Index: base/files/file_util_proxy.cc |
diff --git a/base/files/file_util_proxy.cc b/base/files/file_util_proxy.cc |
index 9f65da8ec98d40b05631de605302334056a9163a..eb3dd08b01e6e3112613be5d8a4359193e35c295 100644 |
--- a/base/files/file_util_proxy.cc |
+++ b/base/files/file_util_proxy.cc |
@@ -22,6 +22,7 @@ void CallWithTranslatedParameter(const FileUtilProxy::StatusCallback& callback, |
callback.Run(value ? PLATFORM_FILE_OK : PLATFORM_FILE_ERROR_FAILED); |
} |
+#if !defined(OS_NACL) |
// Helper classes or routines for individual methods. |
class CreateOrOpenHelper { |
public: |
@@ -100,12 +101,14 @@ class CreateTemporaryHelper { |
PlatformFileError error_; |
DISALLOW_COPY_AND_ASSIGN(CreateTemporaryHelper); |
}; |
+#endif // !defined(OS_NACL) |
class GetFileInfoHelper { |
public: |
GetFileInfoHelper() |
: error_(PLATFORM_FILE_OK) {} |
+#if !defined(OS_NACL) |
void RunWorkForFilePath(const FilePath& file_path) { |
if (!file_util::PathExists(file_path)) { |
error_ = PLATFORM_FILE_ERROR_NOT_FOUND; |
@@ -114,6 +117,7 @@ class GetFileInfoHelper { |
if (!file_util::GetFileInfo(file_path, &file_info_)) |
error_ = PLATFORM_FILE_ERROR_FAILED; |
} |
+#endif // !defined(OS_NACL) |
void RunWorkForPlatformFile(PlatformFile file) { |
if (!GetPlatformFileInfo(file, &file_info_)) |
@@ -140,7 +144,14 @@ class ReadHelper { |
bytes_read_(0) {} |
void RunWork(PlatformFile file, int64 offset) { |
+#if !defined(OS_NACL) |
bytes_read_ = ReadPlatformFile(file, offset, buffer_.get(), bytes_to_read_); |
+#else |
+ // TODO(bbudge) Eliminate this when NaCl supports pread. |
+ SeekPlatformFile(file, PLATFORM_FILE_FROM_BEGIN, offset); |
brettw
2013/07/09 20:05:37
Does it make more sense to implement ReadPlatformF
bbudge
2013/07/09 21:54:54
Yeah, it looks like it does. Done.
|
+ bytes_read_ = ReadPlatformFileAtCurrentPos(file, buffer_.get(), |
+ bytes_to_read_); |
+#endif |
} |
void Reply(const FileUtilProxy::ReadCallback& callback) { |
@@ -168,8 +179,15 @@ class WriteHelper { |
} |
void RunWork(PlatformFile file, int64 offset) { |
+#if !defined(OS_NACL) |
bytes_written_ = WritePlatformFile(file, offset, buffer_.get(), |
bytes_to_write_); |
+#else |
+ // TODO(bbudge) Eliminate this when NaCl supports pwrite. |
+ SeekPlatformFile(file, PLATFORM_FILE_FROM_BEGIN, offset); |
+ bytes_written_ = WritePlatformFileAtCurrentPos(file, buffer_.get(), |
+ bytes_to_write_); |
+#endif |
} |
void Reply(const FileUtilProxy::WriteCallback& callback) { |
@@ -187,7 +205,7 @@ class WriteHelper { |
DISALLOW_COPY_AND_ASSIGN(WriteHelper); |
}; |
- |
+#if !defined(OS_NACL) |
PlatformFileError CreateOrOpenAdapter( |
const FilePath& file_path, int file_flags, |
PlatformFile* file_handle, bool* created) { |
@@ -202,6 +220,7 @@ PlatformFileError CreateOrOpenAdapter( |
return error; |
} |
+#endif // !defined(OS_NACL) |
PlatformFileError CloseAdapter(PlatformFile file_handle) { |
if (!ClosePlatformFile(file_handle)) { |
return PLATFORM_FILE_ERROR_FAILED; |
@@ -209,6 +228,7 @@ PlatformFileError CloseAdapter(PlatformFile file_handle) { |
return PLATFORM_FILE_OK; |
} |
+#if !defined(OS_NACL) |
PlatformFileError DeleteAdapter(const FilePath& file_path, bool recursive) { |
if (!file_util::PathExists(file_path)) { |
return PLATFORM_FILE_ERROR_NOT_FOUND; |
@@ -221,9 +241,11 @@ PlatformFileError DeleteAdapter(const FilePath& file_path, bool recursive) { |
} |
return PLATFORM_FILE_OK; |
} |
+#endif // !defined(OS_NACL) |
} // namespace |
+#if !defined(OS_NACL) |
// static |
bool FileUtilProxy::CreateOrOpen( |
TaskRunner* task_runner, |
@@ -248,6 +270,7 @@ bool FileUtilProxy::CreateTemporary( |
additional_file_flags), |
Bind(&CreateTemporaryHelper::Reply, Owned(helper), callback)); |
} |
+#endif // !defined(OS_NACL) |
// static |
bool FileUtilProxy::Close( |
@@ -260,6 +283,7 @@ bool FileUtilProxy::Close( |
file_handle, callback); |
} |
+#if !defined(OS_NACL) |
// Retrieves the information about a file. It is invalid to pass NULL for the |
// callback. |
bool FileUtilProxy::GetFileInfo( |
@@ -273,6 +297,7 @@ bool FileUtilProxy::GetFileInfo( |
Unretained(helper), file_path), |
Bind(&GetFileInfoHelper::Reply, Owned(helper), callback)); |
} |
+#endif // !defined(OS_NACL) |
// static |
bool FileUtilProxy::GetFileInfoFromPlatformFile( |
@@ -287,6 +312,7 @@ bool FileUtilProxy::GetFileInfoFromPlatformFile( |
Bind(&GetFileInfoHelper::Reply, Owned(helper), callback)); |
} |
+#if !defined(OS_NACL) |
// static |
bool FileUtilProxy::Delete(TaskRunner* task_runner, |
const FilePath& file_path, |
@@ -308,6 +334,7 @@ bool FileUtilProxy::RecursiveDelete( |
Bind(&DeleteAdapter, file_path, true /* recursive */), |
callback); |
} |
+#endif // !defined(OS_NACL) |
// static |
bool FileUtilProxy::Read( |
@@ -344,6 +371,7 @@ bool FileUtilProxy::Write( |
Bind(&WriteHelper::Reply, Owned(helper), callback)); |
} |
+#if !defined(OS_NACL) |
// static |
bool FileUtilProxy::Touch( |
TaskRunner* task_runner, |
@@ -412,6 +440,7 @@ bool FileUtilProxy::RelayCreateOrOpen( |
Bind(&CreateOrOpenHelper::RunWork, Unretained(helper), open_task), |
Bind(&CreateOrOpenHelper::Reply, Owned(helper), callback)); |
} |
+#endif // !defined(OS_NACL) |
// static |
bool FileUtilProxy::RelayClose( |