| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/disk_cache/blockfile/file.h" | 5 #include "net/disk_cache/blockfile/file.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 if (length > std::numeric_limits<uint32_t>::max()) | 251 if (length > std::numeric_limits<uint32_t>::max()) |
| 252 return false; | 252 return false; |
| 253 | 253 |
| 254 return base_file_.SetLength(length); | 254 return base_file_.SetLength(length); |
| 255 } | 255 } |
| 256 | 256 |
| 257 size_t File::GetLength() { | 257 size_t File::GetLength() { |
| 258 DCHECK(base_file_.IsValid()); | 258 DCHECK(base_file_.IsValid()); |
| 259 int64_t len = base_file_.GetLength(); | 259 int64_t len = base_file_.GetLength(); |
| 260 | 260 |
| 261 if (len < 0) |
| 262 return 0; |
| 261 if (len > static_cast<int64_t>(std::numeric_limits<uint32_t>::max())) | 263 if (len > static_cast<int64_t>(std::numeric_limits<uint32_t>::max())) |
| 262 return std::numeric_limits<uint32_t>::max(); | 264 return std::numeric_limits<uint32_t>::max(); |
| 263 | 265 |
| 264 return static_cast<size_t>(len); | 266 return static_cast<size_t>(len); |
| 265 } | 267 } |
| 266 | 268 |
| 267 // Static. | 269 // Static. |
| 268 void File::WaitForPendingIO(int* num_pending_io) { | 270 void File::WaitForPendingIO(int* num_pending_io) { |
| 269 // We may be running unit tests so we should allow be able to reset the | 271 // We may be running unit tests so we should allow be able to reset the |
| 270 // message loop. | 272 // message loop. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 292 return false; | 294 return false; |
| 293 | 295 |
| 294 GetFileInFlightIO()->PostWrite(this, buffer, buffer_len, offset, callback); | 296 GetFileInFlightIO()->PostWrite(this, buffer, buffer_len, offset, callback); |
| 295 | 297 |
| 296 if (completed) | 298 if (completed) |
| 297 *completed = false; | 299 *completed = false; |
| 298 return true; | 300 return true; |
| 299 } | 301 } |
| 300 | 302 |
| 301 } // namespace disk_cache | 303 } // namespace disk_cache |
| OLD | NEW |