diff options
author | noelutz@google.com <noelutz@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-13 20:29:50 +0000 |
---|---|---|
committer | noelutz@google.com <noelutz@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-13 20:29:50 +0000 |
commit | 86ecf51b45fffd9d83247a4652f892af1c9c28a5 (patch) | |
tree | 4f5e50dc45f4ad8f719220374113c59f3e47af2c /base | |
parent | a6e4b0d03c3f6ae99b3d3879ab93b2e6e09de983 (diff) | |
download | chromium_src-86ecf51b45fffd9d83247a4652f892af1c9c28a5.zip chromium_src-86ecf51b45fffd9d83247a4652f892af1c9c28a5.tar.gz chromium_src-86ecf51b45fffd9d83247a4652f892af1c9c28a5.tar.bz2 |
Support creating temporary files for sync file operations.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/7066067
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88884 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/file_util_proxy.cc | 17 | ||||
-rw-r--r-- | base/file_util_proxy.h | 9 |
2 files changed, 19 insertions, 7 deletions
diff --git a/base/file_util_proxy.cc b/base/file_util_proxy.cc index 1d5b9cc..cff76bde 100644 --- a/base/file_util_proxy.cc +++ b/base/file_util_proxy.cc @@ -167,8 +167,10 @@ class RelayCreateTemporary : public MessageLoopRelay { public: RelayCreateTemporary( scoped_refptr<base::MessageLoopProxy> message_loop_proxy, + int additional_file_flags, base::FileUtilProxy::CreateTemporaryCallback* callback) : message_loop_proxy_(message_loop_proxy), + additional_file_flags_(additional_file_flags), callback_(callback), file_handle_(base::kInvalidPlatformFileValue) { DCHECK(callback); @@ -185,13 +187,12 @@ class RelayCreateTemporary : public MessageLoopRelay { // that returns a FilePath and a PlatformFile. file_util::CreateTemporaryFile(&file_path_); - // Use a fixed set of flags that are appropriate for writing to a temporary - // file from the IO thread using a net::FileStream. int file_flags = - base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE | - base::PLATFORM_FILE_ASYNC | - base::PLATFORM_FILE_TEMPORARY; + base::PLATFORM_FILE_TEMPORARY | + base::PLATFORM_FILE_CREATE_ALWAYS | + additional_file_flags_; + base::PlatformFileError error_code = base::PLATFORM_FILE_OK; file_handle_ = base::CreatePlatformFile(file_path_, file_flags, NULL, &error_code); @@ -206,6 +207,7 @@ class RelayCreateTemporary : public MessageLoopRelay { private: scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; + int additional_file_flags_; base::FileUtilProxy::CreateTemporaryCallback* callback_; base::PlatformFile file_handle_; FilePath file_path_; @@ -742,9 +744,12 @@ bool FileUtilProxy::CreateOrOpen( // static bool FileUtilProxy::CreateTemporary( scoped_refptr<MessageLoopProxy> message_loop_proxy, + int additional_file_flags, CreateTemporaryCallback* callback) { return Start(FROM_HERE, message_loop_proxy, - new RelayCreateTemporary(message_loop_proxy, callback)); + new RelayCreateTemporary(message_loop_proxy, + additional_file_flags, + callback)); } // static diff --git a/base/file_util_proxy.h b/base/file_util_proxy.h index e0b04cb..72591c2 100644 --- a/base/file_util_proxy.h +++ b/base/file_util_proxy.h @@ -64,9 +64,16 @@ class BASE_API FileUtilProxy { CreateOrOpenCallback* callback); // Creates a temporary file for writing. The path and an open file handle - // are returned. It is invalid to pass NULL for the callback. + // are returned. It is invalid to pass NULL for the callback. The additional + // file flags will be added on top of the default file flags which are: + // base::PLATFORM_FILE_CREATE_ALWAYS + // base::PLATFORM_FILE_WRITE + // base::PLATFORM_FILE_TEMPORARY. + // Set |additional_file_flags| to 0 for synchronous writes and set to + // base::PLATFORM_FILE_ASYNC to support asynchronous file operations. static bool CreateTemporary( scoped_refptr<MessageLoopProxy> message_loop_proxy, + int additional_file_flags, CreateTemporaryCallback* callback); // Close the given file handle. |