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

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

Issue 9016020: Cleanup FileSystemOperation for preparing for adding FSO-factory method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 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_system.cc
diff --git a/webkit/tools/test_shell/simple_file_system.cc b/webkit/tools/test_shell/simple_file_system.cc
index c6982eb5a34c80cda5cd1eb45f14899d4418037f..8eb34fba04158dbeabb2799ea07f9104cec6cded 100644
--- a/webkit/tools/test_shell/simple_file_system.cc
+++ b/webkit/tools/test_shell/simple_file_system.cc
@@ -49,11 +49,13 @@ namespace {
class SimpleFileSystemCallbackDispatcher
: public FileSystemCallbackDispatcher {
public:
- SimpleFileSystemCallbackDispatcher(
+ // An instance of this class must be created by Create()
+ // (so that we do not leak ownerships).
+ static scoped_ptr<FileSystemCallbackDispatcher> Create(
const WeakPtr<SimpleFileSystem>& file_system,
- WebFileSystemCallbacks* callbacks)
- : file_system_(file_system),
- callbacks_(callbacks) {
+ WebFileSystemCallbacks* callbacks) {
+ return scoped_ptr<FileSystemCallbackDispatcher>(
+ new SimpleFileSystemCallbackDispatcher(file_system, callbacks));
}
~SimpleFileSystemCallbackDispatcher() {
@@ -114,6 +116,13 @@ class SimpleFileSystemCallbackDispatcher
}
private:
+ SimpleFileSystemCallbackDispatcher(
+ const WeakPtr<SimpleFileSystem>& file_system,
+ WebFileSystemCallbacks* callbacks)
+ : file_system_(file_system),
+ callbacks_(callbacks) {
+ }
+
WeakPtr<SimpleFileSystem> file_system_;
WebFileSystemCallbacks* callbacks_;
};
@@ -162,7 +171,9 @@ void SimpleFileSystem::OpenFileSystem(
}
GURL origin_url(frame->document().securityOrigin().toString());
- GetNewOperation(callbacks)->OpenFileSystem(origin_url, type, create);
+ file_system_context_->OpenFileSystem(
+ origin_url, type, create,
+ SimpleFileSystemCallbackDispatcher::Create(AsWeakPtr(), callbacks));
}
void SimpleFileSystem::move(
@@ -224,10 +235,9 @@ WebFileWriter* SimpleFileSystem::createFileWriter(
FileSystemOperation* SimpleFileSystem::GetNewOperation(
WebFileSystemCallbacks* callbacks) {
- SimpleFileSystemCallbackDispatcher* dispatcher =
- new SimpleFileSystemCallbackDispatcher(AsWeakPtr(), callbacks);
FileSystemOperation* operation = new FileSystemOperation(
- dispatcher, base::MessageLoopProxy::current(),
+ SimpleFileSystemCallbackDispatcher::Create(AsWeakPtr(), callbacks),
+ base::MessageLoopProxy::current(),
file_system_context_.get());
return operation;
}
« no previous file with comments | « webkit/fileapi/sandbox_mount_point_provider_unittest.cc ('k') | webkit/tools/test_shell/simple_file_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698