diff options
Diffstat (limited to 'webkit/fileapi')
-rw-r--r-- | webkit/fileapi/file_system_dir_url_request_job_unittest.cc | 13 | ||||
-rw-r--r-- | webkit/fileapi/file_system_mount_point_provider.h | 2 | ||||
-rw-r--r-- | webkit/fileapi/file_system_operation.cc | 4 | ||||
-rw-r--r-- | webkit/fileapi/file_system_operation.h | 1 | ||||
-rw-r--r-- | webkit/fileapi/file_system_path_manager.cc | 39 | ||||
-rw-r--r-- | webkit/fileapi/file_system_path_manager.h | 11 | ||||
-rw-r--r-- | webkit/fileapi/file_system_path_manager_unittest.cc | 14 | ||||
-rw-r--r-- | webkit/fileapi/file_system_url_request_job_unittest.cc | 11 | ||||
-rw-r--r-- | webkit/fileapi/sandbox_mount_point_provider.cc | 26 | ||||
-rw-r--r-- | webkit/fileapi/sandbox_mount_point_provider.h | 2 | ||||
-rw-r--r-- | webkit/fileapi/sandbox_mount_point_provider_unittest.cc | 18 |
11 files changed, 69 insertions, 72 deletions
diff --git a/webkit/fileapi/file_system_dir_url_request_job_unittest.cc b/webkit/fileapi/file_system_dir_url_request_job_unittest.cc index 4b70f25..fb52cd2 100644 --- a/webkit/fileapi/file_system_dir_url_request_job_unittest.cc +++ b/webkit/fileapi/file_system_dir_url_request_job_unittest.cc @@ -16,6 +16,7 @@ #include "base/file_path.h" #include "base/format_macros.h" +#include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "base/platform_file.h" #include "base/scoped_temp_dir.h" @@ -48,10 +49,10 @@ class FileSystemDirURLRequestJobTest : public testing::Test { protected: FileSystemDirURLRequestJobTest() : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread - ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { } - virtual void SetUp() { + virtual void SetUp() OVERRIDE { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); file_thread_proxy_ = base::MessageLoopProxy::current(); @@ -69,15 +70,15 @@ class FileSystemDirURLRequestJobTest : public testing::Test { file_system_context_->path_manager()->ValidateFileSystemRootAndGetURL( GURL("http://remote/"), kFileSystemTypeTemporary, true, // create - callback_factory_.NewCallback( - &FileSystemDirURLRequestJobTest::OnGetRootPath)); + base::Bind(&FileSystemDirURLRequestJobTest::OnGetRootPath, + weak_factory_.GetWeakPtr())); MessageLoop::current()->RunAllPending(); net::URLRequest::Deprecated::RegisterProtocolFactory( "filesystem", &FileSystemDirURLRequestJobFactory); } - virtual void TearDown() { + virtual void TearDown() OVERRIDE { // NOTE: order matters, request must die before delegate request_.reset(NULL); delegate_.reset(NULL); @@ -216,7 +217,7 @@ class FileSystemDirURLRequestJobTest : public testing::Test { scoped_ptr<TestDelegate> delegate_; scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; scoped_refptr<FileSystemContext> file_system_context_; - base::ScopedCallbackFactory<FileSystemDirURLRequestJobTest> callback_factory_; + base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_; static net::URLRequestJob* job_; }; diff --git a/webkit/fileapi/file_system_mount_point_provider.h b/webkit/fileapi/file_system_mount_point_provider.h index 55161c3..7cf2ce3 100644 --- a/webkit/fileapi/file_system_mount_point_provider.h +++ b/webkit/fileapi/file_system_mount_point_provider.h @@ -33,7 +33,7 @@ class FileSystemMountPointProvider { const GURL& origin_url, FileSystemType type, bool create, - FileSystemPathManager::GetRootPathCallback* callback) = 0; + const FileSystemPathManager::GetRootPathCallback& callback) = 0; // Like GetFileSystemRootPath, but synchronous, and can be called only while // running on the file thread. diff --git a/webkit/fileapi/file_system_operation.cc b/webkit/fileapi/file_system_operation.cc index 113517b..20584ab 100644 --- a/webkit/fileapi/file_system_operation.cc +++ b/webkit/fileapi/file_system_operation.cc @@ -65,7 +65,6 @@ FileSystemOperation::FileSystemOperation( : proxy_(proxy), dispatcher_(dispatcher), file_system_operation_context_(file_system_context, file_util), - ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { DCHECK(dispatcher); #ifndef NDEBUG @@ -99,7 +98,8 @@ void FileSystemOperation::OpenFileSystem( // return GetFileSystemRootURI() here. file_system_context()->path_manager()->ValidateFileSystemRootAndGetURL( origin_url, type, create, - callback_factory_.NewCallback(&FileSystemOperation::DidGetRootPath)); + base::Bind(&FileSystemOperation::DidGetRootPath, + weak_factory_.GetWeakPtr())); } void FileSystemOperation::CreateFile(const GURL& path, diff --git a/webkit/fileapi/file_system_operation.h b/webkit/fileapi/file_system_operation.h index 3fa1338..3cfa69f 100644 --- a/webkit/fileapi/file_system_operation.h +++ b/webkit/fileapi/file_system_operation.h @@ -241,7 +241,6 @@ class FileSystemOperation { FileSystemOperationContext file_system_operation_context_; - base::ScopedCallbackFactory<FileSystemOperation> callback_factory_; base::WeakPtrFactory<FileSystemOperation> weak_factory_; scoped_ptr<ScopedQuotaUtilHelper> quota_util_helper_; diff --git a/webkit/fileapi/file_system_path_manager.cc b/webkit/fileapi/file_system_path_manager.cc index 569c261..2690e7b 100644 --- a/webkit/fileapi/file_system_path_manager.cc +++ b/webkit/fileapi/file_system_path_manager.cc @@ -56,27 +56,26 @@ FileSystemPathManager::FileSystemPathManager( FileSystemPathManager::~FileSystemPathManager() {} void FileSystemPathManager::ValidateFileSystemRootAndGetURL( - const GURL& origin_url, fileapi::FileSystemType type, - bool create, GetRootPathCallback* callback_ptr) { - scoped_ptr<GetRootPathCallback> callback(callback_ptr); + const GURL& origin_url, fileapi::FileSystemType type, bool create, + const GetRootPathCallback& callback) { switch (type) { - case kFileSystemTypeTemporary: - case kFileSystemTypePersistent: - sandbox_provider_->ValidateFileSystemRootAndGetURL( - origin_url, type, create, callback.release()); - break; - case kFileSystemTypeExternal: - if (external_provider_.get()) { - external_provider_->ValidateFileSystemRootAndGetURL( - origin_url, type, create, callback.release()); - } else { - callback->Run(false, FilePath(), std::string()); - } - break; - case kFileSystemTypeUnknown: - default: - NOTREACHED(); - callback->Run(false, FilePath(), std::string()); + case kFileSystemTypeTemporary: + case kFileSystemTypePersistent: + sandbox_provider_->ValidateFileSystemRootAndGetURL( + origin_url, type, create, callback); + break; + case kFileSystemTypeExternal: + if (external_provider_.get()) { + external_provider_->ValidateFileSystemRootAndGetURL( + origin_url, type, create, callback); + } else { + callback.Run(false, FilePath(), std::string()); + } + break; + case kFileSystemTypeUnknown: + default: + NOTREACHED(); + callback.Run(false, FilePath(), std::string()); } } diff --git a/webkit/fileapi/file_system_path_manager.h b/webkit/fileapi/file_system_path_manager.h index 5c9600c..34aebac 100644 --- a/webkit/fileapi/file_system_path_manager.h +++ b/webkit/fileapi/file_system_path_manager.h @@ -6,7 +6,7 @@ #define WEBKIT_FILEAPI_FILE_SYSTEM_PATH_MANAGER_H_ #pragma once -#include "base/callback_old.h" +#include "base/callback.h" #include "base/file_path.h" #include "base/file_util.h" #include "webkit/fileapi/file_system_types.h" @@ -40,9 +40,10 @@ class FileSystemPathManager { // If the request is accepted, |create| is specified for // GetFileSystemRootPath, and the root directory does not exist, it creates // a new one and calls back with success=true if the creation has succeeded. - typedef Callback3<bool /* success */, - const FilePath& /* root_path */, - const std::string& /* name */>::Type GetRootPathCallback; + typedef base::Callback<void(bool /* success */, + const FilePath& /* root_path */, + const std::string& /* name */)> + GetRootPathCallback; // Retrieves the root path for the given |origin_url| and |type|, and // calls the given |callback| with the root path and name. @@ -51,7 +52,7 @@ class FileSystemPathManager { const GURL& origin_url, FileSystemType type, bool create, - FileSystemPathManager::GetRootPathCallback* callback); + const FileSystemPathManager::GetRootPathCallback& callback); // Like GetFileSystemRootPath, but synchronous, and can be called only while // running on the file thread. diff --git a/webkit/fileapi/file_system_path_manager_unittest.cc b/webkit/fileapi/file_system_path_manager_unittest.cc index afa157b..f99824d 100644 --- a/webkit/fileapi/file_system_path_manager_unittest.cc +++ b/webkit/fileapi/file_system_path_manager_unittest.cc @@ -8,10 +8,11 @@ #include <string> #include "base/basictypes.h" +#include "base/bind.h" #include "base/file_util.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_callback_factory.h" #include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "base/message_loop_proxy.h" #include "base/scoped_temp_dir.h" @@ -210,7 +211,7 @@ FilePath UTF8ToFilePath(const std::string& str) { class FileSystemPathManagerTest : public testing::Test { public: FileSystemPathManagerTest() - : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { + : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { } void SetUp() { @@ -252,9 +253,10 @@ class FileSystemPathManagerTest : public testing::Test { fileapi::FileSystemType type, bool create, FilePath* root_path) { - manager->ValidateFileSystemRootAndGetURL(origin_url, type, create, - callback_factory_.NewCallback( - &FileSystemPathManagerTest::OnGetRootPath)); + manager->ValidateFileSystemRootAndGetURL( + origin_url, type, create, + base::Bind(&FileSystemPathManagerTest::OnGetRootPath, + weak_factory_.GetWeakPtr())); MessageLoop::current()->RunAllPending(); if (root_path) *root_path = root_path_; @@ -275,7 +277,7 @@ class FileSystemPathManagerTest : public testing::Test { private: ScopedTempDir data_dir_; - base::ScopedCallbackFactory<FileSystemPathManagerTest> callback_factory_; + base::WeakPtrFactory<FileSystemPathManagerTest> weak_factory_; bool root_path_callback_status_; FilePath root_path_; diff --git a/webkit/fileapi/file_system_url_request_job_unittest.cc b/webkit/fileapi/file_system_url_request_job_unittest.cc index 33e0e7c..bd0ada8 100644 --- a/webkit/fileapi/file_system_url_request_job_unittest.cc +++ b/webkit/fileapi/file_system_url_request_job_unittest.cc @@ -14,10 +14,11 @@ #include <string> +#include "base/bind.h" #include "base/file_path.h" #include "base/file_util.h" #include "base/format_macros.h" -#include "base/memory/scoped_callback_factory.h" +#include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "base/message_loop_proxy.h" #include "base/platform_file.h" @@ -68,7 +69,7 @@ class FileSystemURLRequestJobTest : public testing::Test { protected: FileSystemURLRequestJobTest() : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread - ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { } virtual void SetUp() { @@ -89,8 +90,8 @@ class FileSystemURLRequestJobTest : public testing::Test { file_system_context_->path_manager()->ValidateFileSystemRootAndGetURL( GURL("http://remote/"), kFileSystemTypeTemporary, true, // create - callback_factory_.NewCallback( - &FileSystemURLRequestJobTest::OnGetRootPath)); + base::Bind(&FileSystemURLRequestJobTest::OnGetRootPath, + weak_factory_.GetWeakPtr())); MessageLoop::current()->RunAllPending(); net::URLRequest::Deprecated::RegisterProtocolFactory( @@ -202,7 +203,7 @@ class FileSystemURLRequestJobTest : public testing::Test { FilePath origin_root_path_; scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_; scoped_refptr<FileSystemContext> file_system_context_; - base::ScopedCallbackFactory<FileSystemURLRequestJobTest> callback_factory_; + base::WeakPtrFactory<FileSystemURLRequestJobTest> weak_factory_; // NOTE: order matters, request must die before delegate scoped_ptr<TestDelegate> delegate_; diff --git a/webkit/fileapi/sandbox_mount_point_provider.cc b/webkit/fileapi/sandbox_mount_point_provider.cc index 8feb2ff..7bc8dba 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.cc +++ b/webkit/fileapi/sandbox_mount_point_provider.cc @@ -306,7 +306,7 @@ class SandboxMountPointProvider::GetFileSystemRootPathTask FileSystemType type, ObfuscatedFileUtil* file_util, const FilePath& old_base_path, - FileSystemPathManager::GetRootPathCallback* callback) + const FileSystemPathManager::GetRootPathCallback& callback) : file_message_loop_(file_message_loop), origin_message_loop_proxy_( base::MessageLoopProxy::current()), @@ -350,8 +350,8 @@ class SandboxMountPointProvider::GetFileSystemRootPathTask FileSystemPathManager::GetFileSystemTypeString(type_); DCHECK(!type_string.empty()); std::string name = origin_identifier + ":" + type_string; - callback_->Run(!root_path.empty(), root_path, name); - callback_.reset(); + callback_.Run(!root_path.empty(), root_path, name); + callback_.Reset(); } scoped_refptr<base::MessageLoopProxy> file_message_loop_; @@ -360,7 +360,7 @@ class SandboxMountPointProvider::GetFileSystemRootPathTask FileSystemType type_; scoped_refptr<ObfuscatedFileUtil> file_util_; FilePath old_base_path_; - scoped_ptr<FileSystemPathManager::GetRootPathCallback> callback_; + FileSystemPathManager::GetRootPathCallback callback_; }; FilePath SandboxMountPointProvider::old_base_path() const { @@ -413,29 +413,25 @@ SandboxMountPointProvider::CreateOriginEnumerator() const { } void SandboxMountPointProvider::ValidateFileSystemRootAndGetURL( - const GURL& origin_url, fileapi::FileSystemType type, - bool create, FileSystemPathManager::GetRootPathCallback* callback_ptr) { - scoped_ptr<FileSystemPathManager::GetRootPathCallback> callback(callback_ptr); + const GURL& origin_url, fileapi::FileSystemType type, bool create, + const FileSystemPathManager::GetRootPathCallback& callback) { FilePath origin_base_path; if (path_manager_->is_incognito()) { // TODO(kinuko): return an isolated temporary directory. - callback->Run(false, FilePath(), std::string()); + callback.Run(false, FilePath(), std::string()); return; } if (!path_manager_->IsAllowedScheme(origin_url)) { - callback->Run(false, FilePath(), std::string()); + callback.Run(false, FilePath(), std::string()); return; } scoped_refptr<GetFileSystemRootPathTask> task( - new GetFileSystemRootPathTask(file_message_loop_, - origin_url, - type, - sandbox_file_util_.get(), - old_base_path(), - callback.release())); + new GetFileSystemRootPathTask( + file_message_loop_, origin_url, type, sandbox_file_util_.get(), + old_base_path(), callback)); task->Start(create); }; diff --git a/webkit/fileapi/sandbox_mount_point_provider.h b/webkit/fileapi/sandbox_mount_point_provider.h index b6cab5b..9696287 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.h +++ b/webkit/fileapi/sandbox_mount_point_provider.h @@ -66,7 +66,7 @@ class SandboxMountPointProvider const GURL& origin_url, FileSystemType type, bool create, - FileSystemPathManager::GetRootPathCallback* callback); + const FileSystemPathManager::GetRootPathCallback& callback); // Like GetFileSystemRootPath, but synchronous, and can be called only while // running on the file thread. diff --git a/webkit/fileapi/sandbox_mount_point_provider_unittest.cc b/webkit/fileapi/sandbox_mount_point_provider_unittest.cc index 77f9d24..60ad07e 100644 --- a/webkit/fileapi/sandbox_mount_point_provider_unittest.cc +++ b/webkit/fileapi/sandbox_mount_point_provider_unittest.cc @@ -8,10 +8,11 @@ #include <string> #include "base/basictypes.h" +#include "base/bind.h" #include "base/file_util.h" #include "base/memory/ref_counted.h" -#include "base/memory/scoped_callback_factory.h" #include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "base/message_loop_proxy.h" #include "base/platform_file.h" @@ -133,7 +134,7 @@ const MigrationTestCaseRecord kMigrationTestRecords[] = { class SandboxMountPointProviderMigrationTest : public testing::Test { public: SandboxMountPointProviderMigrationTest() : - ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { } void SetUp() { @@ -171,9 +172,9 @@ class SandboxMountPointProviderMigrationTest : public testing::Test { EXPECT_FALSE(success); // We told it not to create. } - FileSystemPathManager::GetRootPathCallback* GetRootPathCallback() { - return callback_factory_.NewCallback( - &SandboxMountPointProviderMigrationTest::OnGetRootPath); + FileSystemPathManager::GetRootPathCallback GetRootPathCallback() { + return base::Bind(&SandboxMountPointProviderMigrationTest::OnGetRootPath, + weak_factory_.GetWeakPtr()); } void EnsureFileExists(const FilePath& path) { @@ -286,16 +287,14 @@ class SandboxMountPointProviderMigrationTest : public testing::Test { std::set<GURL> origins; std::string host = "the host with the most"; int64 delta = 0; - scoped_ptr<FileSystemPathManager::GetRootPathCallback> callback; // We want to make sure that all the public methods of // SandboxMountPointProvider which might access the filesystem will cause a // migration if one is needed. switch (method) { case 0: - callback.reset(GetRootPathCallback()); sandbox_provider()->ValidateFileSystemRootAndGetURL( - origin_url, type, create, callback.release()); + origin_url, type, create, GetRootPathCallback()); MessageLoop::current()->RunAllPending(); break; case 1: @@ -360,8 +359,7 @@ class SandboxMountPointProviderMigrationTest : public testing::Test { ScopedTempDir data_dir_; FileSystemPathManager* path_manager_; scoped_refptr<FileSystemContext> file_system_context_; - base::ScopedCallbackFactory<SandboxMountPointProviderMigrationTest> - callback_factory_; + base::WeakPtrFactory<SandboxMountPointProviderMigrationTest> weak_factory_; }; TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod0) { |