diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-15 00:37:34 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-15 00:37:34 +0000 |
commit | fd55c28d08f5daef2938cc8ec956849fa80ffcbb (patch) | |
tree | b36eec5e70c97649b570ef6395549c043b1ad3fd /webkit/fileapi | |
parent | 1a47d7ea5a641b185283228692c2767a69f09e1a (diff) | |
download | chromium_src-fd55c28d08f5daef2938cc8ec956849fa80ffcbb.zip chromium_src-fd55c28d08f5daef2938cc8ec956849fa80ffcbb.tar.gz chromium_src-fd55c28d08f5daef2938cc8ec956849fa80ffcbb.tar.bz2 |
Rename FileUtilProxy::Create to EnsureFileExists
per follow-up discussion on http://codereview.chromium.org/3717001/show
Rename FileUtilProxy::Create to EnsureFileExists to make it clear that
it doesn't open the file (or doesn't leave a file handle opened).
Also fixes CreatePlatformFile to set |created| correctly when
PLATFORM_FILE_CREATE flag is given (I think this is the correct
behavior).
BUG=none
TEST=FileSystemOperationTest.*
Review URL: http://codereview.chromium.org/3743004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r-- | webkit/fileapi/file_system_operation.cc | 33 | ||||
-rw-r--r-- | webkit/fileapi/file_system_operation.h | 12 |
2 files changed, 19 insertions, 26 deletions
diff --git a/webkit/fileapi/file_system_operation.cc b/webkit/fileapi/file_system_operation.cc index 6a88b6f..0e2e823 100644 --- a/webkit/fileapi/file_system_operation.cc +++ b/webkit/fileapi/file_system_operation.cc @@ -36,11 +36,10 @@ void FileSystemOperation::CreateFile(const FilePath& path, pending_operation_ = kOperationCreateFile; #endif - base::FileUtilProxy::Create( - proxy_, path, base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_READ, - callback_factory_.NewCallback( - exclusive ? &FileSystemOperation::DidCreateFileExclusive - : &FileSystemOperation::DidCreateFileNonExclusive)); + base::FileUtilProxy::EnsureFileExists( + proxy_, path, callback_factory_.NewCallback( + exclusive ? &FileSystemOperation::DidEnsureFileExistsExclusive + : &FileSystemOperation::DidEnsureFileExistsNonExclusive)); } void FileSystemOperation::CreateDirectory(const FilePath& path, @@ -219,23 +218,17 @@ void FileSystemOperation::Cancel(FileSystemOperation* cancel_operation) { } } -void FileSystemOperation::DidCreateFileExclusive( - base::PlatformFileError rv, - base::PassPlatformFile file, - bool created) { - DidFinishFileOperation(rv); +void FileSystemOperation::DidEnsureFileExistsExclusive( + base::PlatformFileError rv, bool created) { + if (rv == base::PLATFORM_FILE_OK && !created) + dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_EXISTS); + else + DidFinishFileOperation(rv); } -void FileSystemOperation::DidCreateFileNonExclusive( - base::PlatformFileError rv, - base::PassPlatformFile file, - bool created) { - // Suppress the already exists error and report success. - if (rv == base::PLATFORM_FILE_OK || - rv == base::PLATFORM_FILE_ERROR_EXISTS) - dispatcher_->DidSucceed(); - else - dispatcher_->DidFail(rv); +void FileSystemOperation::DidEnsureFileExistsNonExclusive( + base::PlatformFileError rv, bool /* created */) { + DidFinishFileOperation(rv); } void FileSystemOperation::DidFinishFileOperation( diff --git a/webkit/fileapi/file_system_operation.h b/webkit/fileapi/file_system_operation.h index bfa4141..6b4599a 100644 --- a/webkit/fileapi/file_system_operation.h +++ b/webkit/fileapi/file_system_operation.h @@ -82,13 +82,13 @@ class FileSystemOperation { scoped_refptr<base::MessageLoopProxy> proxy_; private: - // Callbacks for above methods. - void DidCreateFileExclusive( - base::PlatformFileError rv, base::PassPlatformFile file, bool created); + // Callback for CreateFile for |exclusive|=true cases. + void DidEnsureFileExistsExclusive(base::PlatformFileError rv, + bool created); - // Returns success even if the file already existed. - void DidCreateFileNonExclusive( - base::PlatformFileError rv, base::PassPlatformFile file, bool created); + // Callback for CreateFile for |exclusive|=false cases. + void DidEnsureFileExistsNonExclusive(base::PlatformFileError rv, + bool created); // Generic callback that translates platform errors to WebKit error codes. void DidFinishFileOperation(base::PlatformFileError rv); |