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

Unified Diff: base/file_util_proxy.cc

Issue 8294015: base::Bind: Convert FileUtilProxy::ReadCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. 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
Index: base/file_util_proxy.cc
diff --git a/base/file_util_proxy.cc b/base/file_util_proxy.cc
index 771a5bea3e8fbfdec79cd5aad67cfe08b8a953a5..b1652c4f3a96f29e98a1a28ee68c7a98306e2b6f 100644
--- a/base/file_util_proxy.cc
+++ b/base/file_util_proxy.cc
@@ -527,7 +527,7 @@ class RelayRead : public MessageLoopRelay {
RelayRead(base::PlatformFile file,
int64 offset,
int bytes_to_read,
- base::FileUtilProxy::ReadCallback* callback)
+ const base::FileUtilProxy::ReadCallback& callback)
: file_(file),
offset_(offset),
buffer_(new char[bytes_to_read]),
@@ -545,10 +545,8 @@ class RelayRead : public MessageLoopRelay {
}
virtual void RunCallback() {
- if (callback_) {
- callback_->Run(error_code(), buffer_.get(), bytes_read_);
- delete callback_;
- }
+ if (!callback_.is_null())
+ callback_.Run(error_code(), buffer_.get(), bytes_read_);
}
private:
@@ -556,7 +554,7 @@ class RelayRead : public MessageLoopRelay {
int64 offset_;
scoped_array<char> buffer_;
int bytes_to_read_;
- base::FileUtilProxy::ReadCallback* callback_;
+ base::FileUtilProxy::ReadCallback callback_;
int bytes_read_;
};
@@ -849,11 +847,10 @@ bool FileUtilProxy::Read(
PlatformFile file,
int64 offset,
int bytes_to_read,
- ReadCallback* callback) {
- if (bytes_to_read < 0) {
- delete callback;
+ const ReadCallback& callback) {
+ if (bytes_to_read < 0)
return false;
- }
+
return Start(FROM_HERE, message_loop_proxy,
new RelayRead(file, offset, bytes_to_read, callback));
}

Powered by Google App Engine
This is Rietveld 408576698