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

Unified 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: Flush() uses fdatasync 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_posix.cc
diff --git a/base/files/file_posix.cc b/base/files/file_posix.cc
index 517390f8eacf71135f9e62aff00de4a2d2b7f337..252c3687a15d0584f081df45cbd6caafef4ae6b6 100644
--- a/base/files/file_posix.cc
+++ b/base/files/file_posix.cc
@@ -53,10 +53,6 @@ static int CallFtruncate(PlatformFile file, int64 length) {
return HANDLE_EINTR(ftruncate(file, length));
}
-static int CallFsync(PlatformFile file) {
- return HANDLE_EINTR(fsync(file));
-}
-
static int CallFutimes(PlatformFile file, const struct timeval times[2]) {
#ifdef __USE_XOPEN2K8
// futimens should be available, but futimes might not be
@@ -98,11 +94,6 @@ static int CallFtruncate(PlatformFile file, int64 length) {
return 0;
}
-static int CallFsync(PlatformFile file) {
- NOTIMPLEMENTED(); // NaCl doesn't implement fsync.
- return 0;
-}
-
static int CallFutimes(PlatformFile file, const struct timeval times[2]) {
NOTIMPLEMENTED(); // NaCl doesn't implement futimes.
return 0;
@@ -430,7 +421,14 @@ bool File::SetLength(int64 length) {
bool File::Flush() {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(IsValid());
- return !CallFsync(file_.get());
+#if defined(OS_NACL)
+ NOTIMPLEMENTED(); // NaCl doesn't implement fsync.
+ return true;
+#elif defined(OS_LINUX) || defined(OS_ANDROID)
+ return !HANDLE_EINTR(fdatasync(file_.get()));
+#else
+ return !HANDLE_EINTR(fsync(file_.get()));
+#endif
}
bool File::SetTimes(Time last_access_time, Time last_modified_time) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698