| 986 | } |
| 987 | |
| 988 | bool TmpFileLocal::AllocateSpace(int64_t num_bytes, int64_t* offset) { |
| 989 | DCHECK_GT(num_bytes, 0); |
| 990 | TmpDir* dir = GetDir(); |
| 991 | // Increment optimistically and roll back if the limit is exceeded. |
| 992 | if (dir->bytes_used_metric()->Increment(num_bytes) > dir->bytes_limit()) { |
| 993 | dir->bytes_used_metric()->Increment(-num_bytes); |
| 994 | return false; |
| 995 | } |
| 996 | *offset = allocation_offset_; |
| 997 | allocation_offset_ += num_bytes; |
| 998 | return true; |
| 999 | } |
| 1000 | |
| 1001 | io::DiskFile* TmpFileLocal::GetWriteFile() { |
| 1002 | return disk_file_.get(); |