Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3986)

Unified Diff: base/file_util_proxy.cc

Issue 8321014: base::Bind: Convert FileUtilProxy::WriteCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fixes. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_util_proxy.h ('k') | content/common/net/url_fetcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_proxy.cc
diff --git a/base/file_util_proxy.cc b/base/file_util_proxy.cc
index b1652c4f3a96f29e98a1a28ee68c7a98306e2b6f..f0192d934465a24b28803a665cc5d3799d401b04 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));
}
« no previous file with comments | « base/file_util_proxy.h ('k') | content/common/net/url_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698