diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-11 10:26:10 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-11 10:26:10 +0000 |
commit | 60f60f854736bd82e9e8d5967ec160df38fcd660 (patch) | |
tree | 41fdbe702084398954904afe6993be40c8c4e909 /webkit/tools | |
parent | 9569b218572ab58deb22546cde49d2bd8ea20c48 (diff) | |
download | chromium_src-60f60f854736bd82e9e8d5967ec160df38fcd660.zip chromium_src-60f60f854736bd82e9e8d5967ec160df38fcd660.tar.gz chromium_src-60f60f854736bd82e9e8d5967ec160df38fcd660.tar.bz2 |
Cleanup FileSystemOperation for preparing for adding FSO-factory method
1. Move OpenFileSystem() to FileSystemContext
2. Change Cancel() not to take another FileSystemOperation
These two changes are made so that all the operations that require FileSystemOperation take target path URL.
3. Did some related code cleanups in FileSystemMountPointProvider:
- Renamed ValidateFileSystemRootAndGetURL() to ValidateFileSystemRoot() as we no longer need to return RootURL
- Renamed ValidateFileSystemRootAndGetPathOnFileThread() to GetFileSystemRootPathOnFileThread() for the sake of simplicity
- Reimplemented SandboxMPP::GetRootPathTask using PostTaskAndReply
Patch from http://codereview.chromium.org/9004019/
BUG=none
TEST=existing tests should pass
Review URL: http://codereview.chromium.org/9016020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117197 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools')
-rw-r--r-- | webkit/tools/test_shell/simple_file_system.cc | 26 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_file_writer.cc | 15 |
2 files changed, 29 insertions, 12 deletions
diff --git a/webkit/tools/test_shell/simple_file_system.cc b/webkit/tools/test_shell/simple_file_system.cc index c6982eb..8eb34fb 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; } diff --git a/webkit/tools/test_shell/simple_file_writer.cc b/webkit/tools/test_shell/simple_file_writer.cc index dfa37ba..169106b 100644 --- a/webkit/tools/test_shell/simple_file_writer.cc +++ b/webkit/tools/test_shell/simple_file_writer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -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()); } |