diff options
author | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-24 01:09:32 +0000 |
---|---|---|
committer | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-24 01:09:32 +0000 |
commit | 9fae63af34efd773d1bc275909069a40789d8abf (patch) | |
tree | 36445623712986235cc1c067ee7304920986026c /base | |
parent | ac716267efc98d9fcdf9c3c22b10e6a9d8a9dbc8 (diff) | |
download | chromium_src-9fae63af34efd773d1bc275909069a40789d8abf.zip chromium_src-9fae63af34efd773d1bc275909069a40789d8abf.tar.gz chromium_src-9fae63af34efd773d1bc275909069a40789d8abf.tar.bz2 |
Adding a FileUtilProxy::TouchFile() method that takes a FilePath as an
argument (instead of PlatformFile).
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3380024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60397 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/file_util_proxy.cc | 37 | ||||
-rw-r--r-- | base/file_util_proxy.h | 8 |
2 files changed, 45 insertions, 0 deletions
diff --git a/base/file_util_proxy.cc b/base/file_util_proxy.cc index 941dede..bd25ddd 100644 --- a/base/file_util_proxy.cc +++ b/base/file_util_proxy.cc @@ -557,6 +557,31 @@ class RelayTouch : public RelayWithStatusCallback { base::Time last_modified_time_; }; +class RelayTouchFilePath : public RelayWithStatusCallback { + public: + RelayTouchFilePath(const FilePath& file_path, + const base::Time& last_access_time, + const base::Time& last_modified_time, + base::FileUtilProxy::StatusCallback* callback) + : RelayWithStatusCallback(callback), + file_path_(file_path_), + last_access_time_(last_access_time), + last_modified_time_(last_modified_time) { + } + + protected: + virtual void RunWork() { + if (!file_util::TouchFile( + file_path_, last_access_time_, last_modified_time_)) + set_error_code(base::PLATFORM_FILE_ERROR_FAILED); + } + + private: + FilePath file_path_; + base::Time last_access_time_; + base::Time last_modified_time_; +}; + class RelayTruncate : public RelayWithStatusCallback { public: RelayTruncate(base::PlatformFile file, @@ -742,6 +767,18 @@ bool FileUtilProxy::Touch( } // static +bool FileUtilProxy::Touch( + scoped_refptr<MessageLoopProxy> message_loop_proxy, + const FilePath& file_path, + const base::Time& last_access_time, + const base::Time& last_modified_time, + StatusCallback* callback) { + return Start(FROM_HERE, message_loop_proxy, + new RelayTouchFilePath(file_path, last_access_time, + last_modified_time, callback)); +} + +// static bool FileUtilProxy::Truncate( scoped_refptr<MessageLoopProxy> message_loop_proxy, PlatformFile file, diff --git a/base/file_util_proxy.h b/base/file_util_proxy.h index 581738d..081c11b 100644 --- a/base/file_util_proxy.h +++ b/base/file_util_proxy.h @@ -155,6 +155,14 @@ class FileUtilProxy { const base::Time& last_modified_time, StatusCallback* callback); + // Touches a file. The callback can be NULL. + static bool Touch( + scoped_refptr<MessageLoopProxy> message_loop_proxy, + const FilePath& file_path, + const base::Time& last_access_time, + const base::Time& last_modified_time, + StatusCallback* callback); + // Truncates a file to the given length. If |length| is greater than the // current length of the file, the file will be extended with zeroes. // The callback can be NULL. |