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

Unified Diff: webkit/tools/test_shell/simple_file_writer.cc

Issue 9016020: Cleanup FileSystemOperation for preparing for adding FSO-factory method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 8 years, 11 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: webkit/tools/test_shell/simple_file_writer.cc
diff --git a/webkit/tools/test_shell/simple_file_writer.cc b/webkit/tools/test_shell/simple_file_writer.cc
index dfa37baf298e564f74c4c2d8e4b283b3dde8d7eb..c548183e35b31c4862fb2c7db927c920b9dc63a9 100644
--- a/webkit/tools/test_shell/simple_file_writer.cc
+++ b/webkit/tools/test_shell/simple_file_writer.cc
@@ -80,14 +80,19 @@ class SimpleFileWriter::IOThreadProxy
DidFail(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
return;
}
- operation_->Cancel(GetNewOperation());
+ operation_->Cancel(CallbackDispatcher::Create(this));
}
private:
// Inner class to receive callbacks from FileSystemOperation.
class CallbackDispatcher : public FileSystemCallbackDispatcher {
public:
- explicit CallbackDispatcher(IOThreadProxy* proxy) : proxy_(proxy) {
+ // An instance of this class must be created by Create()
+ // (so that we do not leak ownerships).
+ static scoped_ptr<FileSystemCallbackDispatcher> Create(
+ IOThreadProxy* proxy) {
+ return scoped_ptr<FileSystemCallbackDispatcher>(
+ new CallbackDispatcher(proxy));
}
~CallbackDispatcher() {
@@ -124,12 +129,14 @@ class SimpleFileWriter::IOThreadProxy
NOTREACHED();
}
+ private:
+ explicit CallbackDispatcher(IOThreadProxy* proxy) : proxy_(proxy) {}
scoped_refptr<IOThreadProxy> proxy_;
};
FileSystemOperation* GetNewOperation() {
// The FileSystemOperation takes ownership of the CallbackDispatcher.
- return new FileSystemOperation(new CallbackDispatcher(this),
+ return new FileSystemOperation(CallbackDispatcher::Create(this),
io_thread_, file_system_context_.get());
}

Powered by Google App Engine
This is Rietveld 408576698