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

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

Issue 1023103002: Let ImportantFileWriter Use fdatasync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
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 <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 DCHECK(IsValid()); 426 DCHECK(IsValid());
427 return !CallFtruncate(file_.get(), length); 427 return !CallFtruncate(file_.get(), length);
428 } 428 }
429 429
430 bool File::Flush() { 430 bool File::Flush() {
431 base::ThreadRestrictions::AssertIOAllowed(); 431 base::ThreadRestrictions::AssertIOAllowed();
432 DCHECK(IsValid()); 432 DCHECK(IsValid());
433 return !CallFsync(file_.get()); 433 return !CallFsync(file_.get());
434 } 434 }
435 435
436 bool File::FlushData() {
437 #if defined(OS_LINUX) || defined(OS_ANDROID)
438 base::ThreadRestrictions::AssertIOAllowed();
439 DCHECK(IsValid());
440 return !HANDLE_EINTR(fdatasync(file_.get()));
rvargas (doing something else) 2015/03/20 18:56:05 is fdatasync a Linux-only thing? What's the behavi
hashimoto 2015/03/20 19:38:57 fdatasync is a part of POSIX, but it's not mandato
441 #else
442 return Flush();
443 #endif
444 }
445
436 bool File::SetTimes(Time last_access_time, Time last_modified_time) { 446 bool File::SetTimes(Time last_access_time, Time last_modified_time) {
437 base::ThreadRestrictions::AssertIOAllowed(); 447 base::ThreadRestrictions::AssertIOAllowed();
438 DCHECK(IsValid()); 448 DCHECK(IsValid());
439 449
440 timeval times[2]; 450 timeval times[2];
441 times[0] = last_access_time.ToTimeVal(); 451 times[0] = last_access_time.ToTimeVal();
442 times[1] = last_modified_time.ToTimeVal(); 452 times[1] = last_modified_time.ToTimeVal();
443 453
444 return !CallFutimes(file_.get(), times); 454 return !CallFutimes(file_.get(), times);
445 } 455 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 567 }
558 568
559 void File::SetPlatformFile(PlatformFile file) { 569 void File::SetPlatformFile(PlatformFile file) {
560 CHECK(!file_.is_valid()); 570 CHECK(!file_.is_valid());
561 file_.reset(file); 571 file_.reset(file);
562 if (file_.is_valid()) 572 if (file_.is_valid())
563 ProtectFileDescriptor(GetPlatformFile()); 573 ProtectFileDescriptor(GetPlatformFile());
564 } 574 }
565 575
566 } // namespace base 576 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698