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

Side by Side Diff: base/files/file_win.cc

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 months 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 | « base/files/file_tracing.cc ('k') | base/files/memory_mapped_file.h » ('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 (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 "base/files/file.h" 5 #include "base/files/file.h"
6 6
7 #include <io.h> 7 #include <io.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 case ERROR_FILE_CORRUPT: 301 case ERROR_FILE_CORRUPT:
302 case ERROR_DISK_CORRUPT: 302 case ERROR_DISK_CORRUPT:
303 return FILE_ERROR_IO; 303 return FILE_ERROR_IO;
304 default: 304 default:
305 UMA_HISTOGRAM_SPARSE_SLOWLY("PlatformFile.UnknownErrors.Windows", 305 UMA_HISTOGRAM_SPARSE_SLOWLY("PlatformFile.UnknownErrors.Windows",
306 last_error); 306 last_error);
307 return FILE_ERROR_FAILED; 307 return FILE_ERROR_FAILED;
308 } 308 }
309 } 309 }
310 310
311 void File::DoInitialize(uint32 flags) { 311 void File::DoInitialize(const FilePath& path, uint32 flags) {
312 ThreadRestrictions::AssertIOAllowed(); 312 ThreadRestrictions::AssertIOAllowed();
313 DCHECK(!IsValid()); 313 DCHECK(!IsValid());
314 314
315 DWORD disposition = 0; 315 DWORD disposition = 0;
316 316
317 if (flags & FLAG_OPEN) 317 if (flags & FLAG_OPEN)
318 disposition = OPEN_EXISTING; 318 disposition = OPEN_EXISTING;
319 319
320 if (flags & FLAG_CREATE) { 320 if (flags & FLAG_CREATE) {
321 DCHECK(!disposition); 321 DCHECK(!disposition);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 create_flags |= FILE_FLAG_OVERLAPPED; 369 create_flags |= FILE_FLAG_OVERLAPPED;
370 if (flags & FLAG_TEMPORARY) 370 if (flags & FLAG_TEMPORARY)
371 create_flags |= FILE_ATTRIBUTE_TEMPORARY; 371 create_flags |= FILE_ATTRIBUTE_TEMPORARY;
372 if (flags & FLAG_HIDDEN) 372 if (flags & FLAG_HIDDEN)
373 create_flags |= FILE_ATTRIBUTE_HIDDEN; 373 create_flags |= FILE_ATTRIBUTE_HIDDEN;
374 if (flags & FLAG_DELETE_ON_CLOSE) 374 if (flags & FLAG_DELETE_ON_CLOSE)
375 create_flags |= FILE_FLAG_DELETE_ON_CLOSE; 375 create_flags |= FILE_FLAG_DELETE_ON_CLOSE;
376 if (flags & FLAG_BACKUP_SEMANTICS) 376 if (flags & FLAG_BACKUP_SEMANTICS)
377 create_flags |= FILE_FLAG_BACKUP_SEMANTICS; 377 create_flags |= FILE_FLAG_BACKUP_SEMANTICS;
378 378
379 file_.Set(CreateFile(path_.value().c_str(), access, sharing, NULL, 379 file_.Set(CreateFile(path.value().c_str(), access, sharing, NULL, disposition,
380 disposition, create_flags, NULL)); 380 create_flags, NULL));
381 381
382 if (file_.IsValid()) { 382 if (file_.IsValid()) {
383 error_details_ = FILE_OK; 383 error_details_ = FILE_OK;
384 async_ = ((flags & FLAG_ASYNC) == FLAG_ASYNC); 384 async_ = ((flags & FLAG_ASYNC) == FLAG_ASYNC);
385 385
386 if (flags & (FLAG_OPEN_ALWAYS)) 386 if (flags & (FLAG_OPEN_ALWAYS))
387 created_ = (ERROR_ALREADY_EXISTS != GetLastError()); 387 created_ = (ERROR_ALREADY_EXISTS != GetLastError());
388 else if (flags & (FLAG_CREATE_ALWAYS | FLAG_CREATE)) 388 else if (flags & (FLAG_CREATE_ALWAYS | FLAG_CREATE))
389 created_ = true; 389 created_ = true;
390 } else { 390 } else {
391 error_details_ = OSErrorToFileError(GetLastError()); 391 error_details_ = OSErrorToFileError(GetLastError());
392 } 392 }
393 } 393 }
394 394
395 bool File::DoFlush() { 395 bool File::DoFlush() {
396 ThreadRestrictions::AssertIOAllowed(); 396 ThreadRestrictions::AssertIOAllowed();
397 DCHECK(IsValid()); 397 DCHECK(IsValid());
398 return ::FlushFileBuffers(file_.Get()) != FALSE; 398 return ::FlushFileBuffers(file_.Get()) != FALSE;
399 } 399 }
400 400
401 void File::SetPlatformFile(PlatformFile file) { 401 void File::SetPlatformFile(PlatformFile file) {
402 file_.Set(file); 402 file_.Set(file);
403 } 403 }
404 404
405 } // namespace base 405 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_tracing.cc ('k') | base/files/memory_mapped_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698