diff options
author | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 01:58:45 +0000 |
---|---|---|
committer | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 01:58:45 +0000 |
commit | c9f87ae7ddfa0fc8ca2d20a91572198c42b81b18 (patch) | |
tree | b3cc1f0564805e9cd085aebe860fffe4a2a20b5a /base | |
parent | 43fad839433bfa7561f86e0f4629f5a9b2b31b3e (diff) | |
download | chromium_src-c9f87ae7ddfa0fc8ca2d20a91572198c42b81b18.zip chromium_src-c9f87ae7ddfa0fc8ca2d20a91572198c42b81b18.tar.gz chromium_src-c9f87ae7ddfa0fc8ca2d20a91572198c42b81b18.tar.bz2 |
Revert 61462 - Add truncate and cancel for FileWriter; write and more tests will come in later CLs.
This CL also contains a fair amount of plumbing for the write call itself.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3599011
TBR=ericu@google.com
Review URL: http://codereview.chromium.org/3604006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/file_util_proxy.cc | 57 | ||||
-rw-r--r-- | base/file_util_proxy.h | 13 |
2 files changed, 9 insertions, 61 deletions
diff --git a/base/file_util_proxy.cc b/base/file_util_proxy.cc index d71f374..7f7b03a 100644 --- a/base/file_util_proxy.cc +++ b/base/file_util_proxy.cc @@ -498,7 +498,7 @@ class RelayRead : public MessageLoopRelay { class RelayWrite : public MessageLoopRelay { public: RelayWrite(base::PlatformFile file, - int64 offset, + long long offset, const char* buffer, int bytes_to_write, base::FileUtilProxy::ReadWriteCallback* callback) @@ -582,57 +582,24 @@ class RelayTouchFilePath : public RelayWithStatusCallback { base::Time last_modified_time_; }; -class RelayTruncatePlatformFile : public RelayWithStatusCallback { - public: - RelayTruncatePlatformFile(base::PlatformFile file, - int64 length, - base::FileUtilProxy::StatusCallback* callback) - : RelayWithStatusCallback(callback), - file_(file), - length_(length) { - } - - protected: - virtual void RunWork() { - if (!base::TruncatePlatformFile(file_, length_)) - set_error_code(base::PLATFORM_FILE_ERROR_FAILED); - } - - private: - base::PlatformFile file_; - int64 length_; -}; - class RelayTruncate : public RelayWithStatusCallback { public: - RelayTruncate(const FilePath& path, + RelayTruncate(base::PlatformFile file, int64 length, base::FileUtilProxy::StatusCallback* callback) : RelayWithStatusCallback(callback), - path_(path), + file_(file), length_(length) { } protected: virtual void RunWork() { - base::PlatformFileError error_code(base::PLATFORM_FILE_ERROR_FAILED); - base::PlatformFile file = - base::CreatePlatformFile( - path_, - base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE, - NULL, - &error_code); - if (error_code != base::PLATFORM_FILE_OK) { - set_error_code(error_code); - return; - } - if (!base::TruncatePlatformFile(file, length_)) + if (!base::TruncatePlatformFile(file_, length_)) set_error_code(base::PLATFORM_FILE_ERROR_FAILED); - base::ClosePlatformFile(file); } private: - FilePath path_; + base::PlatformFile file_; int64 length_; }; @@ -815,20 +782,10 @@ bool FileUtilProxy::Touch( bool FileUtilProxy::Truncate( scoped_refptr<MessageLoopProxy> message_loop_proxy, PlatformFile file, - int64 length, - StatusCallback* callback) { - return Start(FROM_HERE, message_loop_proxy, - new RelayTruncatePlatformFile(file, length, callback)); -} - -// static -bool FileUtilProxy::Truncate( - scoped_refptr<MessageLoopProxy> message_loop_proxy, - const FilePath& path, - int64 length, + long long length, StatusCallback* callback) { return Start(FROM_HERE, message_loop_proxy, - new RelayTruncate(path, length, callback)); + new RelayTruncate(file, length, callback)); } // static diff --git a/base/file_util_proxy.h b/base/file_util_proxy.h index 32b78630..081c11b 100644 --- a/base/file_util_proxy.h +++ b/base/file_util_proxy.h @@ -138,7 +138,7 @@ class FileUtilProxy { // Writes to a file. If |offset| is greater than the length of the file, // |false| is returned. On success, the file pointer is moved to position - // |offset + bytes_to_write| in the file. The callback can be NULL. + // |offset + bytes_to_write| in the file. If The callback can be NULL. static bool Write( scoped_refptr<MessageLoopProxy> message_loop_proxy, base::PlatformFile file, @@ -169,16 +169,7 @@ class FileUtilProxy { static bool Truncate( scoped_refptr<MessageLoopProxy> message_loop_proxy, base::PlatformFile file, - int64 length, - 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. - static bool Truncate( - scoped_refptr<MessageLoopProxy> message_loop_proxy, - const FilePath& path, - int64 length, + long long length, StatusCallback* callback); // Flushes a file. The callback can be NULL. |