diff options
49 files changed, 252 insertions, 322 deletions
diff --git a/content/browser/fileapi/fileapi_message_filter.cc b/content/browser/fileapi/fileapi_message_filter.cc index 3ce1d18..9449866 100644 --- a/content/browser/fileapi/fileapi_message_filter.cc +++ b/content/browser/fileapi/fileapi_message_filter.cc @@ -432,10 +432,7 @@ void FileAPIMessageFilter::OnSyncGetPlatformPath( // TODO(kinuko): this hack should go away once appropriate upload-stream // handling based on element types is supported. FileSystemOperation* operation = - context_->CreateFileSystemOperation( - path, - BrowserThread::GetMessageLoopProxyForThread( - BrowserThread::FILE))->AsFileSystemOperation(); + context_->CreateFileSystemOperation(path)->AsFileSystemOperation(); DCHECK(operation); operation->SyncGetPlatformPath(path, platform_path); } @@ -670,9 +667,7 @@ FileSystemOperationInterface* FileAPIMessageFilter::GetNewOperation( const GURL& target_path, int request_id) { FileSystemOperationInterface* operation = - context_->CreateFileSystemOperation( - target_path, - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); + context_->CreateFileSystemOperation(target_path); DCHECK(operation); operations_.AddWithID(operation, request_id); return operation; diff --git a/content/browser/resource_context_impl.cc b/content/browser/resource_context_impl.cc index db1baeb..dc90129 100644 --- a/content/browser/resource_context_impl.cc +++ b/content/browser/resource_context_impl.cc @@ -162,8 +162,7 @@ void InitializeRequestContext( set_protocol = job_factory->SetProtocolHandler( chrome::kFileSystemScheme, CreateFileSystemProtocolHandler( - GetFileSystemContextForResourceContext(resource_context), - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); + GetFileSystemContextForResourceContext(resource_context))); DCHECK(set_protocol); job_factory->AddInterceptor(new DeveloperProtocolHandler( diff --git a/webkit/blob/local_file_reader.cc b/webkit/blob/local_file_reader.cc index 8b5fb05..7de2686 100644 --- a/webkit/blob/local_file_reader.cc +++ b/webkit/blob/local_file_reader.cc @@ -8,8 +8,8 @@ #include "base/file_util_proxy.h" #include "base/location.h" #include "base/logging.h" -#include "base/message_loop_proxy.h" #include "base/platform_file.h" +#include "base/task_runner.h" #include "net/base/file_stream.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" @@ -48,11 +48,11 @@ int LocalFileReader::PlatformFileErrorToNetError( } LocalFileReader::LocalFileReader( - base::MessageLoopProxy* file_thread_proxy, + base::TaskRunner* task_runner, const FilePath& file_path, int64 initial_offset, const base::Time& expected_modification_time) - : file_thread_proxy_(file_thread_proxy), + : task_runner_(task_runner), file_path_(file_path), initial_offset_(initial_offset), expected_modification_time_(expected_modification_time), @@ -74,7 +74,7 @@ int LocalFileReader::Read(net::IOBuffer* buf, int buf_len, int LocalFileReader::GetLength(const net::Int64CompletionCallback& callback) { const bool posted = base::FileUtilProxy::GetFileInfo( - file_thread_proxy_, file_path_, + task_runner_, file_path_, base::Bind(&LocalFileReader::DidGetFileInfoForGetLength, weak_factory_.GetWeakPtr(), callback)); DCHECK(posted); diff --git a/webkit/blob/local_file_reader.h b/webkit/blob/local_file_reader.h index 8f0508d..2bacedf 100644 --- a/webkit/blob/local_file_reader.h +++ b/webkit/blob/local_file_reader.h @@ -16,7 +16,7 @@ #include "webkit/blob/file_reader.h" namespace base { -class MessageLoopProxy; +class TaskRunner; } namespace webkit_blob { @@ -38,8 +38,7 @@ class BLOB_EXPORT LocalFileReader : public FileReader { // actual modification time to see if the file has been modified, and if // it does any succeeding read operations should fail with // ERR_UPLOAD_FILE_CHANGED error. - // TODO(kinuko): Consider using SequencedWorkerPool. - LocalFileReader(base::MessageLoopProxy* file_thread_proxy, + LocalFileReader(base::TaskRunner* task_runner, const FilePath& file_path, int64 initial_offset, const base::Time& expected_modification_time); @@ -76,7 +75,7 @@ class BLOB_EXPORT LocalFileReader : public FileReader { base::PlatformFileError error, const base::PlatformFileInfo& file_info); - scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; + scoped_refptr<base::TaskRunner> task_runner_; scoped_ptr<net::FileStream> stream_impl_; const FilePath file_path_; const int64 initial_offset_; diff --git a/webkit/chromeos/fileapi/cros_mount_point_provider.cc b/webkit/chromeos/fileapi/cros_mount_point_provider.cc index e73516f..118ffa8 100644 --- a/webkit/chromeos/fileapi/cros_mount_point_provider.cc +++ b/webkit/chromeos/fileapi/cros_mount_point_provider.cc @@ -8,7 +8,6 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" -#include "base/message_loop_proxy.h" #include "base/stringprintf.h" #include "base/synchronization/lock.h" #include "base/utf_string_conversions.h" @@ -244,24 +243,22 @@ CrosMountPointProvider::CreateFileSystemOperation( const GURL& origin_url, fileapi::FileSystemType file_system_type, const FilePath& virtual_path, - base::MessageLoopProxy* file_proxy, fileapi::FileSystemContext* context) const { const MountPoint* mount_point = GetMountPoint(virtual_path); if (mount_point && mount_point->location == REMOTE) return new chromeos::RemoteFileSystemOperation(mount_point->remote_proxy); - return new fileapi::FileSystemOperation(file_proxy, context); + return new fileapi::FileSystemOperation(context); } webkit_blob::FileReader* CrosMountPointProvider::CreateFileReader( const GURL& url, int64 offset, - base::MessageLoopProxy* file_proxy, fileapi::FileSystemContext* context) const { // For now we return a generic Reader implementation which utilizes // CreateSnapshotFile internally (i.e. will download everything first). // TODO(satorux,zel): implement more efficient reader for remote cases. - return new fileapi::FileSystemFileReader(file_proxy, context, url, offset); + return new fileapi::FileSystemFileReader(context, url, offset); } bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, diff --git a/webkit/chromeos/fileapi/cros_mount_point_provider.h b/webkit/chromeos/fileapi/cros_mount_point_provider.h index 1e58939..5f3e421 100644 --- a/webkit/chromeos/fileapi/cros_mount_point_provider.h +++ b/webkit/chromeos/fileapi/cros_mount_point_provider.h @@ -67,12 +67,10 @@ class CrosMountPointProvider const GURL& origin_url, fileapi::FileSystemType file_system_type, const FilePath& virtual_path, - base::MessageLoopProxy* file_proxy, fileapi::FileSystemContext* context) const OVERRIDE; virtual webkit_blob::FileReader* CreateFileReader( const GURL& path, int64 offset, - base::MessageLoopProxy* file_proxy, fileapi::FileSystemContext* context) const OVERRIDE; // fileapi::ExternalFileSystemMountPointProvider overrides. diff --git a/webkit/database/database_quota_client.cc b/webkit/database/database_quota_client.cc index 4d963be..4d2835d 100644 --- a/webkit/database/database_quota_client.cc +++ b/webkit/database/database_quota_client.cc @@ -192,7 +192,7 @@ class DatabaseQuotaClient::DeleteOriginTask : public HelperTask { void OnCompletionCallback(int rv) { if (rv == net::OK) result_ = quota::kQuotaStatusOk; - original_message_loop()->PostTask( + original_task_runner()->PostTask( FROM_HERE, base::Bind(&DeleteOriginTask::CallCompleted, this)); Release(); // balanced in RunOnTargetThreadAsync } diff --git a/webkit/fileapi/file_system_context.cc b/webkit/fileapi/file_system_context.cc index f0c596e..a01e2f8 100644 --- a/webkit/fileapi/file_system_context.cc +++ b/webkit/fileapi/file_system_context.cc @@ -6,7 +6,7 @@ #include "base/bind.h" #include "base/file_util.h" -#include "base/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "googleurl/src/gurl.h" #include "webkit/fileapi/file_system_file_util.h" #include "webkit/fileapi/file_system_operation_interface.h" @@ -29,10 +29,9 @@ namespace fileapi { namespace { QuotaClient* CreateQuotaClient( - scoped_refptr<base::MessageLoopProxy> file_message_loop, FileSystemContext* context, bool is_incognito) { - return new FileSystemQuotaClient(file_message_loop, context, is_incognito); + return new FileSystemQuotaClient(context, is_incognito); } void DidOpenFileSystem(FileSystemContext::OpenFileSystemCallback callback, @@ -45,24 +44,24 @@ void DidOpenFileSystem(FileSystemContext::OpenFileSystemCallback callback, } // anonymous namespace FileSystemContext::FileSystemContext( - scoped_refptr<base::MessageLoopProxy> file_message_loop, - scoped_refptr<base::MessageLoopProxy> io_message_loop, - scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, + base::SequencedTaskRunner* file_task_runner, + base::SingleThreadTaskRunner* io_task_runner, + quota::SpecialStoragePolicy* special_storage_policy, quota::QuotaManagerProxy* quota_manager_proxy, const FilePath& profile_path, const FileSystemOptions& options) - : file_message_loop_(file_message_loop), - io_message_loop_(io_message_loop), + : file_task_runner_(file_task_runner), + io_task_runner_(io_task_runner), quota_manager_proxy_(quota_manager_proxy), sandbox_provider_( new SandboxMountPointProvider( - file_message_loop, + file_task_runner, profile_path, options)), isolated_provider_(new IsolatedMountPointProvider) { if (quota_manager_proxy) { quota_manager_proxy->RegisterClient(CreateQuotaClient( - file_message_loop, this, options.is_incognito())); + this, options.is_incognito())); } #if defined(OS_CHROMEOS) external_provider_.reset( @@ -72,7 +71,7 @@ FileSystemContext::FileSystemContext( bool FileSystemContext::DeleteDataForOriginOnFileThread( const GURL& origin_url) { - DCHECK(file_message_loop_->BelongsToCurrentThread()); + DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); DCHECK(sandbox_provider()); // Delete temporary and persistent data. @@ -85,7 +84,7 @@ bool FileSystemContext::DeleteDataForOriginOnFileThread( bool FileSystemContext::DeleteDataForOriginAndTypeOnFileThread( const GURL& origin_url, FileSystemType type) { - DCHECK(file_message_loop_->BelongsToCurrentThread()); + DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); if (type == fileapi::kFileSystemTypeTemporary || type == fileapi::kFileSystemTypePersistent) { DCHECK(sandbox_provider()); @@ -164,8 +163,7 @@ void FileSystemContext::OpenFileSystem( } FileSystemOperationInterface* FileSystemContext::CreateFileSystemOperation( - const GURL& url, - base::MessageLoopProxy* file_proxy) { + const GURL& url) { GURL origin_url; FileSystemType file_system_type = kFileSystemTypeUnknown; FilePath file_path; @@ -176,13 +174,12 @@ FileSystemOperationInterface* FileSystemContext::CreateFileSystemOperation( if (!mount_point_provider) return NULL; return mount_point_provider->CreateFileSystemOperation( - origin_url, file_system_type, file_path, file_proxy, this); + origin_url, file_system_type, file_path, this); } webkit_blob::FileReader* FileSystemContext::CreateFileReader( const GURL& url, - int64 offset, - base::MessageLoopProxy* file_proxy) { + int64 offset) { GURL origin_url; FileSystemType file_system_type = kFileSystemTypeUnknown; FilePath file_path; @@ -192,14 +189,14 @@ webkit_blob::FileReader* FileSystemContext::CreateFileReader( GetMountPointProvider(file_system_type); if (!mount_point_provider) return NULL; - return mount_point_provider->CreateFileReader(url, offset, file_proxy, this); + return mount_point_provider->CreateFileReader(url, offset, this); } FileSystemContext::~FileSystemContext() {} void FileSystemContext::DeleteOnCorrectThread() const { - if (!io_message_loop_->BelongsToCurrentThread() && - io_message_loop_->DeleteSoon(FROM_HERE, this)) { + if (!io_task_runner_->RunsTasksOnCurrentThread() && + io_task_runner_->DeleteSoon(FROM_HERE, this)) { return; } delete this; diff --git a/webkit/fileapi/file_system_context.h b/webkit/fileapi/file_system_context.h index 6c43037..472bf8a 100644 --- a/webkit/fileapi/file_system_context.h +++ b/webkit/fileapi/file_system_context.h @@ -19,7 +19,8 @@ class FilePath; class GURL; namespace base { -class MessageLoopProxy; +class SequencedTaskRunner; +class SingleThreadTaskRunner; } namespace quota { @@ -50,15 +51,19 @@ class FileSystemContext : public base::RefCountedThreadSafe<FileSystemContext, DefaultContextDeleter> { public: + // |file_task_runner| is used for all file operations and file related + // meta operations. + // The code assumes that file_task_runner->RunsTasksOnCurrentThread() returns + // false if the current task is not running on the thread that allows + // blocking file operations (like SequencedWorkerPool implementation does). FileSystemContext( - scoped_refptr<base::MessageLoopProxy> file_message_loop, - scoped_refptr<base::MessageLoopProxy> io_message_loop, - scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, + base::SequencedTaskRunner* file_task_runner, + base::SingleThreadTaskRunner* io_task_runner, + quota::SpecialStoragePolicy* special_storage_policy, quota::QuotaManagerProxy* quota_manager_proxy, const FilePath& profile_path, const FileSystemOptions& options); - // This method can be called on any thread. bool DeleteDataForOriginOnFileThread(const GURL& origin_url); bool DeleteDataForOriginAndTypeOnFileThread(const GURL& origin_url, FileSystemType type); @@ -67,6 +72,10 @@ class FileSystemContext return quota_manager_proxy_.get(); } + base::SequencedTaskRunner* file_task_runner() const { + return file_task_runner_.get(); + } + // Returns a quota util for a given filesystem type. This may // return NULL if the type does not support the usage tracking or // it is not a quota-managed storage. @@ -114,9 +123,7 @@ class FileSystemContext // and calling the provider's corresponding CreateFileSystemOperation method. // The resolved MountPointProvider could perform further specialization // depending on the filesystem type pointed by the |url|. - FileSystemOperationInterface* CreateFileSystemOperation( - const GURL& url, - base::MessageLoopProxy* file_proxy); + FileSystemOperationInterface* CreateFileSystemOperation(const GURL& url); // Creates new FileReader instance to read a file pointed by the given // filesystem URL |url| starting from |offset|. @@ -126,8 +133,7 @@ class FileSystemContext // depending on the filesystem type pointed by the |url|. webkit_blob::FileReader* CreateFileReader( const GURL& url, - int64 offset, - base::MessageLoopProxy* file_proxy); + int64 offset); private: friend struct DefaultContextDeleter; @@ -136,8 +142,8 @@ class FileSystemContext void DeleteOnCorrectThread() const; - scoped_refptr<base::MessageLoopProxy> file_message_loop_; - scoped_refptr<base::MessageLoopProxy> io_message_loop_; + scoped_refptr<base::SequencedTaskRunner> file_task_runner_; + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; diff --git a/webkit/fileapi/file_system_dir_url_request_job.cc b/webkit/fileapi/file_system_dir_url_request_job.cc index af0a934..b5b3cde 100644 --- a/webkit/fileapi/file_system_dir_url_request_job.cc +++ b/webkit/fileapi/file_system_dir_url_request_job.cc @@ -39,11 +39,9 @@ static FilePath GetRelativePath(const GURL& url) { } FileSystemDirURLRequestJob::FileSystemDirURLRequestJob( - URLRequest* request, FileSystemContext* file_system_context, - scoped_refptr<base::MessageLoopProxy> file_thread_proxy) + URLRequest* request, FileSystemContext* file_system_context) : URLRequestJob(request), file_system_context_(file_system_context), - file_thread_proxy_(file_thread_proxy), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { } @@ -141,9 +139,7 @@ void FileSystemDirURLRequestJob::DidReadDirectory( FileSystemOperationInterface* FileSystemDirURLRequestJob::GetNewOperation(const GURL& url) { - return file_system_context_->CreateFileSystemOperation( - url, - file_thread_proxy_); + return file_system_context_->CreateFileSystemOperation(url); } } // namespace fileapi diff --git a/webkit/fileapi/file_system_dir_url_request_job.h b/webkit/fileapi/file_system_dir_url_request_job.h index fd95130..4ced831 100644 --- a/webkit/fileapi/file_system_dir_url_request_job.h +++ b/webkit/fileapi/file_system_dir_url_request_job.h @@ -25,8 +25,7 @@ class FileSystemDirURLRequestJob : public net::URLRequestJob { public: FileSystemDirURLRequestJob( net::URLRequest* request, - FileSystemContext* file_system_context, - scoped_refptr<base::MessageLoopProxy> file_thread_proxy); + FileSystemContext* file_system_context); // URLRequestJob methods: virtual void Start() OVERRIDE; @@ -54,7 +53,6 @@ class FileSystemDirURLRequestJob : public net::URLRequestJob { std::string data_; FileSystemContext* file_system_context_; - scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; base::WeakPtrFactory<FileSystemDirURLRequestJob> weak_factory_; DISALLOW_COPY_AND_ASSIGN(FileSystemDirURLRequestJob); 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 8c04d0e..52b96cb 100644 --- a/webkit/fileapi/file_system_dir_url_request_job_unittest.cc +++ b/webkit/fileapi/file_system_dir_url_request_job_unittest.cc @@ -93,8 +93,7 @@ class FileSystemDirURLRequestJobTest : public testing::Test { delegate_->set_quit_on_redirect(true); request_.reset(new net::URLRequest(url, delegate_.get())); job_ = new FileSystemDirURLRequestJob(request_.get(), - file_system_context_.get(), - file_thread_proxy_); + file_system_context_.get()); request_->Start(); ASSERT_TRUE(request_->is_pending()); // verify that we're starting async diff --git a/webkit/fileapi/file_system_file_reader.cc b/webkit/fileapi/file_system_file_reader.cc index c15a607..58f269a 100644 --- a/webkit/fileapi/file_system_file_reader.cc +++ b/webkit/fileapi/file_system_file_reader.cc @@ -5,8 +5,8 @@ #include "webkit/fileapi/file_system_file_reader.h" #include "base/file_util_proxy.h" -#include "base/message_loop_proxy.h" #include "base/platform_file.h" +#include "base/sequenced_task_runner.h" #include "net/base/file_stream.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" @@ -33,12 +33,10 @@ void ReadAdapter(base::WeakPtr<FileSystemFileReader> reader, } FileSystemFileReader::FileSystemFileReader( - base::MessageLoopProxy* file_thread_proxy, FileSystemContext* file_system_context, const GURL& url, int64 initial_offset) - : file_thread_proxy_(file_thread_proxy), - file_system_context_(file_system_context), + : file_system_context_(file_system_context), url_(url), initial_offset_(initial_offset), has_pending_create_snapshot_(false), @@ -55,8 +53,7 @@ int FileSystemFileReader::Read( return local_file_reader_->Read(buf, buf_len, callback); DCHECK(!has_pending_create_snapshot_); FileSystemOperationInterface* operation = - file_system_context_->CreateFileSystemOperation( - url_, file_thread_proxy_); + file_system_context_->CreateFileSystemOperation(url_); if (!operation) return net::ERR_INVALID_URL; has_pending_create_snapshot_ = true; @@ -90,7 +87,7 @@ void FileSystemFileReader::DidCreateSnapshot( snapshot_ref_ = file_ref; local_file_reader_.reset( - new LocalFileReader(file_thread_proxy_, + new LocalFileReader(file_system_context_->file_task_runner(), platform_path, initial_offset_, base::Time())); diff --git a/webkit/fileapi/file_system_file_reader.h b/webkit/fileapi/file_system_file_reader.h index cc9a4f3..4b63ed3 100644 --- a/webkit/fileapi/file_system_file_reader.h +++ b/webkit/fileapi/file_system_file_reader.h @@ -15,7 +15,7 @@ class FilePath; namespace base { -class MessageLoopProxy; +class SequencedTaskRunner; } namespace webkit_blob { @@ -34,8 +34,7 @@ class FileSystemContext; class FileSystemFileReader : public webkit_blob::FileReader { public: // Creates a new FileReader for a filesystem URL |url| form |initial_offset|. - FileSystemFileReader(base::MessageLoopProxy* file_thread_proxy, - FileSystemContext* file_system_context, + FileSystemFileReader(FileSystemContext* file_system_context, const GURL& url, int64 initial_offset); virtual ~FileSystemFileReader(); @@ -53,7 +52,6 @@ class FileSystemFileReader : public webkit_blob::FileReader { const FilePath& platform_path, const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); - scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; scoped_refptr<FileSystemContext> file_system_context_; const GURL url_; const int64 initial_offset_; diff --git a/webkit/fileapi/file_system_file_util_proxy.cc b/webkit/fileapi/file_system_file_util_proxy.cc index f26d279..301b0bf 100644 --- a/webkit/fileapi/file_system_file_util_proxy.cc +++ b/webkit/fileapi/file_system_file_util_proxy.cc @@ -6,7 +6,8 @@ #include "base/bind.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop_proxy.h" +#include "base/sequenced_task_runner.h" +#include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_file_util.h" #include "webkit/fileapi/file_system_operation_context.h" #include "webkit/fileapi/file_util_helper.h" @@ -92,28 +93,26 @@ class ReadDirectoryHelper { // static bool FileSystemFileUtilProxy::Delete( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, bool recursive, const StatusCallback& callback) { return base::FileUtilProxy::RelayFileTask( - message_loop_proxy, FROM_HERE, + context->file_task_runner(), FROM_HERE, Bind(&FileUtilHelper::Delete, context, file_util, path, recursive), callback); } // static bool FileSystemFileUtilProxy::CreateOrOpen( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, int file_flags, const CreateOrOpenCallback& callback) { return base::FileUtilProxy::RelayCreateOrOpen( - message_loop_proxy, + context->file_task_runner(), Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), context, path, file_flags), Bind(&FileSystemFileUtil::Close, Unretained(file_util), @@ -123,7 +122,6 @@ bool FileSystemFileUtilProxy::CreateOrOpen( // static bool FileSystemFileUtilProxy::Copy( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* src_util, FileSystemFileUtil* dest_util, @@ -131,7 +129,7 @@ bool FileSystemFileUtilProxy::Copy( const FileSystemPath& dest_path, const StatusCallback& callback) { return base::FileUtilProxy::RelayFileTask( - message_loop_proxy, FROM_HERE, + context->file_task_runner(), FROM_HERE, Bind(&FileUtilHelper::Copy, context, src_util, dest_util, src_path, dest_path), callback); @@ -139,7 +137,6 @@ bool FileSystemFileUtilProxy::Copy( // static bool FileSystemFileUtilProxy::Move( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* src_util, FileSystemFileUtil* dest_util, @@ -147,7 +144,7 @@ bool FileSystemFileUtilProxy::Move( const FileSystemPath& dest_path, const StatusCallback& callback) { return base::FileUtilProxy::RelayFileTask( - message_loop_proxy, FROM_HERE, + context->file_task_runner(), FROM_HERE, Bind(&FileUtilHelper::Move, context, src_util, dest_util, src_path, dest_path), callback); @@ -155,13 +152,12 @@ bool FileSystemFileUtilProxy::Move( // static bool FileSystemFileUtilProxy::EnsureFileExists( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, const EnsureFileExistsCallback& callback) { EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; - return message_loop_proxy->PostTaskAndReply( + return context->file_task_runner()->PostTaskAndReply( FROM_HERE, Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), file_util, context, path), @@ -170,7 +166,6 @@ bool FileSystemFileUtilProxy::EnsureFileExists( // static bool FileSystemFileUtilProxy::CreateDirectory( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, @@ -178,7 +173,7 @@ bool FileSystemFileUtilProxy::CreateDirectory( bool recursive, const StatusCallback& callback) { return base::FileUtilProxy::RelayFileTask( - message_loop_proxy, FROM_HERE, + context->file_task_runner(), FROM_HERE, Bind(&FileSystemFileUtil::CreateDirectory, Unretained(file_util), context, path, exclusive, recursive), callback); @@ -186,13 +181,12 @@ bool FileSystemFileUtilProxy::CreateDirectory( // static bool FileSystemFileUtilProxy::GetFileInfo( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, const GetFileInfoCallback& callback) { GetFileInfoHelper* helper = new GetFileInfoHelper; - return message_loop_proxy->PostTaskAndReply( + return context->file_task_runner()->PostTaskAndReply( FROM_HERE, Bind(&GetFileInfoHelper::RunWork, Unretained(helper), file_util, context, path), @@ -201,13 +195,12 @@ bool FileSystemFileUtilProxy::GetFileInfo( // static bool FileSystemFileUtilProxy::ReadDirectory( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, const ReadDirectoryCallback& callback) { ReadDirectoryHelper* helper = new ReadDirectoryHelper; - return message_loop_proxy->PostTaskAndReply( + return context->file_task_runner()->PostTaskAndReply( FROM_HERE, Bind(&ReadDirectoryHelper::RunWork, Unretained(helper), file_util, context, path), @@ -216,7 +209,6 @@ bool FileSystemFileUtilProxy::ReadDirectory( // static bool FileSystemFileUtilProxy::Touch( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, @@ -224,7 +216,7 @@ bool FileSystemFileUtilProxy::Touch( const base::Time& last_modified_time, const StatusCallback& callback) { return base::FileUtilProxy::RelayFileTask( - message_loop_proxy, FROM_HERE, + context->file_task_runner(), FROM_HERE, Bind(&FileSystemFileUtil::Touch, Unretained(file_util), context, path, last_access_time, last_modified_time), callback); @@ -232,14 +224,13 @@ bool FileSystemFileUtilProxy::Touch( // static bool FileSystemFileUtilProxy::Truncate( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, int64 length, const StatusCallback& callback) { return base::FileUtilProxy::RelayFileTask( - message_loop_proxy, FROM_HERE, + context->file_task_runner(), FROM_HERE, Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), context, path, length), callback); diff --git a/webkit/fileapi/file_system_file_util_proxy.h b/webkit/fileapi/file_system_file_util_proxy.h index c651565..9351edb 100644 --- a/webkit/fileapi/file_system_file_util_proxy.h +++ b/webkit/fileapi/file_system_file_util_proxy.h @@ -14,13 +14,8 @@ #include "base/platform_file.h" #include "base/tracked_objects.h" -namespace base { -class MessageLoopProxy; -} - namespace fileapi { -using base::MessageLoopProxy; using base::PlatformFile; using base::PlatformFileError; using base::PlatformFileInfo; @@ -50,10 +45,9 @@ class FileSystemFileUtilProxy { const std::vector<Entry>&, bool has_more)> ReadDirectoryCallback; - // Deletes a file or a directory on the given |message_loop_proxy|. + // Deletes a file or a directory on the given context's file_task_runner. // It is an error to delete a non-empty directory with recursive=false. static bool Delete( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, @@ -61,9 +55,8 @@ class FileSystemFileUtilProxy { const StatusCallback& callback); // Creates or opens a file with the given flags by calling |file_util|'s - // CreateOrOpen method on the given |message_loop_proxy|. + // CreateOrOpen method on the given context's file_task_runner. static bool CreateOrOpen( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, @@ -71,7 +64,8 @@ class FileSystemFileUtilProxy { const CreateOrOpenCallback& callback); // Copies a file or a directory from |src_path| to |dest_path| by calling - // FileSystemFileUtil's following methods on the given |message_loop_proxy|. + // FileSystemFileUtil's following methods on the given context's + // file_task_runner. // - CopyOrMoveFile() for same-filesystem operations // - CopyInForeignFile() for (limited) cross-filesystem operations // @@ -83,7 +77,6 @@ class FileSystemFileUtilProxy { // If source doesn't exist. // If source and dest are the same path in the same filesystem. static bool Copy( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* src_util, FileSystemFileUtil* dest_util, @@ -92,13 +85,13 @@ class FileSystemFileUtilProxy { const StatusCallback& callback); // Moves a file or a directory from |src_path| to |dest_path| by calling - // FileSystemFileUtil's following methods on the given |message_loop_proxy|. + // FileSystemFileUtil's following methods on the given context's + // file_task_runner. // - CopyOrMoveFile() for same-filesystem operations // - CopyInForeignFile() for (limited) cross-filesystem operations // // This method returns an error on the same error cases with Copy. static bool Move( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* src_util, FileSystemFileUtil* dest_util, @@ -107,18 +100,16 @@ class FileSystemFileUtilProxy { const StatusCallback& callback); // Ensures that the given |path| exist by calling |file_util|'s - // EnsureFileExists method on the given |message_loop_proxy|. + // EnsureFileExists method on the given context's file_task_runner. static bool EnsureFileExists( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, const EnsureFileExistsCallback& callback); // Creates directory at a given path by calling |file_util|'s - // CreateDirectory method on the given |message_loop_proxy|. + // CreateDirectory method on the given context's file_task_runner. static bool CreateDirectory( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, @@ -127,28 +118,25 @@ class FileSystemFileUtilProxy { const StatusCallback& callback); // Retrieves the information about a file by calling |file_util|'s - // GetFileInfo method on the given |message_loop_proxy|. + // GetFileInfo method on the given context's file_task_runner. static bool GetFileInfo( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, const GetFileInfoCallback& callback); // Reads the filenames in |path| by calling |file_util|'s - // ReadDirectory method on the given |message_loop_proxy|. + // ReadDirectory method on the given context's file_task_runner. // TODO: this should support returning entries in multiple chunks. static bool ReadDirectory( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, const ReadDirectoryCallback& callback); // Touches a file by calling |file_util|'s Touch method - // on the given |message_loop_proxy|. + // on the given context's file_task_runner. static bool Touch( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, @@ -157,9 +145,8 @@ class FileSystemFileUtilProxy { const StatusCallback& callback); // Truncates a file to the given length by calling |file_util|'s - // Truncate method on the given |message_loop_proxy|. + // Truncate method on the given context's file_task_runner. static bool Truncate( - MessageLoopProxy* message_loop_proxy, FileSystemOperationContext* context, FileSystemFileUtil* file_util, const FileSystemPath& path, diff --git a/webkit/fileapi/file_system_mount_point_provider.h b/webkit/fileapi/file_system_mount_point_provider.h index 18e1d9a..ebce1de 100644 --- a/webkit/fileapi/file_system_mount_point_provider.h +++ b/webkit/fileapi/file_system_mount_point_provider.h @@ -16,10 +16,6 @@ class GURL; -namespace base { -class MessageLoopProxy; -} - namespace webkit_blob { class FileReader; } @@ -92,7 +88,6 @@ class FileSystemMountPointProvider { const GURL& origin_url, FileSystemType file_system_type, const FilePath& virtual_path, - base::MessageLoopProxy* file_proxy, FileSystemContext* context) const = 0; // Creates a new file reader for a given filesystem URL |url| with a offset @@ -103,7 +98,6 @@ class FileSystemMountPointProvider { virtual webkit_blob::FileReader* CreateFileReader( const GURL& url, int64 offset, - base::MessageLoopProxy* file_proxy, FileSystemContext* context) const = 0; }; diff --git a/webkit/fileapi/file_system_operation.cc b/webkit/fileapi/file_system_operation.cc index 23f87ce..663bace 100644 --- a/webkit/fileapi/file_system_operation.cc +++ b/webkit/fileapi/file_system_operation.cc @@ -5,6 +5,7 @@ #include "webkit/fileapi/file_system_operation.h" #include "base/bind.h" +#include "base/sequenced_task_runner.h" #include "base/time.h" #include "base/utf_string_conversions.h" #include "net/base/escape.h" @@ -82,7 +83,7 @@ FileSystemOperation::~FileSystemOperation() { FileSystemOperationContext* c = new FileSystemOperationContext(operation_context_); base::FileUtilProxy::RelayClose( - proxy_, + file_system_context()->file_task_runner(), base::Bind(&FileSystemFileUtil::Close, base::Unretained(src_util_), base::Owned(c)), @@ -190,7 +191,7 @@ void FileSystemOperation::DirectoryExists(const GURL& path_url, } FileSystemFileUtilProxy::GetFileInfo( - proxy_, &operation_context_, src_util_, src_path_, + &operation_context_, src_util_, src_path_, base::Bind(&FileSystemOperation::DidDirectoryExists, base::Owned(this), callback)); } @@ -208,7 +209,7 @@ void FileSystemOperation::FileExists(const GURL& path_url, } FileSystemFileUtilProxy::GetFileInfo( - proxy_, &operation_context_, src_util_, src_path_, + &operation_context_, src_util_, src_path_, base::Bind(&FileSystemOperation::DidFileExists, base::Owned(this), callback)); } @@ -226,7 +227,7 @@ void FileSystemOperation::GetMetadata(const GURL& path_url, } FileSystemFileUtilProxy::GetFileInfo( - proxy_, &operation_context_, src_util_, src_path_, + &operation_context_, src_util_, src_path_, base::Bind(&FileSystemOperation::DidGetMetadata, base::Owned(this), callback)); } @@ -244,7 +245,7 @@ void FileSystemOperation::ReadDirectory(const GURL& path_url, } FileSystemFileUtilProxy::ReadDirectory( - proxy_, &operation_context_, src_util_, src_path_, + &operation_context_, src_util_, src_path_, base::Bind(&FileSystemOperation::DidReadDirectory, base::Owned(this), callback)); } @@ -265,7 +266,7 @@ void FileSystemOperation::Remove(const GURL& path_url, bool recursive, file_system_context(), src_path_.origin(), src_path_.type())); FileSystemFileUtilProxy::Delete( - proxy_, &operation_context_, src_util_, src_path_, recursive, + &operation_context_, src_util_, src_path_, recursive, base::Bind(&FileSystemOperation::DidFinishFileOperation, base::Owned(this), callback)); } @@ -287,7 +288,7 @@ void FileSystemOperation::Write( } DCHECK(blob_url.is_valid()); file_writer_delegate_.reset(new FileWriterDelegate( - this, src_path_, offset, proxy_)); + this, src_path_, offset)); set_write_callback(callback); blob_request_.reset( new net::URLRequest(blob_url, file_writer_delegate_.get())); @@ -332,7 +333,7 @@ void FileSystemOperation::TouchFile(const GURL& path_url, } FileSystemFileUtilProxy::Touch( - proxy_, &operation_context_, src_util_, src_path_, + &operation_context_, src_util_, src_path_, last_access_time, last_modified_time, base::Bind(&FileSystemOperation::DidTouchFile, base::Owned(this), callback)); @@ -444,10 +445,8 @@ void FileSystemOperation::CreateSnapshotFile( } FileSystemOperation::FileSystemOperation( - scoped_refptr<base::MessageLoopProxy> proxy, FileSystemContext* file_system_context) - : proxy_(proxy), - operation_context_(file_system_context), + : operation_context_(file_system_context), src_util_(NULL), dest_util_(NULL), peer_handle_(base::kNullProcessHandle), @@ -505,7 +504,8 @@ void FileSystemOperation::DoCreateFile( const StatusCallback& callback, bool exclusive) { FileSystemFileUtilProxy::EnsureFileExists( - proxy_, &operation_context_, src_util_, src_path_, + &operation_context_, + src_util_, src_path_, base::Bind( exclusive ? &FileSystemOperation::DidEnsureFileExistsExclusive : &FileSystemOperation::DidEnsureFileExistsNonExclusive, @@ -516,14 +516,15 @@ void FileSystemOperation::DoCreateDirectory( const StatusCallback& callback, bool exclusive, bool recursive) { FileSystemFileUtilProxy::CreateDirectory( - proxy_, &operation_context_, src_util_, src_path_, exclusive, recursive, + &operation_context_, + src_util_, src_path_, exclusive, recursive, base::Bind(&FileSystemOperation::DidFinishFileOperation, base::Owned(this), callback)); } void FileSystemOperation::DoCopy(const StatusCallback& callback) { FileSystemFileUtilProxy::Copy( - proxy_, &operation_context_, + &operation_context_, src_util_, dest_util_, src_path_, dest_path_, base::Bind(&FileSystemOperation::DidFinishFileOperation, @@ -532,7 +533,7 @@ void FileSystemOperation::DoCopy(const StatusCallback& callback) { void FileSystemOperation::DoMove(const StatusCallback& callback) { FileSystemFileUtilProxy::Move( - proxy_, &operation_context_, + &operation_context_, src_util_, dest_util_, src_path_, dest_path_, base::Bind(&FileSystemOperation::DidFinishFileOperation, @@ -545,7 +546,7 @@ void FileSystemOperation::DoWrite() { base::PLATFORM_FILE_ASYNC; FileSystemFileUtilProxy::CreateOrOpen( - proxy_, &operation_context_, src_util_, src_path_, file_flags, + &operation_context_, src_util_, src_path_, file_flags, base::Bind(&FileSystemOperation::OnFileOpenedForWrite, base::Unretained(this))); } @@ -553,7 +554,7 @@ void FileSystemOperation::DoWrite() { void FileSystemOperation::DoTruncate(const StatusCallback& callback, int64 length) { FileSystemFileUtilProxy::Truncate( - proxy_, &operation_context_, src_util_, src_path_, length, + &operation_context_, src_util_, src_path_, length, base::Bind(&FileSystemOperation::DidFinishFileOperation, base::Owned(this), callback)); } @@ -561,7 +562,7 @@ void FileSystemOperation::DoTruncate(const StatusCallback& callback, void FileSystemOperation::DoOpenFile(const OpenFileCallback& callback, int file_flags) { FileSystemFileUtilProxy::CreateOrOpen( - proxy_, &operation_context_, src_util_, src_path_, file_flags, + &operation_context_, src_util_, src_path_, file_flags, base::Bind(&FileSystemOperation::DidOpenFile, base::Owned(this), callback)); } diff --git a/webkit/fileapi/file_system_operation.h b/webkit/fileapi/file_system_operation.h index 380e3ee..dde3158 100644 --- a/webkit/fileapi/file_system_operation.h +++ b/webkit/fileapi/file_system_operation.h @@ -13,7 +13,6 @@ #include "base/gtest_prod_util.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop_proxy.h" #include "base/platform_file.h" #include "base/process.h" #include "googleurl/src/gurl.h" @@ -130,8 +129,7 @@ class FileSystemOperation : public FileSystemOperationInterface { friend class FileSystemTestOriginHelper; friend class FileSystemQuotaTest; - FileSystemOperation(scoped_refptr<base::MessageLoopProxy> proxy, - FileSystemContext* file_system_context); + FileSystemOperation(FileSystemContext* file_system_context); FileSystemContext* file_system_context() const { return operation_context_.file_system_context(); @@ -236,9 +234,6 @@ class FileSystemOperation : public FileSystemOperationInterface { // Returns false if there's another inflight pending operation. bool SetPendingOperationType(OperationType type); - // Proxy for calling file_util_proxy methods. - scoped_refptr<base::MessageLoopProxy> proxy_; - FileSystemOperationContext operation_context_; FileSystemPath src_path_; FileSystemPath dest_path_; diff --git a/webkit/fileapi/file_system_operation_context.cc b/webkit/fileapi/file_system_operation_context.cc index 0f33024..196e3b8 100644 --- a/webkit/fileapi/file_system_operation_context.cc +++ b/webkit/fileapi/file_system_operation_context.cc @@ -15,4 +15,9 @@ FileSystemOperationContext::FileSystemOperationContext( FileSystemOperationContext::~FileSystemOperationContext() {} +base::SequencedTaskRunner* +FileSystemOperationContext::file_task_runner() const { + return file_system_context_->file_task_runner(); +} + } // namespace fileapi diff --git a/webkit/fileapi/file_system_operation_context.h b/webkit/fileapi/file_system_operation_context.h index 77298bf..06a2ff2 100644 --- a/webkit/fileapi/file_system_operation_context.h +++ b/webkit/fileapi/file_system_operation_context.h @@ -11,6 +11,10 @@ #include "webkit/fileapi/file_system_file_util.h" #include "webkit/fileapi/file_system_types.h" +namespace base { +class SequencedTaskRunner; +} + namespace fileapi { class FileSystemContext; @@ -29,6 +33,8 @@ class FileSystemOperationContext { } int64 allowed_bytes_growth() const { return allowed_bytes_growth_; } + base::SequencedTaskRunner* file_task_runner() const; + private: scoped_refptr<FileSystemContext> file_system_context_; diff --git a/webkit/fileapi/file_system_quota_client.cc b/webkit/fileapi/file_system_quota_client.cc index d0a1ccc..f4ee095 100644 --- a/webkit/fileapi/file_system_quota_client.cc +++ b/webkit/fileapi/file_system_quota_client.cc @@ -11,7 +11,7 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop_proxy.h" +#include "base/sequenced_task_runner.h" #include "googleurl/src/gurl.h" #include "net/base/net_util.h" #include "webkit/fileapi/file_system_context.h" @@ -19,7 +19,7 @@ #include "webkit/fileapi/file_system_usage_cache.h" #include "webkit/fileapi/file_system_util.h" -using base::MessageLoopProxy; +using base::SequencedTaskRunner; using quota::QuotaThreadTask; using quota::StorageType; @@ -29,10 +29,9 @@ class FileSystemQuotaClient::GetOriginUsageTask : public QuotaThreadTask { public: GetOriginUsageTask( FileSystemQuotaClient* quota_client, - scoped_refptr<MessageLoopProxy> file_message_loop, const GURL& origin_url, FileSystemType type) - : QuotaThreadTask(quota_client, file_message_loop), + : QuotaThreadTask(quota_client, quota_client->file_task_runner()), quota_client_(quota_client), origin_url_(origin_url), type_(type), @@ -66,9 +65,8 @@ class FileSystemQuotaClient::GetOriginsForTypeTask : public QuotaThreadTask { public: GetOriginsForTypeTask( FileSystemQuotaClient* quota_client, - scoped_refptr<MessageLoopProxy> file_message_loop, FileSystemType type) - : QuotaThreadTask(quota_client, file_message_loop), + : QuotaThreadTask(quota_client, quota_client->file_task_runner()), quota_client_(quota_client), type_(type) { DCHECK(quota_client_); @@ -100,10 +98,9 @@ class FileSystemQuotaClient::GetOriginsForHostTask : public QuotaThreadTask { public: GetOriginsForHostTask( FileSystemQuotaClient* quota_client, - scoped_refptr<MessageLoopProxy> file_message_loop, FileSystemType type, const std::string& host) - : QuotaThreadTask(quota_client, file_message_loop), + : QuotaThreadTask(quota_client, quota_client->file_task_runner()), quota_client_(quota_client), type_(type), host_(host) { @@ -138,11 +135,10 @@ class FileSystemQuotaClient::DeleteOriginTask public: DeleteOriginTask( FileSystemQuotaClient* quota_client, - scoped_refptr<MessageLoopProxy> file_message_loop, const GURL& origin, FileSystemType type, const DeletionCallback& callback) - : QuotaThreadTask(quota_client, file_message_loop), + : QuotaThreadTask(quota_client, quota_client->file_task_runner()), file_system_context_(quota_client->file_system_context_), origin_(origin), type_(type), @@ -175,13 +171,10 @@ class FileSystemQuotaClient::DeleteOriginTask }; FileSystemQuotaClient::FileSystemQuotaClient( - scoped_refptr<base::MessageLoopProxy> file_message_loop, FileSystemContext* file_system_context, bool is_incognito) - : file_message_loop_(file_message_loop), - file_system_context_(file_system_context), + : file_system_context_(file_system_context), is_incognito_(is_incognito) { - DCHECK(file_message_loop); } FileSystemQuotaClient::~FileSystemQuotaClient() {} @@ -212,7 +205,7 @@ void FileSystemQuotaClient::GetOriginUsage( if (pending_usage_callbacks_.Add( std::make_pair(type, origin_url.spec()), callback)) { scoped_refptr<GetOriginUsageTask> task( - new GetOriginUsageTask(this, file_message_loop_, origin_url, type)); + new GetOriginUsageTask(this, origin_url, type)); task->Start(); } } @@ -234,7 +227,7 @@ void FileSystemQuotaClient::GetOriginsForType( if (pending_origins_for_type_callbacks_.Add(type, callback)) { scoped_refptr<GetOriginsForTypeTask> task( - new GetOriginsForTypeTask(this, file_message_loop_, type)); + new GetOriginsForTypeTask(this, type)); task->Start(); } } @@ -258,8 +251,7 @@ void FileSystemQuotaClient::GetOriginsForHost( if (pending_origins_for_host_callbacks_.Add( std::make_pair(type, host), callback)) { scoped_refptr<GetOriginsForHostTask> task( - new GetOriginsForHostTask(this, file_message_loop_, - type, host)); + new GetOriginsForHostTask(this, type, host)); task->Start(); } } @@ -270,8 +262,7 @@ void FileSystemQuotaClient::DeleteOriginData(const GURL& origin, FileSystemType fs_type = QuotaStorageTypeToFileSystemType(type); DCHECK(fs_type != kFileSystemTypeUnknown); scoped_refptr<DeleteOriginTask> task( - new DeleteOriginTask(this, file_message_loop_, - origin, fs_type, callback)); + new DeleteOriginTask(this, origin, fs_type, callback)); task->Start(); } @@ -297,4 +288,8 @@ void FileSystemQuotaClient::DidGetOriginsForHost( FileSystemTypeToQuotaStorageType(type_and_host.first)); } +base::SequencedTaskRunner* FileSystemQuotaClient::file_task_runner() const { + return file_system_context_->file_task_runner(); +} + } // namespace fileapi diff --git a/webkit/fileapi/file_system_quota_client.h b/webkit/fileapi/file_system_quota_client.h index d5d6403..cc4cd37 100644 --- a/webkit/fileapi/file_system_quota_client.h +++ b/webkit/fileapi/file_system_quota_client.h @@ -17,6 +17,10 @@ #include "webkit/quota/quota_client.h" #include "webkit/quota/quota_task.h" +namespace base { +class SequencedTaskRunner; +} + namespace fileapi { class FileSystemContext; @@ -30,7 +34,6 @@ class FileSystemQuotaClient : public quota::QuotaClient, public quota::QuotaTaskObserver { public: FileSystemQuotaClient( - scoped_refptr<base::MessageLoopProxy> file_message_loop, FileSystemContext* file_system_context, bool is_incognito); virtual ~FileSystemQuotaClient(); @@ -83,7 +86,8 @@ class FileSystemQuotaClient : public quota::QuotaClient, void DidGetOriginsForHost(const TypeAndHostOrOrigin& type_and_host, const std::set<GURL>& origins); - scoped_refptr<base::MessageLoopProxy> file_message_loop_; + base::SequencedTaskRunner* file_task_runner() const; + scoped_refptr<FileSystemContext> file_system_context_; bool is_incognito_; diff --git a/webkit/fileapi/file_system_quota_client_unittest.cc b/webkit/fileapi/file_system_quota_client_unittest.cc index 8d487cb..a3c3e9b 100644 --- a/webkit/fileapi/file_system_quota_client_unittest.cc +++ b/webkit/fileapi/file_system_quota_client_unittest.cc @@ -66,7 +66,6 @@ class FileSystemQuotaClientTest : public testing::Test { protected: FileSystemQuotaClient* NewQuotaClient(bool is_incognito) { return new FileSystemQuotaClient( - base::MessageLoopProxy::current(), file_system_context_, is_incognito); } diff --git a/webkit/fileapi/file_system_quota_util.cc b/webkit/fileapi/file_system_quota_util.cc index 9a5a63c..286588d 100644 --- a/webkit/fileapi/file_system_quota_util.cc +++ b/webkit/fileapi/file_system_quota_util.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. @@ -8,14 +8,15 @@ #include "base/compiler_specific.h" #include "base/location.h" #include "base/message_loop_proxy.h" +#include "base/sequenced_task_runner.h" namespace fileapi { void FileSystemQuotaUtil::Proxy::UpdateOriginUsage( quota::QuotaManagerProxy* proxy, const GURL& origin_url, fileapi::FileSystemType type, int64 delta) { - if (!file_thread_->BelongsToCurrentThread()) { - file_thread_->PostTask( + if (!file_task_runner_->RunsTasksOnCurrentThread()) { + file_task_runner_->PostTask( FROM_HERE, base::Bind(&Proxy::UpdateOriginUsage, this, proxy, origin_url, type, delta)); @@ -27,8 +28,8 @@ void FileSystemQuotaUtil::Proxy::UpdateOriginUsage( void FileSystemQuotaUtil::Proxy::StartUpdateOrigin( const GURL& origin_url, fileapi::FileSystemType type) { - if (!file_thread_->BelongsToCurrentThread()) { - file_thread_->PostTask( + if (!file_task_runner_->RunsTasksOnCurrentThread()) { + file_task_runner_->PostTask( FROM_HERE, base::Bind(&Proxy::StartUpdateOrigin, this, origin_url, type)); return; @@ -39,8 +40,8 @@ void FileSystemQuotaUtil::Proxy::StartUpdateOrigin( void FileSystemQuotaUtil::Proxy::EndUpdateOrigin( const GURL& origin_url, fileapi::FileSystemType type) { - if (!file_thread_->BelongsToCurrentThread()) { - file_thread_->PostTask( + if (!file_task_runner_->RunsTasksOnCurrentThread()) { + file_task_runner_->PostTask( FROM_HERE, base::Bind(&Proxy::EndUpdateOrigin, this, origin_url, type)); return; @@ -51,17 +52,19 @@ void FileSystemQuotaUtil::Proxy::EndUpdateOrigin( FileSystemQuotaUtil::Proxy::Proxy( FileSystemQuotaUtil* quota_util, - base::MessageLoopProxy* file_thread) + base::SequencedTaskRunner* file_task_runner) : quota_util_(quota_util), - file_thread_(file_thread) { + file_task_runner_(file_task_runner) { DCHECK(quota_util); } FileSystemQuotaUtil::Proxy::~Proxy() { } -FileSystemQuotaUtil::FileSystemQuotaUtil(base::MessageLoopProxy* file_thread) - : proxy_(new Proxy(ALLOW_THIS_IN_INITIALIZER_LIST(this), file_thread)) { +FileSystemQuotaUtil::FileSystemQuotaUtil( + base::SequencedTaskRunner* file_task_runner) + : proxy_(new Proxy(ALLOW_THIS_IN_INITIALIZER_LIST(this), + file_task_runner)) { } FileSystemQuotaUtil::~FileSystemQuotaUtil() { diff --git a/webkit/fileapi/file_system_quota_util.h b/webkit/fileapi/file_system_quota_util.h index 5ba638a..6063acf 100644 --- a/webkit/fileapi/file_system_quota_util.h +++ b/webkit/fileapi/file_system_quota_util.h @@ -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. @@ -14,7 +14,7 @@ #include "webkit/fileapi/file_system_types.h" namespace base { -class MessageLoopProxy; +class SequencedTaskRunner; } namespace quota { @@ -46,11 +46,11 @@ class FileSystemQuotaUtil { friend class FileSystemQuotaUtil; friend class base::RefCountedThreadSafe<Proxy>; Proxy(FileSystemQuotaUtil* quota_handler, - base::MessageLoopProxy* file_thread); + base::SequencedTaskRunner* file_task_runner); ~Proxy(); FileSystemQuotaUtil* quota_util_; // Accessed only on the FILE thread. - scoped_refptr<base::MessageLoopProxy> file_thread_; + scoped_refptr<base::SequencedTaskRunner> file_task_runner_; DISALLOW_COPY_AND_ASSIGN(Proxy); }; @@ -97,7 +97,7 @@ class FileSystemQuotaUtil { Proxy* proxy() { return proxy_.get(); } protected: - explicit FileSystemQuotaUtil(base::MessageLoopProxy* file_thread); + explicit FileSystemQuotaUtil(base::SequencedTaskRunner* file_task_runner); virtual ~FileSystemQuotaUtil(); private: diff --git a/webkit/fileapi/file_system_test_helper.cc b/webkit/fileapi/file_system_test_helper.cc index b036a2e..554b035 100644 --- a/webkit/fileapi/file_system_test_helper.cc +++ b/webkit/fileapi/file_system_test_helper.cc @@ -175,8 +175,7 @@ FileSystemOperation* FileSystemTestOriginHelper::NewOperation() { DCHECK(file_system_context_.get()); DCHECK(file_util_); FileSystemOperation* operation = - new FileSystemOperation(base::MessageLoopProxy::current(), - file_system_context_.get()); + new FileSystemOperation(file_system_context_.get()); operation->set_override_file_util(file_util_); return operation; } diff --git a/webkit/fileapi/file_system_url_request_job.cc b/webkit/fileapi/file_system_url_request_job.cc index b76e11e..8823662 100644 --- a/webkit/fileapi/file_system_url_request_job.cc +++ b/webkit/fileapi/file_system_url_request_job.cc @@ -11,6 +11,7 @@ #include "base/file_path.h" #include "base/file_util_proxy.h" #include "base/message_loop.h" +#include "base/message_loop_proxy.h" #include "base/platform_file.h" #include "base/threading/thread_restrictions.h" #include "base/time.h" @@ -53,11 +54,9 @@ static net::HttpResponseHeaders* CreateHttpResponseHeaders() { } FileSystemURLRequestJob::FileSystemURLRequestJob( - URLRequest* request, FileSystemContext* file_system_context, - scoped_refptr<base::MessageLoopProxy> file_thread_proxy) + URLRequest* request, FileSystemContext* file_system_context) : URLRequestJob(request), file_system_context_(file_system_context), - file_thread_proxy_(file_thread_proxy), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), is_directory_(false), remaining_bytes_(0) { @@ -158,9 +157,7 @@ void FileSystemURLRequestJob::StartAsync() { return; DCHECK(!reader_.get()); FileSystemOperationInterface* operation = - file_system_context_->CreateFileSystemOperation( - request_->url(), - file_thread_proxy_); + file_system_context_->CreateFileSystemOperation(request_->url()); if (!operation) { NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, net::ERR_INVALID_URL)); @@ -206,8 +203,7 @@ void FileSystemURLRequestJob::DidGetMetadata( reader_.reset( file_system_context_->CreateFileReader( request_->url(), - byte_range_.first_byte_position(), - file_thread_proxy_)); + byte_range_.first_byte_position())); set_expected_content_size(remaining_bytes_); response_info_.reset(new net::HttpResponseInfo()); diff --git a/webkit/fileapi/file_system_url_request_job.h b/webkit/fileapi/file_system_url_request_job.h index 13391d7..3d69008 100644 --- a/webkit/fileapi/file_system_url_request_job.h +++ b/webkit/fileapi/file_system_url_request_job.h @@ -11,7 +11,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop_proxy.h" #include "base/platform_file.h" #include "net/http/http_byte_range.h" #include "net/url_request/url_request_job.h" @@ -31,8 +30,7 @@ class FileSystemURLRequestJob : public net::URLRequestJob { public: FileSystemURLRequestJob( net::URLRequest* request, - FileSystemContext* file_system_context, - scoped_refptr<base::MessageLoopProxy> file_thread_proxy); + FileSystemContext* file_system_context); // URLRequestJob methods: virtual void Start() OVERRIDE; @@ -64,7 +62,6 @@ class FileSystemURLRequestJob : public net::URLRequestJob { void NotifyFailed(int rv); FileSystemContext* file_system_context_; - scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; base::WeakPtrFactory<FileSystemURLRequestJob> weak_factory_; scoped_ptr<webkit_blob::FileReader> reader_; bool is_directory_; diff --git a/webkit/fileapi/file_system_url_request_job_factory.cc b/webkit/fileapi/file_system_url_request_job_factory.cc index 4e5855a..ae6f39c 100644 --- a/webkit/fileapi/file_system_url_request_job_factory.cc +++ b/webkit/fileapi/file_system_url_request_job_factory.cc @@ -19,9 +19,7 @@ namespace { class FileSystemProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { public: - explicit FileSystemProtocolHandler( - FileSystemContext* context, - base::MessageLoopProxy* loop_proxy); + explicit FileSystemProtocolHandler(FileSystemContext* context); virtual ~FileSystemProtocolHandler(); virtual net::URLRequestJob* MaybeCreateJob( @@ -31,18 +29,14 @@ class FileSystemProtocolHandler // No scoped_refptr because |file_system_context_| is owned by the // ProfileIOData, which also owns this ProtocolHandler. FileSystemContext* const file_system_context_; - const scoped_refptr<base::MessageLoopProxy> file_loop_proxy_; DISALLOW_COPY_AND_ASSIGN(FileSystemProtocolHandler); }; FileSystemProtocolHandler::FileSystemProtocolHandler( - FileSystemContext* context, - base::MessageLoopProxy* file_loop_proxy) - : file_system_context_(context), - file_loop_proxy_(file_loop_proxy) { + FileSystemContext* context) + : file_system_context_(context) { DCHECK(file_system_context_); - DCHECK(file_loop_proxy_); } FileSystemProtocolHandler::~FileSystemProtocolHandler() {} @@ -55,21 +49,17 @@ net::URLRequestJob* FileSystemProtocolHandler::MaybeCreateJob( // to a directory and gets dispatched to FileSystemURLRequestJob, that class // redirects back here, by adding a / to the URL. if (!path.empty() && path[path.size() - 1] == '/') { - return new FileSystemDirURLRequestJob( - request, file_system_context_, file_loop_proxy_); + return new FileSystemDirURLRequestJob(request, file_system_context_); } - return new FileSystemURLRequestJob( - request, file_system_context_, file_loop_proxy_); + return new FileSystemURLRequestJob(request, file_system_context_); } } // anonymous namespace net::URLRequestJobFactory::ProtocolHandler* -CreateFileSystemProtocolHandler(FileSystemContext* context, - base::MessageLoopProxy* loop_proxy) { +CreateFileSystemProtocolHandler(FileSystemContext* context) { DCHECK(context); - DCHECK(loop_proxy); - return new FileSystemProtocolHandler(context, loop_proxy); + return new FileSystemProtocolHandler(context); } } // namespace fileapi diff --git a/webkit/fileapi/file_system_url_request_job_factory.h b/webkit/fileapi/file_system_url_request_job_factory.h index 1e4e4c6..c159a27 100644 --- a/webkit/fileapi/file_system_url_request_job_factory.h +++ b/webkit/fileapi/file_system_url_request_job_factory.h @@ -19,8 +19,7 @@ class FileSystemContext; // Currently, this is only used by ProfileIOData which owns |context| and the // ProtocolHandler. net::URLRequestJobFactory::ProtocolHandler* -CreateFileSystemProtocolHandler(FileSystemContext* context, - base::MessageLoopProxy* file_loop_proxy); +CreateFileSystemProtocolHandler(FileSystemContext* context); } // namespace fileapi diff --git a/webkit/fileapi/file_system_url_request_job_unittest.cc b/webkit/fileapi/file_system_url_request_job_unittest.cc index 3fc8ad7..cb2107c 100644 --- a/webkit/fileapi/file_system_url_request_job_unittest.cc +++ b/webkit/fileapi/file_system_url_request_job_unittest.cc @@ -122,8 +122,7 @@ class FileSystemURLRequestJobTest : public testing::Test { ASSERT_TRUE(!job_); job_ = new FileSystemURLRequestJob( request_.get(), - file_system_context_.get(), - base::MessageLoopProxy::current()); + file_system_context_.get()); pending_job_ = job_; request_->Start(); diff --git a/webkit/fileapi/file_writer_delegate.cc b/webkit/fileapi/file_writer_delegate.cc index d92684b..1f8a086 100644 --- a/webkit/fileapi/file_writer_delegate.cc +++ b/webkit/fileapi/file_writer_delegate.cc @@ -8,6 +8,8 @@ #include "base/callback.h" #include "base/file_util_proxy.h" #include "base/message_loop.h" +#include "base/message_loop_proxy.h" +#include "base/sequenced_task_runner.h" #include "base/threading/thread_restrictions.h" #include "net/base/net_errors.h" #include "webkit/fileapi/file_system_context.h" @@ -33,8 +35,7 @@ class InitializeTask : public base::RefCountedThreadSafe<InitializeTask> { const FileSystemPath& path, FileSystemOperationContext* context, const InitializeTaskCallback& callback) - : origin_message_loop_proxy_( - base::MessageLoopProxy::current()), + : original_loop_(base::MessageLoopProxy::current()), error_code_(base::PLATFORM_FILE_OK), file_(file), path_(path), @@ -43,9 +44,9 @@ class InitializeTask : public base::RefCountedThreadSafe<InitializeTask> { DCHECK_EQ(false, callback.is_null()); } - bool Start(scoped_refptr<base::MessageLoopProxy> message_loop_proxy, + bool Start(base::SequencedTaskRunner* task_runner, const tracked_objects::Location& from_here) { - return message_loop_proxy->PostTask( + return task_runner->PostTask( from_here, base::Bind(&InitializeTask::ProcessOnTargetThread, this)); } @@ -68,12 +69,12 @@ class InitializeTask : public base::RefCountedThreadSafe<InitializeTask> { } if (!base::GetPlatformFileInfo(file_, &file_info_)) error_code_ = base::PLATFORM_FILE_ERROR_FAILED; - origin_message_loop_proxy_->PostTask( + original_loop_->PostTask( FROM_HERE, base::Bind(&InitializeTask::RunCallback, this)); } - scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_; + scoped_refptr<base::MessageLoopProxy> original_loop_; base::PlatformFileError error_code_; base::PlatformFile file_; @@ -89,13 +90,11 @@ class InitializeTask : public base::RefCountedThreadSafe<InitializeTask> { FileWriterDelegate::FileWriterDelegate( FileSystemOperation* file_system_operation, const FileSystemPath& path, - int64 offset, - scoped_refptr<base::MessageLoopProxy> proxy) + int64 offset) : file_system_operation_(file_system_operation), file_(base::kInvalidPlatformFileValue), path_(path), offset_(offset), - proxy_(proxy), bytes_written_backlog_(0), bytes_written_(0), bytes_read_(0), @@ -142,7 +141,7 @@ void FileWriterDelegate::Start(base::PlatformFile file, file_system_operation_context(), base::Bind(&FileWriterDelegate::OnGetFileInfoAndCallStartUpdate, weak_factory_.GetWeakPtr())); - relay->Start(proxy_, FROM_HERE); + relay->Start(file_system_operation_context()->file_task_runner(), FROM_HERE); } void FileWriterDelegate::OnReceivedRedirect(net::URLRequest* request, diff --git a/webkit/fileapi/file_writer_delegate.h b/webkit/fileapi/file_writer_delegate.h index dbb2d7c..4b37af0 100644 --- a/webkit/fileapi/file_writer_delegate.h +++ b/webkit/fileapi/file_writer_delegate.h @@ -8,7 +8,6 @@ #include "base/file_path.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop_proxy.h" #include "base/platform_file.h" #include "base/time.h" #include "net/base/file_stream.h" @@ -27,8 +26,7 @@ class FileWriterDelegate : public net::URLRequest::Delegate { FileWriterDelegate( FileSystemOperation* write_operation, const FileSystemPath& path, - int64 offset, - scoped_refptr<base::MessageLoopProxy> proxy); + int64 offset); virtual ~FileWriterDelegate(); void Start(base::PlatformFile file, @@ -71,7 +69,6 @@ class FileWriterDelegate : public net::URLRequest::Delegate { FileSystemPath path_; int64 size_; int64 offset_; - scoped_refptr<base::MessageLoopProxy> proxy_; base::Time last_progress_event_time_; int bytes_written_backlog_; int bytes_written_; diff --git a/webkit/fileapi/file_writer_delegate_unittest.cc b/webkit/fileapi/file_writer_delegate_unittest.cc index 24a85cb..31c95db 100644 --- a/webkit/fileapi/file_writer_delegate_unittest.cc +++ b/webkit/fileapi/file_writer_delegate_unittest.cc @@ -115,7 +115,7 @@ class FileWriterDelegateTest : public PlatformTest { file_writer_delegate_.reset(new FileWriterDelegate( CreateNewOperation(result_.get(), allowed_growth), test_helper_.CreatePath(file_path_), - offset, base::MessageLoopProxy::current())); + offset)); request_.reset(new net::URLRequest(blob_url, file_writer_delegate_.get())); } @@ -326,8 +326,7 @@ TEST_F(FileWriterDelegateTest, WriteSuccessWithoutQuotaLimitConcurrent) { result2.reset(new Result()); file_writer_delegate2.reset(new FileWriterDelegate( CreateNewOperation(result2.get(), QuotaFileUtil::kNoLimit), - test_helper_.CreatePath(file_path2), - 0, base::MessageLoopProxy::current())); + test_helper_.CreatePath(file_path2), 0)); request2.reset(new net::URLRequest(kBlobURL2, file_writer_delegate2.get())); ASSERT_EQ(0, test_helper_.GetCachedOriginUsage()); diff --git a/webkit/fileapi/isolated_mount_point_provider.cc b/webkit/fileapi/isolated_mount_point_provider.cc index 02bf8ae..0e4d813 100644 --- a/webkit/fileapi/isolated_mount_point_provider.cc +++ b/webkit/fileapi/isolated_mount_point_provider.cc @@ -10,9 +10,11 @@ #include "base/file_path.h" #include "base/logging.h" #include "base/message_loop_proxy.h" +#include "base/sequenced_task_runner.h" #include "googleurl/src/gurl.h" #include "webkit/blob/local_file_reader.h" #include "webkit/fileapi/file_system_callback_dispatcher.h" +#include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_file_reader.h" #include "webkit/fileapi/file_system_operation.h" #include "webkit/fileapi/file_system_types.h" @@ -95,15 +97,13 @@ IsolatedMountPointProvider::CreateFileSystemOperation( const GURL& origin_url, FileSystemType file_system_type, const FilePath& virtual_path, - base::MessageLoopProxy* file_proxy, FileSystemContext* context) const { - return new FileSystemOperation(file_proxy, context); + return new FileSystemOperation(context); } webkit_blob::FileReader* IsolatedMountPointProvider::CreateFileReader( const GURL& url, int64 offset, - base::MessageLoopProxy* file_proxy, FileSystemContext* context) const { GURL origin_url; FileSystemType file_system_type = kFileSystemTypeUnknown; @@ -117,7 +117,7 @@ webkit_blob::FileReader* IsolatedMountPointProvider::CreateFileReader( if (path.empty()) return NULL; return new webkit_blob::LocalFileReader( - file_proxy, path, offset, base::Time()); + context->file_task_runner(), path, offset, base::Time()); } IsolatedContext* IsolatedMountPointProvider::isolated_context() const { diff --git a/webkit/fileapi/isolated_mount_point_provider.h b/webkit/fileapi/isolated_mount_point_provider.h index 141bc94..d43daf4 100644 --- a/webkit/fileapi/isolated_mount_point_provider.h +++ b/webkit/fileapi/isolated_mount_point_provider.h @@ -45,12 +45,10 @@ class IsolatedMountPointProvider : public FileSystemMountPointProvider { const GURL& origin_url, FileSystemType file_system_type, const FilePath& virtual_path, - base::MessageLoopProxy* file_proxy, FileSystemContext* context) const OVERRIDE; virtual webkit_blob::FileReader* CreateFileReader( const GURL& url, int64 offset, - base::MessageLoopProxy* file_proxy, FileSystemContext* context) const OVERRIDE; private: diff --git a/webkit/fileapi/sandbox_mount_point_provider.cc b/webkit/fileapi/sandbox_mount_point_provider.cc index 0ab51204..ff1b6cd 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.cc +++ b/webkit/fileapi/sandbox_mount_point_provider.cc @@ -8,12 +8,11 @@ #include "base/command_line.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop.h" -#include "base/message_loop_proxy.h" +#include "base/metrics/histogram.h" #include "base/rand_util.h" +#include "base/sequenced_task_runner.h" #include "base/string_util.h" #include "base/stringprintf.h" -#include "base/metrics/histogram.h" #include "googleurl/src/gurl.h" #include "net/base/net_util.h" #include "webkit/fileapi/file_system_file_reader.h" @@ -306,11 +305,11 @@ const FilePath::CharType FILE_PATH_LITERAL("FS.old"); SandboxMountPointProvider::SandboxMountPointProvider( - scoped_refptr<base::MessageLoopProxy> file_message_loop, + base::SequencedTaskRunner* file_task_runner, const FilePath& profile_path, const FileSystemOptions& file_system_options) - : FileSystemQuotaUtil(file_message_loop), - file_message_loop_(file_message_loop), + : FileSystemQuotaUtil(file_task_runner), + file_task_runner_(file_task_runner), profile_path_(profile_path), file_system_options_(file_system_options), sandbox_file_util_( @@ -320,9 +319,9 @@ SandboxMountPointProvider::SandboxMountPointProvider( } SandboxMountPointProvider::~SandboxMountPointProvider() { - if (!file_message_loop_->BelongsToCurrentThread()) { + if (!file_task_runner_->RunsTasksOnCurrentThread()) { ObfuscatedFileUtil* sandbox_file_util = sandbox_file_util_.release(); - if (!file_message_loop_->ReleaseSoon(FROM_HERE, sandbox_file_util)) + if (!file_task_runner_->ReleaseSoon(FROM_HERE, sandbox_file_util)) sandbox_file_util->Release(); } } @@ -348,7 +347,7 @@ void SandboxMountPointProvider::ValidateFileSystemRoot( } base::PlatformFileError* error_ptr = new base::PlatformFileError; - file_message_loop_->PostTaskAndReply( + file_task_runner_->PostTaskAndReply( FROM_HERE, base::Bind(&ValidateRootOnFileThread, sandbox_file_util_, @@ -429,17 +428,15 @@ SandboxMountPointProvider::CreateFileSystemOperation( const GURL& origin_url, FileSystemType file_system_type, const FilePath& virtual_path, - base::MessageLoopProxy* file_proxy, FileSystemContext* context) const { - return new FileSystemOperation(file_proxy, context); + return new FileSystemOperation(context); } webkit_blob::FileReader* SandboxMountPointProvider::CreateFileReader( const GURL& url, int64 offset, - base::MessageLoopProxy* file_proxy, FileSystemContext* context) const { - return new FileSystemFileReader(file_proxy, context, url, offset); + return new FileSystemFileReader(context, url, offset); } FilePath SandboxMountPointProvider::old_base_path() const { diff --git a/webkit/fileapi/sandbox_mount_point_provider.h b/webkit/fileapi/sandbox_mount_point_provider.h index c92cda2..8841089 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.h +++ b/webkit/fileapi/sandbox_mount_point_provider.h @@ -17,7 +17,7 @@ #include "webkit/fileapi/file_system_quota_util.h" namespace base { -class MessageLoopProxy; +class SequencedTaskRunner; } namespace quota { @@ -61,8 +61,10 @@ class SandboxMountPointProvider // Where we move the old filesystem directory if migration fails. static const FilePath::CharType kRenamedOldFileSystemDirectory[]; + // |file_task_runner| is used to validate the root directory and delete the + // obfuscated file util. SandboxMountPointProvider( - scoped_refptr<base::MessageLoopProxy> file_message_loop, + base::SequencedTaskRunner* file_task_runner, const FilePath& profile_path, const FileSystemOptions& file_system_options); virtual ~SandboxMountPointProvider(); @@ -91,12 +93,10 @@ class SandboxMountPointProvider const GURL& origin_url, FileSystemType file_system_type, const FilePath& virtual_path, - base::MessageLoopProxy* file_proxy, FileSystemContext* context) const OVERRIDE; virtual webkit_blob::FileReader* CreateFileReader( const GURL& url, int64 offset, - base::MessageLoopProxy* file_proxy, FileSystemContext* context) const OVERRIDE; FilePath old_base_path() const; @@ -173,7 +173,7 @@ class SandboxMountPointProvider friend class SandboxMountPointProviderMigrationTest; friend class SandboxMountPointProviderOriginEnumeratorTest; - scoped_refptr<base::MessageLoopProxy> file_message_loop_; + scoped_refptr<base::SequencedTaskRunner> file_task_runner_; const FilePath profile_path_; diff --git a/webkit/quota/mock_quota_manager.cc b/webkit/quota/mock_quota_manager.cc index 595c43a..535fb65 100644 --- a/webkit/quota/mock_quota_manager.cc +++ b/webkit/quota/mock_quota_manager.cc @@ -10,11 +10,8 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "base/single_thread_task_runner.h" #include "googleurl/src/gurl.h" -#include "webkit/quota/quota_client.h" -#include "webkit/quota/quota_manager.h" -#include "webkit/quota/quota_task.h" -#include "webkit/quota/quota_types.h" namespace quota { @@ -24,7 +21,7 @@ class MockQuotaManager::GetModifiedSinceTask : public QuotaThreadTask { const std::set<GURL>& origins, StorageType type, const GetOriginsCallback& callback) - : QuotaThreadTask(manager, manager->io_thread_), + : QuotaThreadTask(manager, manager->io_thread_.get()), origins_(origins), type_(type), callback_(callback) { @@ -96,8 +93,8 @@ MockQuotaManager::OriginInfo::~OriginInfo() {} MockQuotaManager::MockQuotaManager( bool is_incognito, const FilePath& profile_path, - base::MessageLoopProxy* io_thread, - base::MessageLoopProxy* db_thread, + base::SingleThreadTaskRunner* io_thread, + base::SequencedTaskRunner* db_thread, SpecialStoragePolicy* special_storage_policy) : QuotaManager(is_incognito, profile_path, io_thread, db_thread, special_storage_policy) { diff --git a/webkit/quota/mock_quota_manager.h b/webkit/quota/mock_quota_manager.h index dac1eff..92b9273 100644 --- a/webkit/quota/mock_quota_manager.h +++ b/webkit/quota/mock_quota_manager.h @@ -43,8 +43,8 @@ class MockQuotaManager : public QuotaManager { MockQuotaManager(bool is_incognito, const FilePath& profile_path, - base::MessageLoopProxy* io_thread, - base::MessageLoopProxy* db_thread, + base::SingleThreadTaskRunner* io_thread, + base::SequencedTaskRunner* db_thread, SpecialStoragePolicy* special_storage_policy); // Adds an origin to the canned list that will be searched through via diff --git a/webkit/quota/quota_manager.cc b/webkit/quota/quota_manager.cc index 031aa9d..7d4669f 100644 --- a/webkit/quota/quota_manager.cc +++ b/webkit/quota/quota_manager.cc @@ -12,7 +12,8 @@ #include "base/callback.h" #include "base/command_line.h" #include "base/file_path.h" -#include "base/message_loop_proxy.h" +#include "base/sequenced_task_runner.h" +#include "base/single_thread_task_runner.h" #include "base/metrics/histogram.h" #include "base/string_number_conversions.h" #include "base/sys_info.h" @@ -1181,8 +1182,8 @@ class QuotaManager::DumpOriginInfoTableTask QuotaManager::QuotaManager(bool is_incognito, const FilePath& profile_path, - base::MessageLoopProxy* io_thread, - base::MessageLoopProxy* db_thread, + base::SingleThreadTaskRunner* io_thread, + base::SequencedTaskRunner* db_thread, SpecialStoragePolicy* special_storage_policy) : is_incognito_(is_incognito), profile_path_(profile_path), @@ -1823,7 +1824,7 @@ QuotaManager* QuotaManagerProxy::quota_manager() const { } QuotaManagerProxy::QuotaManagerProxy( - QuotaManager* manager, base::MessageLoopProxy* io_thread) + QuotaManager* manager, base::SingleThreadTaskRunner* io_thread) : manager_(manager), io_thread_(io_thread) { } diff --git a/webkit/quota/quota_manager.h b/webkit/quota/quota_manager.h index b86cbfd..1566177 100644 --- a/webkit/quota/quota_manager.h +++ b/webkit/quota/quota_manager.h @@ -18,12 +18,12 @@ #include "base/callback.h" #include "base/file_path.h" #include "base/memory/ref_counted.h" -#include "base/memory/weak_ptr.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/memory/weak_ptr.h" #include "base/sequenced_task_runner_helpers.h" -#include "webkit/quota/quota_database.h" #include "webkit/quota/quota_client.h" +#include "webkit/quota/quota_database.h" #include "webkit/quota/quota_task.h" #include "webkit/quota/quota_types.h" #include "webkit/quota/special_storage_policy.h" @@ -31,7 +31,8 @@ class FilePath; namespace base { -class MessageLoopProxy; +class SequencedTaskRunner; +class SingleThreadTaskRunner; } namespace quota_internals { @@ -106,8 +107,8 @@ class QuotaManager : public QuotaTaskObserver, QuotaManager(bool is_incognito, const FilePath& profile_path, - base::MessageLoopProxy* io_thread, - base::MessageLoopProxy* db_thread, + base::SingleThreadTaskRunner* io_thread, + base::SequencedTaskRunner* db_thread, SpecialStoragePolicy* special_storage_policy); // Returns a proxy object that can be used on any thread. @@ -352,8 +353,8 @@ class QuotaManager : public QuotaTaskObserver, scoped_refptr<QuotaManagerProxy> proxy_; bool db_disabled_; bool eviction_disabled_; - scoped_refptr<base::MessageLoopProxy> io_thread_; - scoped_refptr<base::MessageLoopProxy> db_thread_; + scoped_refptr<base::SingleThreadTaskRunner> io_thread_; + scoped_refptr<base::SequencedTaskRunner> db_thread_; mutable scoped_ptr<QuotaDatabase> database_; GetLRUOriginCallback lru_origin_callback_; @@ -418,11 +419,12 @@ class QuotaManagerProxy friend class QuotaManager; friend class base::RefCountedThreadSafe<QuotaManagerProxy>; - QuotaManagerProxy(QuotaManager* manager, base::MessageLoopProxy* io_thread); + QuotaManagerProxy(QuotaManager* manager, + base::SingleThreadTaskRunner* io_thread); virtual ~QuotaManagerProxy(); QuotaManager* manager_; // only accessed on the io thread - scoped_refptr<base::MessageLoopProxy> io_thread_; + scoped_refptr<base::SingleThreadTaskRunner> io_thread_; DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); }; diff --git a/webkit/quota/quota_task.cc b/webkit/quota/quota_task.cc index 28d275f..27542d7 100644 --- a/webkit/quota/quota_task.cc +++ b/webkit/quota/quota_task.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. @@ -8,10 +8,12 @@ #include <functional> #include "base/bind.h" +#include "base/location.h" #include "base/message_loop.h" #include "base/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" -using base::MessageLoopProxy; +using base::TaskRunner; namespace quota { @@ -28,11 +30,11 @@ void QuotaTask::Start() { QuotaTask::QuotaTask(QuotaTaskObserver* observer) : observer_(observer), - original_message_loop_(MessageLoopProxy::current()) { + original_task_runner_(base::MessageLoopProxy::current()) { } void QuotaTask::CallCompleted() { - DCHECK(original_message_loop_->BelongsToCurrentThread()); + DCHECK(original_task_runner_->BelongsToCurrentThread()); if (observer_) { observer_->UnregisterTask(this); Completed(); @@ -40,7 +42,7 @@ void QuotaTask::CallCompleted() { } void QuotaTask::Abort() { - DCHECK(original_message_loop_->BelongsToCurrentThread()); + DCHECK(original_task_runner_->BelongsToCurrentThread()); observer_ = NULL; Aborted(); } @@ -53,24 +55,24 @@ void QuotaTask::DeleteSoon() { QuotaThreadTask::QuotaThreadTask( QuotaTaskObserver* observer, - scoped_refptr<MessageLoopProxy> target_message_loop) + TaskRunner* target_task_runner) : QuotaTask(observer), - target_message_loop_(target_message_loop) { + target_task_runner_(target_task_runner) { } QuotaThreadTask::~QuotaThreadTask() { } void QuotaThreadTask::Run() { - target_message_loop_->PostTask( + target_task_runner_->PostTask( FROM_HERE, base::Bind(&QuotaThreadTask::CallRunOnTargetThread, this)); } void QuotaThreadTask::CallRunOnTargetThread() { - DCHECK(target_message_loop_->BelongsToCurrentThread()); + DCHECK(target_task_runner_->RunsTasksOnCurrentThread()); if (RunOnTargetThreadAsync()) - original_message_loop()->PostTask( + original_task_runner()->PostTask( FROM_HERE, base::Bind(&QuotaThreadTask::CallCompleted, this)); } diff --git a/webkit/quota/quota_task.h b/webkit/quota/quota_task.h index dbd5ca04..ae9b2f1 100644 --- a/webkit/quota/quota_task.h +++ b/webkit/quota/quota_task.h @@ -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. @@ -11,17 +11,19 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" -#include "base/message_loop_proxy.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; +class TaskRunner; } namespace quota { class QuotaTaskObserver; +class QuotaThreadTask; // A base class for quota tasks. +// TODO(kinuko): Revise this using base::Callback. class QuotaTask { public: virtual ~QuotaTask(); @@ -45,15 +47,16 @@ class QuotaTask { void DeleteSoon(); QuotaTaskObserver* observer() const { return observer_; } - scoped_refptr<base::MessageLoopProxy> original_message_loop() const { - return original_message_loop_; + base::SingleThreadTaskRunner* original_task_runner() const { + return original_task_runner_; } private: friend class QuotaTaskObserver; + friend class QuotaThreadTask; void Abort(); QuotaTaskObserver* observer_; - scoped_refptr<base::MessageLoopProxy> original_message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> original_task_runner_; }; // For tasks that post tasks to the other thread. @@ -61,7 +64,7 @@ class QuotaThreadTask : public QuotaTask, public base::RefCountedThreadSafe<QuotaThreadTask> { public: QuotaThreadTask(QuotaTaskObserver* observer, - scoped_refptr<base::MessageLoopProxy> target_message_loop); + base::TaskRunner* target_task_runner); protected: virtual ~QuotaThreadTask(); @@ -80,8 +83,8 @@ class QuotaThreadTask : public QuotaTask, virtual bool RunOnTargetThreadAsync(); virtual void Run() OVERRIDE; - scoped_refptr<base::MessageLoopProxy> target_message_loop() const { - return target_message_loop_; + base::TaskRunner* target_task_runner() const { + return target_task_runner_; } private: @@ -89,7 +92,7 @@ class QuotaThreadTask : public QuotaTask, friend class QuotaTaskObserver; void CallRunOnTargetThread(); - scoped_refptr<base::MessageLoopProxy> target_message_loop_; + scoped_refptr<base::TaskRunner> target_task_runner_; }; class QuotaTaskObserver { diff --git a/webkit/quota/usage_tracker.cc b/webkit/quota/usage_tracker.cc index 0eb2411..0b22e70 100644 --- a/webkit/quota/usage_tracker.cc +++ b/webkit/quota/usage_tracker.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. @@ -43,7 +43,7 @@ class ClientUsageTracker::GatherUsageTaskBase : public QuotaTask { // Get total usage for the given |origins|. void GetUsageForOrigins(const std::set<GURL>& origins, StorageType type) { - DCHECK(original_message_loop()->BelongsToCurrentThread()); + DCHECK(original_task_runner()->BelongsToCurrentThread()); // We do not get usage for origins for which we have valid usage cache. std::vector<GURL> origins_to_gather; std::set<GURL> cached_origins; @@ -91,7 +91,7 @@ class ClientUsageTracker::GatherUsageTaskBase : public QuotaTask { private: void DidGetUsage(int64 usage) { - DCHECK(original_message_loop()->BelongsToCurrentThread()); + DCHECK(original_task_runner()->BelongsToCurrentThread()); DCHECK(!pending_origins_.empty()); DCHECK(client_tracker_); diff --git a/webkit/tools/test_shell/simple_file_system.cc b/webkit/tools/test_shell/simple_file_system.cc index db698eb..d653a08 100644 --- a/webkit/tools/test_shell/simple_file_system.cc +++ b/webkit/tools/test_shell/simple_file_system.cc @@ -199,9 +199,7 @@ void SimpleFileSystem::CleanupOnIOThread() { FileSystemOperationInterface* SimpleFileSystem::GetNewOperation( const WebURL& url) { - return file_system_context_->CreateFileSystemOperation( - GURL(url), - base::MessageLoopProxy::current()); + return file_system_context_->CreateFileSystemOperation(GURL(url)); } FileSystemOperationInterface::StatusCallback diff --git a/webkit/tools/test_shell/simple_file_writer.cc b/webkit/tools/test_shell/simple_file_writer.cc index 6689bf1..9153edf 100644 --- a/webkit/tools/test_shell/simple_file_writer.cc +++ b/webkit/tools/test_shell/simple_file_writer.cc @@ -86,7 +86,7 @@ class SimpleFileWriter::IOThreadProxy virtual ~IOThreadProxy() {} FileSystemOperationInterface* GetNewOperation(const GURL& path) { - return file_system_context_->CreateFileSystemOperation(path, io_thread_); + return file_system_context_->CreateFileSystemOperation(path); } void DidSucceedOnMainThread() { diff --git a/webkit/tools/test_shell/test_shell_request_context.cc b/webkit/tools/test_shell/test_shell_request_context.cc index 71c46fc..a284479 100644 --- a/webkit/tools/test_shell/test_shell_request_context.cc +++ b/webkit/tools/test_shell/test_shell_request_context.cc @@ -127,9 +127,7 @@ void TestShellRequestContext::Init( SimpleResourceLoaderBridge::GetIoThread())); job_factory->SetProtocolHandler( "filesystem", - fileapi::CreateFileSystemProtocolHandler( - file_system_context_.get(), - SimpleResourceLoaderBridge::GetIoThread())); + fileapi::CreateFileSystemProtocolHandler(file_system_context_.get())); storage_.set_job_factory(job_factory); } |