Remove CreatePlatformFile from file_util_proxy
Most of file_util_proxy is going to be deleted soon (users have to migrate to
FileProxy) so this CL is quite superficial. It is intended to remove the last
uses of CreatePlatformFile so that the method can be removed and no new code
can ignore base::File.
BUG=322664
Review URL: https://codereview.chromium.org/227433006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262781 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: 4735522f8b30a06dce580b770f79020adc730352
diff --git a/base/files/file_util_proxy.cc b/base/files/file_util_proxy.cc
index 447552d..0a86393 100644
--- a/base/files/file_util_proxy.cc
+++ b/base/files/file_util_proxy.cc
@@ -90,15 +90,15 @@
PLATFORM_FILE_CREATE_ALWAYS |
additional_file_flags;
- error_ = File::FILE_OK;
- // TODO(rvargas): Convert this code to use File.
- file_handle_ =
- CreatePlatformFile(file_path_, file_flags, NULL,
- reinterpret_cast<PlatformFileError*>(&error_));
- if (error_ != File::FILE_OK) {
+ File file(file_path_, file_flags);
+ if (!file.IsValid()) {
base::DeleteFile(file_path_, false);
file_path_.clear();
+ error_ = file.error_details();
+ return;
}
+ error_ = File::FILE_OK;
+ file_handle_ = file.TakePlatformFile();
}
void Reply(const FileUtilProxy::CreateTemporaryCallback& callback) {
@@ -212,11 +212,14 @@
// If its parent does not exist, should return NOT_FOUND error.
return File::FILE_ERROR_NOT_FOUND;
}
- File::Error error = File::FILE_OK;
- *file_handle =
- CreatePlatformFile(file_path, file_flags, created,
- reinterpret_cast<PlatformFileError*>(&error));
- return error;
+
+ File file(file_path, file_flags);
+ if (!file.IsValid())
+ return file.error_details();
+
+ *file_handle = file.TakePlatformFile();
+ *created = file.created();
+ return File::FILE_OK;
}
File::Error CloseAdapter(PlatformFile file_handle) {