diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 01:12:12 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 01:12:12 +0000 |
commit | b7b82eb3dce4220e592472d0f9220280d1246243 (patch) | |
tree | 2fa55d5d932949d4a313ca3b7d8ed39fc9c81d11 /webkit/fileapi | |
parent | a097393e6e0f08f521c977677bed01a0ad01120b (diff) | |
download | chromium_src-b7b82eb3dce4220e592472d0f9220280d1246243.zip chromium_src-b7b82eb3dce4220e592472d0f9220280d1246243.tar.gz chromium_src-b7b82eb3dce4220e592472d0f9220280d1246243.tar.bz2 |
Remove BrowserFileSystemContext class and merge it into SandboxedFileSystemContext
BUG=60243
TEST=none
Review URL: http://codereview.chromium.org/5633008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r-- | webkit/fileapi/sandboxed_file_system_context.cc | 21 | ||||
-rw-r--r-- | webkit/fileapi/sandboxed_file_system_context.h | 16 | ||||
-rw-r--r-- | webkit/fileapi/sandboxed_file_system_operation.cc | 2 | ||||
-rw-r--r-- | webkit/fileapi/sandboxed_file_system_operation.h | 15 |
4 files changed, 42 insertions, 12 deletions
diff --git a/webkit/fileapi/sandboxed_file_system_context.cc b/webkit/fileapi/sandboxed_file_system_context.cc index b3b009e..16232d5 100644 --- a/webkit/fileapi/sandboxed_file_system_context.cc +++ b/webkit/fileapi/sandboxed_file_system_context.cc @@ -13,11 +13,13 @@ namespace fileapi { SandboxedFileSystemContext::SandboxedFileSystemContext( scoped_refptr<base::MessageLoopProxy> file_message_loop, + scoped_refptr<base::MessageLoopProxy> io_message_loop, const FilePath& profile_path, bool is_incognito, bool allow_file_access, bool unlimited_quota) : file_message_loop_(file_message_loop), + io_message_loop_(io_message_loop), path_manager_(new FileSystemPathManager( file_message_loop, profile_path, is_incognito, allow_file_access)), quota_manager_(new FileSystemQuotaManager( @@ -28,6 +30,7 @@ SandboxedFileSystemContext::~SandboxedFileSystemContext() { } void SandboxedFileSystemContext::Shutdown() { + DCHECK(io_message_loop_->BelongsToCurrentThread()); path_manager_.reset(); quota_manager_.reset(); } @@ -45,4 +48,22 @@ void SandboxedFileSystemContext::DeleteDataForOriginOnFileThread( file_util::Delete(path_for_origin, true /* recursive */); } +void SandboxedFileSystemContext::SetOriginQuotaUnlimited(const GURL& url) { + DCHECK(io_message_loop_->BelongsToCurrentThread()); + quota_manager()->SetOriginQuotaUnlimited(url); +} + +void SandboxedFileSystemContext::ResetOriginQuotaUnlimited(const GURL& url) { + DCHECK(io_message_loop_->BelongsToCurrentThread()); + quota_manager()->ResetOriginQuotaUnlimited(url); +} + +void SandboxedFileSystemContext::DeleteOnCorrectThread() const { + if (!io_message_loop_->BelongsToCurrentThread()) { + io_message_loop_->DeleteSoon(FROM_HERE, this); + return; + } + delete this; +} + } // namespace fileapi diff --git a/webkit/fileapi/sandboxed_file_system_context.h b/webkit/fileapi/sandboxed_file_system_context.h index 6c72bc0..fcb90bb 100644 --- a/webkit/fileapi/sandboxed_file_system_context.h +++ b/webkit/fileapi/sandboxed_file_system_context.h @@ -24,10 +24,13 @@ class SandboxedFileSystemContext; struct DefaultContextDeleter; // This class keeps and provides a sandboxed file system context. -class SandboxedFileSystemContext { +class SandboxedFileSystemContext + : public base::RefCountedThreadSafe<SandboxedFileSystemContext, + DefaultContextDeleter> { public: SandboxedFileSystemContext( scoped_refptr<base::MessageLoopProxy> file_message_loop, + scoped_refptr<base::MessageLoopProxy> io_message_loop, const FilePath& profile_path, bool is_incognito, bool allow_file_access_from_files, @@ -38,6 +41,10 @@ class SandboxedFileSystemContext { void DeleteDataForOriginOnFileThread(const GURL& origin_url); + // Quota related methods. + void SetOriginQuotaUnlimited(const GURL& url); + void ResetOriginQuotaUnlimited(const GURL& url); + FileSystemPathManager* path_manager() { return path_manager_.get(); } FileSystemQuotaManager* quota_manager() { return quota_manager_.get(); } @@ -47,12 +54,19 @@ class SandboxedFileSystemContext { bool allow_file_access_from_files_; scoped_refptr<base::MessageLoopProxy> file_message_loop_; + scoped_refptr<base::MessageLoopProxy> io_message_loop_; scoped_ptr<FileSystemPathManager> path_manager_; scoped_ptr<FileSystemQuotaManager> quota_manager_; DISALLOW_IMPLICIT_CONSTRUCTORS(SandboxedFileSystemContext); }; +struct DefaultContextDeleter { + static void Destruct(const SandboxedFileSystemContext* context) { + context->DeleteOnCorrectThread(); + } +}; + } // namespace fileapi #endif // WEBKIT_FILEAPI_SANDBOXED_FILE_SYSTEM_CONTEXT_H_ diff --git a/webkit/fileapi/sandboxed_file_system_operation.cc b/webkit/fileapi/sandboxed_file_system_operation.cc index ef7c752..d866512 100644 --- a/webkit/fileapi/sandboxed_file_system_operation.cc +++ b/webkit/fileapi/sandboxed_file_system_operation.cc @@ -15,7 +15,7 @@ namespace fileapi { SandboxedFileSystemOperation::SandboxedFileSystemOperation( FileSystemCallbackDispatcher* dispatcher, scoped_refptr<base::MessageLoopProxy> proxy, - SandboxedFileSystemContext* file_system_context) + scoped_refptr<SandboxedFileSystemContext> file_system_context) : FileSystemOperation(dispatcher, proxy), file_system_context_(file_system_context), callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { diff --git a/webkit/fileapi/sandboxed_file_system_operation.h b/webkit/fileapi/sandboxed_file_system_operation.h index c6c905d..d3e1ce9 100644 --- a/webkit/fileapi/sandboxed_file_system_operation.h +++ b/webkit/fileapi/sandboxed_file_system_operation.h @@ -21,14 +21,10 @@ class SandboxedFileSystemContext; // via |file_system_context|. class SandboxedFileSystemOperation : public FileSystemOperation { public: - // This class doesn't hold a reference or ownership of |file_system_context|. - // It is the caller's responsibility to keep the pointer alive *until* - // it calls any of the operation methods. The |file_system_context| won't be - // used in the callback path and can be deleted after the operation is - // made (e.g. after one of CreateFile, CreateDirectory, Copy, etc is called). - SandboxedFileSystemOperation(FileSystemCallbackDispatcher* dispatcher, - scoped_refptr<base::MessageLoopProxy> proxy, - SandboxedFileSystemContext* file_system_context); + SandboxedFileSystemOperation( + FileSystemCallbackDispatcher* dispatcher, + scoped_refptr<base::MessageLoopProxy> proxy, + scoped_refptr<SandboxedFileSystemContext> file_system_context); virtual ~SandboxedFileSystemOperation(); void OpenFileSystem(const GURL& origin_url, @@ -94,8 +90,7 @@ class SandboxedFileSystemOperation : public FileSystemOperation { bool create, int64 growth); - // Not owned. See the comment at the constructor. - SandboxedFileSystemContext* file_system_context_; + scoped_refptr<SandboxedFileSystemContext> file_system_context_; base::ScopedCallbackFactory<SandboxedFileSystemOperation> callback_factory_; |