summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-17 20:56:52 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-17 20:56:52 +0000
commit4958f9fb8d57661a370ac4291a27b740daadbdd7 (patch)
tree3df922741e345b036b0e8390b9b78d58ca6ba41c /base
parente12ba91ddcd2cacb66f4c38216f1fac065968e5e (diff)
downloadchromium_src-4958f9fb8d57661a370ac4291a27b740daadbdd7.zip
chromium_src-4958f9fb8d57661a370ac4291a27b740daadbdd7.tar.gz
chromium_src-4958f9fb8d57661a370ac4291a27b740daadbdd7.tar.bz2
base::Bind: Convert FileUtilProxy::WriteCallback.
BUG=none TEST=none R=csilv@chromium.org Review URL: http://codereview.chromium.org/8321014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/file_util_proxy.cc17
-rw-r--r--base/file_util_proxy.h18
2 files changed, 16 insertions, 19 deletions
diff --git a/base/file_util_proxy.cc b/base/file_util_proxy.cc
index b1652c4..f0192d9 100644
--- a/base/file_util_proxy.cc
+++ b/base/file_util_proxy.cc
@@ -564,7 +564,7 @@ class RelayWrite : public MessageLoopRelay {
int64 offset,
const char* buffer,
int bytes_to_write,
- base::FileUtilProxy::WriteCallback* callback)
+ const base::FileUtilProxy::WriteCallback& callback)
: file_(file),
offset_(offset),
buffer_(new char[bytes_to_write]),
@@ -583,10 +583,8 @@ class RelayWrite : public MessageLoopRelay {
}
virtual void RunCallback() {
- if (callback_) {
- callback_->Run(error_code(), bytes_written_);
- delete callback_;
- }
+ if (!callback_.is_null())
+ callback_.Run(error_code(), bytes_written_);
}
private:
@@ -594,7 +592,7 @@ class RelayWrite : public MessageLoopRelay {
int64 offset_;
scoped_array<char> buffer_;
int bytes_to_write_;
- base::FileUtilProxy::WriteCallback* callback_;
+ base::FileUtilProxy::WriteCallback callback_;
int bytes_written_;
};
@@ -862,11 +860,10 @@ bool FileUtilProxy::Write(
int64 offset,
const char* buffer,
int bytes_to_write,
- WriteCallback* callback) {
- if (bytes_to_write <= 0) {
- delete callback;
+ const WriteCallback& callback) {
+ if (bytes_to_write <= 0)
return false;
- }
+
return Start(FROM_HERE, message_loop_proxy,
new RelayWrite(file, offset, buffer, bytes_to_write, callback));
}
diff --git a/base/file_util_proxy.h b/base/file_util_proxy.h
index d86f797..b89c01e 100644
--- a/base/file_util_proxy.h
+++ b/base/file_util_proxy.h
@@ -55,8 +55,8 @@ class BASE_EXPORT FileUtilProxy {
typedef base::Callback<void(PlatformFileError /* error code */,
const char* /* data */,
int /* bytes read/written */)> ReadCallback;
- typedef Callback2<PlatformFileError /* error code */,
- int /* bytes written */>::Type WriteCallback;
+ typedef base::Callback<void(PlatformFileError /* error code */,
+ int /* bytes written */)> WriteCallback;
// Creates or opens a file with the given flags. It is invalid to pass a null
// callback. If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to
@@ -169,7 +169,7 @@ class BASE_EXPORT 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. The callback can be null.
// |bytes_to_write| must be greater than zero.
static bool Write(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
@@ -177,9 +177,9 @@ class BASE_EXPORT FileUtilProxy {
int64 offset,
const char* buffer,
int bytes_to_write,
- WriteCallback* callback);
+ const WriteCallback& callback);
- // Touches a file. The callback can be NULL.
+ // Touches a file. The callback can be null.
static bool Touch(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
PlatformFile file,
@@ -187,7 +187,7 @@ class BASE_EXPORT FileUtilProxy {
const Time& last_modified_time,
StatusCallback* callback);
- // Touches a file. The callback can be NULL.
+ // Touches a file. The callback can be null.
static bool Touch(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
const FilePath& file_path,
@@ -197,7 +197,7 @@ class BASE_EXPORT FileUtilProxy {
// 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.
+ // The callback can be null.
static bool Truncate(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
PlatformFile file,
@@ -206,14 +206,14 @@ class BASE_EXPORT FileUtilProxy {
// 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.
+ // The callback can be null.
static bool Truncate(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
const FilePath& path,
int64 length,
StatusCallback* callback);
- // Flushes a file. The callback can be NULL.
+ // Flushes a file. The callback can be null.
static bool Flush(
scoped_refptr<MessageLoopProxy> message_loop_proxy,
PlatformFile file,