Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: net/disk_cache/blockfile/file_ios.cc

Issue 1492403002: Remove kuint32max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: http security header file Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/disk_cache/blockfile/backend_impl_v3.cc ('k') | net/disk_cache/blockfile/file_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h>
8
9 #include <limits>
10
7 #include "base/bind.h" 11 #include "base/bind.h"
8 #include "base/location.h" 12 #include "base/location.h"
9 #include "base/logging.h" 13 #include "base/logging.h"
10 #include "base/threading/worker_pool.h" 14 #include "base/threading/worker_pool.h"
11 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
12 #include "net/disk_cache/blockfile/in_flight_io.h" 16 #include "net/disk_cache/blockfile/in_flight_io.h"
13 #include "net/disk_cache/disk_cache.h" 17 #include "net/disk_cache/disk_cache.h"
14 18
15 namespace { 19 namespace {
16 20
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 base_file_.Initialize(name, flags); 185 base_file_.Initialize(name, flags);
182 return base_file_.IsValid(); 186 return base_file_.IsValid();
183 } 187 }
184 188
185 bool File::IsValid() const { 189 bool File::IsValid() const {
186 return base_file_.IsValid(); 190 return base_file_.IsValid();
187 } 191 }
188 192
189 bool File::Read(void* buffer, size_t buffer_len, size_t offset) { 193 bool File::Read(void* buffer, size_t buffer_len, size_t offset) {
190 DCHECK(base_file_.IsValid()); 194 DCHECK(base_file_.IsValid());
191 if (buffer_len > static_cast<size_t>(kint32max) || 195 if (buffer_len > static_cast<size_t>(std::numeric_limits<int32_t>::max()) ||
192 offset > static_cast<size_t>(kint32max)) { 196 offset > static_cast<size_t>(std::numeric_limits<int32_t>::max())) {
193 return false; 197 return false;
194 } 198 }
195 199
196 int ret = base_file_.Read(offset, static_cast<char*>(buffer), buffer_len); 200 int ret = base_file_.Read(offset, static_cast<char*>(buffer), buffer_len);
197 return (static_cast<size_t>(ret) == buffer_len); 201 return (static_cast<size_t>(ret) == buffer_len);
198 } 202 }
199 203
200 bool File::Write(const void* buffer, size_t buffer_len, size_t offset) { 204 bool File::Write(const void* buffer, size_t buffer_len, size_t offset) {
201 DCHECK(base_file_.IsValid()); 205 DCHECK(base_file_.IsValid());
202 if (buffer_len > static_cast<size_t>(kint32max) || 206 if (buffer_len > static_cast<size_t>(std::numeric_limits<int32_t>::max()) ||
203 offset > static_cast<size_t>(kint32max)) { 207 offset > static_cast<size_t>(std::numeric_limits<int32_t>::max())) {
204 return false; 208 return false;
205 } 209 }
206 210
207 int ret = base_file_.Write(offset, static_cast<const char*>(buffer), 211 int ret = base_file_.Write(offset, static_cast<const char*>(buffer),
208 buffer_len); 212 buffer_len);
209 return (static_cast<size_t>(ret) == buffer_len); 213 return (static_cast<size_t>(ret) == buffer_len);
210 } 214 }
211 215
212 // We have to increase the ref counter of the file before performing the IO to 216 // We have to increase the ref counter of the file before performing the IO to
213 // prevent the completion to happen with an invalid handle (if the file is 217 // prevent the completion to happen with an invalid handle (if the file is
(...skipping 23 matching lines...) Expand all
237 if (completed) 241 if (completed)
238 *completed = true; 242 *completed = true;
239 return Write(buffer, buffer_len, offset); 243 return Write(buffer, buffer_len, offset);
240 } 244 }
241 245
242 return AsyncWrite(buffer, buffer_len, offset, callback, completed); 246 return AsyncWrite(buffer, buffer_len, offset, callback, completed);
243 } 247 }
244 248
245 bool File::SetLength(size_t length) { 249 bool File::SetLength(size_t length) {
246 DCHECK(base_file_.IsValid()); 250 DCHECK(base_file_.IsValid());
247 if (length > kuint32max) 251 if (length > std::numeric_limits<uint32_t>::max())
248 return false; 252 return false;
249 253
250 return base_file_.SetLength(length); 254 return base_file_.SetLength(length);
251 } 255 }
252 256
253 size_t File::GetLength() { 257 size_t File::GetLength() {
254 DCHECK(base_file_.IsValid()); 258 DCHECK(base_file_.IsValid());
255 int64 len = base_file_.GetLength(); 259 int64_t len = base_file_.GetLength();
256 260
257 if (len > static_cast<int64>(kuint32max)) 261 if (len > static_cast<int64_t>(std::numeric_limits<uint32_t>::max()))
258 return kuint32max; 262 return std::numeric_limits<uint32_t>::max();
259 263
260 return static_cast<size_t>(len); 264 return static_cast<size_t>(len);
261 } 265 }
262 266
263 // Static. 267 // Static.
264 void File::WaitForPendingIO(int* num_pending_io) { 268 void File::WaitForPendingIO(int* num_pending_io) {
265 // We may be running unit tests so we should allow be able to reset the 269 // We may be running unit tests so we should allow be able to reset the
266 // message loop. 270 // message loop.
267 GetFileInFlightIO()->WaitForPendingIO(); 271 GetFileInFlightIO()->WaitForPendingIO();
268 DeleteFileInFlightIO(); 272 DeleteFileInFlightIO();
(...skipping 19 matching lines...) Expand all
288 return false; 292 return false;
289 293
290 GetFileInFlightIO()->PostWrite(this, buffer, buffer_len, offset, callback); 294 GetFileInFlightIO()->PostWrite(this, buffer, buffer_len, offset, callback);
291 295
292 if (completed) 296 if (completed)
293 *completed = false; 297 *completed = false;
294 return true; 298 return true;
295 } 299 }
296 300
297 } // namespace disk_cache 301 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/backend_impl_v3.cc ('k') | net/disk_cache/blockfile/file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698