| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 7 #include <stdint.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (length > std::numeric_limits<uint32_t>::max()) | 132 if (length > std::numeric_limits<uint32_t>::max()) |
| 133 return false; | 133 return false; |
| 134 | 134 |
| 135 return base_file_.SetLength(length); | 135 return base_file_.SetLength(length); |
| 136 } | 136 } |
| 137 | 137 |
| 138 size_t File::GetLength() { | 138 size_t File::GetLength() { |
| 139 DCHECK(base_file_.IsValid()); | 139 DCHECK(base_file_.IsValid()); |
| 140 int64_t len = base_file_.GetLength(); | 140 int64_t len = base_file_.GetLength(); |
| 141 | 141 |
| 142 if (len < 0) |
| 143 return 0; |
| 142 if (len > static_cast<int64_t>(std::numeric_limits<uint32_t>::max())) | 144 if (len > static_cast<int64_t>(std::numeric_limits<uint32_t>::max())) |
| 143 return std::numeric_limits<uint32_t>::max(); | 145 return std::numeric_limits<uint32_t>::max(); |
| 144 | 146 |
| 145 return static_cast<size_t>(len); | 147 return static_cast<size_t>(len); |
| 146 } | 148 } |
| 147 | 149 |
| 148 // Static. | 150 // Static. |
| 149 void File::WaitForPendingIO(int* num_pending_io) { | 151 void File::WaitForPendingIO(int* num_pending_io) { |
| 150 // We are running unit tests so we should wait for all callbacks. Sadly, the | 152 // We are running unit tests so we should wait for all callbacks. Sadly, the |
| 151 // worker pool only waits for tasks on the worker pool, not the "Reply" tasks | 153 // worker pool only waits for tasks on the worker pool, not the "Reply" tasks |
| (...skipping 30 matching lines...) Expand all Loading... |
| 182 return net::ERR_CACHE_WRITE_FAILURE; | 184 return net::ERR_CACHE_WRITE_FAILURE; |
| 183 } | 185 } |
| 184 | 186 |
| 185 // This method actually makes sure that the last reference to the file doesn't | 187 // This method actually makes sure that the last reference to the file doesn't |
| 186 // go away on the worker pool. | 188 // go away on the worker pool. |
| 187 void File::OnOperationComplete(FileIOCallback* callback, int result) { | 189 void File::OnOperationComplete(FileIOCallback* callback, int result) { |
| 188 callback->OnFileIOComplete(result); | 190 callback->OnFileIOComplete(result); |
| 189 } | 191 } |
| 190 | 192 |
| 191 } // namespace disk_cache | 193 } // namespace disk_cache |
| OLD | NEW |