Port base/files/file_util_proxy to Native Client.
There is a lot here that we will never implement in NaCl. Use #ifdefs to port
enough to allow us to use FileUtilProxy to implement blocking file operations
in NaCl.
BUG=194304
Review URL: https://chromiumcodereview.appspot.com/17779003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211271 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: 0b663eae84d1996b38836b79b6b5e0cb2b8fee73
diff --git a/base/files/file_util_proxy.cc b/base/files/file_util_proxy.cc
index 5eb9fe5..721f671 100644
--- a/base/files/file_util_proxy.cc
+++ b/base/files/file_util_proxy.cc
@@ -22,6 +22,7 @@
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 @@
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 (!PathExists(file_path)) {
error_ = PLATFORM_FILE_ERROR_NOT_FOUND;
@@ -114,6 +117,7 @@
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_))
@@ -187,7 +191,7 @@
DISALLOW_COPY_AND_ASSIGN(WriteHelper);
};
-
+#if !defined(OS_NACL)
PlatformFileError CreateOrOpenAdapter(
const FilePath& file_path, int file_flags,
PlatformFile* file_handle, bool* created) {
@@ -201,6 +205,7 @@
*file_handle = CreatePlatformFile(file_path, file_flags, created, &error);
return error;
}
+#endif // !defined(OS_NACL)
PlatformFileError CloseAdapter(PlatformFile file_handle) {
if (!ClosePlatformFile(file_handle)) {
@@ -209,6 +214,7 @@
return PLATFORM_FILE_OK;
}
+#if !defined(OS_NACL)
PlatformFileError DeleteAdapter(const FilePath& file_path, bool recursive) {
if (!PathExists(file_path)) {
return PLATFORM_FILE_ERROR_NOT_FOUND;
@@ -221,9 +227,11 @@
}
return PLATFORM_FILE_OK;
}
+#endif // !defined(OS_NACL)
} // namespace
+#if !defined(OS_NACL)
// static
bool FileUtilProxy::CreateOrOpen(
TaskRunner* task_runner,
@@ -248,6 +256,7 @@
additional_file_flags),
Bind(&CreateTemporaryHelper::Reply, Owned(helper), callback));
}
+#endif // !defined(OS_NACL)
// static
bool FileUtilProxy::Close(
@@ -260,6 +269,7 @@
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 +283,7 @@
Unretained(helper), file_path),
Bind(&GetFileInfoHelper::Reply, Owned(helper), callback));
}
+#endif // !defined(OS_NACL)
// static
bool FileUtilProxy::GetFileInfoFromPlatformFile(
@@ -287,6 +298,7 @@
Bind(&GetFileInfoHelper::Reply, Owned(helper), callback));
}
+#if !defined(OS_NACL)
// static
bool FileUtilProxy::Delete(TaskRunner* task_runner,
const FilePath& file_path,
@@ -308,6 +320,7 @@
Bind(&DeleteAdapter, file_path, true /* recursive */),
callback);
}
+#endif // !defined(OS_NACL)
// static
bool FileUtilProxy::Read(
@@ -344,6 +357,7 @@
Bind(&WriteHelper::Reply, Owned(helper), callback));
}
+#if !defined(OS_NACL)
// static
bool FileUtilProxy::Touch(
TaskRunner* task_runner,
@@ -412,6 +426,7 @@
Bind(&CreateOrOpenHelper::RunWork, Unretained(helper), open_task),
Bind(&CreateOrOpenHelper::Reply, Owned(helper), callback));
}
+#endif // !defined(OS_NACL)
// static
bool FileUtilProxy::RelayClose(