diff options
author | nhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-15 05:55:37 +0000 |
---|---|---|
committer | nhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-15 05:55:37 +0000 |
commit | 639772fec6025dda6ba1ab666ae559090ee1d6a6 (patch) | |
tree | 8a9a292485ff36f6ec257af0ce1595508096b5b0 /webkit | |
parent | 006596501f624caf602ff6c117266fbadbaf5512 (diff) | |
download | chromium_src-639772fec6025dda6ba1ab666ae559090ee1d6a6.zip chromium_src-639772fec6025dda6ba1ab666ae559090ee1d6a6.tar.gz chromium_src-639772fec6025dda6ba1ab666ae559090ee1d6a6.tar.bz2 |
FileAPI: Rename SandboxContext to SandboxFileSystemBackendDelegate
BUG=272078
TEST=n/a (renaming only)
TBR=jochen
Review URL: https://chromiumcodereview.appspot.com/23167002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217752 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/browser/fileapi/file_system_context.cc | 4 | ||||
-rw-r--r-- | webkit/browser/fileapi/file_system_context.h | 8 | ||||
-rw-r--r-- | webkit/browser/fileapi/obfuscated_file_util.cc | 4 | ||||
-rw-r--r-- | webkit/browser/fileapi/sandbox_file_system_backend.cc | 60 | ||||
-rw-r--r-- | webkit/browser/fileapi/sandbox_file_system_backend.h | 8 | ||||
-rw-r--r-- | webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc (renamed from webkit/browser/fileapi/sandbox_context.cc) | 66 | ||||
-rw-r--r-- | webkit/browser/fileapi/sandbox_file_system_backend_delegate.h (renamed from webkit/browser/fileapi/sandbox_context.h) | 18 | ||||
-rw-r--r-- | webkit/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc (renamed from webkit/browser/fileapi/sandbox_context_unittest.cc) | 36 | ||||
-rw-r--r-- | webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc | 28 | ||||
-rw-r--r-- | webkit/browser/fileapi/sandbox_file_system_test_helper.cc | 10 | ||||
-rw-r--r-- | webkit/browser/fileapi/sandbox_quota_observer.cc | 4 | ||||
-rw-r--r-- | webkit/storage_browser.gyp | 4 |
12 files changed, 132 insertions, 118 deletions
diff --git a/webkit/browser/fileapi/file_system_context.cc b/webkit/browser/fileapi/file_system_context.cc index d43ba8a..f2973d3 100644 --- a/webkit/browser/fileapi/file_system_context.cc +++ b/webkit/browser/fileapi/file_system_context.cc @@ -108,14 +108,14 @@ FileSystemContext::FileSystemContext( : io_task_runner_(io_task_runner), default_file_task_runner_(file_task_runner), quota_manager_proxy_(quota_manager_proxy), - sandbox_context_(new SandboxContext( + sandbox_delegate_(new SandboxFileSystemBackendDelegate( quota_manager_proxy, file_task_runner, partition_path, special_storage_policy, options)), sandbox_backend_(new SandboxFileSystemBackend( - sandbox_context_.get())), + sandbox_delegate_.get())), isolated_backend_(new IsolatedFileSystemBackend()), additional_backends_(additional_backends.Pass()), external_mount_points_(external_mount_points), diff --git a/webkit/browser/fileapi/file_system_context.h b/webkit/browser/fileapi/file_system_context.h index d6934ec..528f7a2 100644 --- a/webkit/browser/fileapi/file_system_context.h +++ b/webkit/browser/fileapi/file_system_context.h @@ -17,7 +17,7 @@ #include "base/sequenced_task_runner_helpers.h" #include "webkit/browser/fileapi/file_system_url.h" #include "webkit/browser/fileapi/open_file_system_mode.h" -#include "webkit/browser/fileapi/sandbox_context.h" +#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" #include "webkit/browser/webkit_storage_browser_export.h" #include "webkit/common/fileapi/file_system_types.h" @@ -228,7 +228,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext void EnableTemporaryFileSystemInIncognito(); #endif - SandboxContext* sandbox_context() { return sandbox_context_.get(); } + SandboxFileSystemBackendDelegate* sandbox_delegate() { + return sandbox_delegate_.get(); + } private: typedef std::map<FileSystemType, FileSystemBackend*> @@ -283,7 +285,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; - scoped_ptr<SandboxContext> sandbox_context_; + scoped_ptr<SandboxFileSystemBackendDelegate> sandbox_delegate_; // Regular file system backends. scoped_ptr<SandboxFileSystemBackend> sandbox_backend_; diff --git a/webkit/browser/fileapi/obfuscated_file_util.cc b/webkit/browser/fileapi/obfuscated_file_util.cc index da63085..7e2f7df 100644 --- a/webkit/browser/fileapi/obfuscated_file_util.cc +++ b/webkit/browser/fileapi/obfuscated_file_util.cc @@ -276,7 +276,7 @@ PlatformFileError ObfuscatedFileUtil::CreateOrOpen( file_flags & base::PLATFORM_FILE_WRITE && context->quota_limit_type() == quota::kQuotaLimitTypeUnlimited) { DCHECK_EQ(base::PLATFORM_FILE_OK, error); - context->file_system_context()->sandbox_context()-> + context->file_system_context()->sandbox_delegate()-> StickyInvalidateUsageCache(url.origin(), url.type()); } return error; @@ -1261,7 +1261,7 @@ void ObfuscatedFileUtil::InvalidateUsageCache( FileSystemOperationContext* context, const GURL& origin, FileSystemType type) { - context->file_system_context()->sandbox_context()-> + context->file_system_context()->sandbox_delegate()-> InvalidateUsageCache(origin, type); } diff --git a/webkit/browser/fileapi/sandbox_file_system_backend.cc b/webkit/browser/fileapi/sandbox_file_system_backend.cc index 6ce4a9e..665c0f1 100644 --- a/webkit/browser/fileapi/sandbox_file_system_backend.cc +++ b/webkit/browser/fileapi/sandbox_file_system_backend.cc @@ -19,8 +19,8 @@ #include "webkit/browser/fileapi/file_system_options.h" #include "webkit/browser/fileapi/file_system_usage_cache.h" #include "webkit/browser/fileapi/obfuscated_file_util.h" -#include "webkit/browser/fileapi/sandbox_context.h" #include "webkit/browser/fileapi/sandbox_file_stream_writer.h" +#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" #include "webkit/browser/fileapi/sandbox_quota_observer.h" #include "webkit/browser/quota/quota_manager.h" #include "webkit/common/fileapi/file_system_types.h" @@ -39,8 +39,8 @@ const char kPersistentOriginsCountLabel[] = "FileSystem.PersistentOriginsCount"; } // anonymous namespace SandboxFileSystemBackend::SandboxFileSystemBackend( - SandboxContext* sandbox_context) - : sandbox_context_(sandbox_context), + SandboxFileSystemBackendDelegate* delegate) + : delegate_(delegate), enable_temporary_file_system_in_incognito_(false) { } @@ -55,10 +55,10 @@ bool SandboxFileSystemBackend::CanHandleType(FileSystemType type) const { void SandboxFileSystemBackend::Initialize(FileSystemContext* context) { // Set quota observers. update_observers_ = update_observers_.AddObserver( - sandbox_context_->quota_observer(), - sandbox_context_->file_task_runner()); + delegate_->quota_observer(), + delegate_->file_task_runner()); access_observers_ = access_observers_.AddObserver( - sandbox_context_->quota_observer(), NULL); + delegate_->quota_observer(), NULL); } void SandboxFileSystemBackend::OpenFileSystem( @@ -67,8 +67,8 @@ void SandboxFileSystemBackend::OpenFileSystem( OpenFileSystemMode mode, const OpenFileSystemCallback& callback) { DCHECK(CanHandleType(type)); - DCHECK(sandbox_context_); - if (sandbox_context_->file_system_options().is_incognito() && + DCHECK(delegate_); + if (delegate_->file_system_options().is_incognito() && !(type == kFileSystemTypeTemporary && enable_temporary_file_system_in_incognito_)) { // TODO(kinuko): return an isolated temporary directory. @@ -76,20 +76,20 @@ void SandboxFileSystemBackend::OpenFileSystem( return; } - sandbox_context_->OpenFileSystem( + delegate_->OpenFileSystem( origin_url, type, mode, callback, GetFileSystemRootURI(origin_url, type)); } FileSystemFileUtil* SandboxFileSystemBackend::GetFileUtil( FileSystemType type) { - return sandbox_context_->sync_file_util(); + return delegate_->sync_file_util(); } AsyncFileUtil* SandboxFileSystemBackend::GetAsyncFileUtil( FileSystemType type) { - DCHECK(sandbox_context_); - return sandbox_context_->file_util(); + DCHECK(delegate_); + return delegate_->file_util(); } CopyOrMoveFileValidatorFactory* @@ -106,8 +106,8 @@ FileSystemOperation* SandboxFileSystemBackend::CreateFileSystemOperation( FileSystemContext* context, base::PlatformFileError* error_code) const { DCHECK(CanHandleType(url.type())); - DCHECK(sandbox_context_); - if (!sandbox_context_->IsAccessValid(url)) { + DCHECK(delegate_); + if (!delegate_->IsAccessValid(url)) { *error_code = base::PLATFORM_FILE_ERROR_SECURITY; return NULL; } @@ -117,7 +117,7 @@ FileSystemOperation* SandboxFileSystemBackend::CreateFileSystemOperation( operation_context->set_update_observers(update_observers_); operation_context->set_change_observers(change_observers_); - SpecialStoragePolicy* policy = sandbox_context_->special_storage_policy(); + SpecialStoragePolicy* policy = delegate_->special_storage_policy(); if (policy && policy->IsStorageUnlimited(url.origin())) operation_context->set_quota_limit_type(quota::kQuotaLimitTypeUnlimited); else @@ -133,8 +133,8 @@ SandboxFileSystemBackend::CreateFileStreamReader( const base::Time& expected_modification_time, FileSystemContext* context) const { DCHECK(CanHandleType(url.type())); - DCHECK(sandbox_context_); - if (!sandbox_context_->IsAccessValid(url)) + DCHECK(delegate_); + if (!delegate_->IsAccessValid(url)) return scoped_ptr<webkit_blob::FileStreamReader>(); return scoped_ptr<webkit_blob::FileStreamReader>( new FileSystemFileStreamReader( @@ -147,8 +147,8 @@ SandboxFileSystemBackend::CreateFileStreamWriter( int64 offset, FileSystemContext* context) const { DCHECK(CanHandleType(url.type())); - DCHECK(sandbox_context_); - if (!sandbox_context_->IsAccessValid(url)) + DCHECK(delegate_); + if (!delegate_->IsAccessValid(url)) return scoped_ptr<fileapi::FileStreamWriter>(); return scoped_ptr<fileapi::FileStreamWriter>( new SandboxFileStreamWriter(context, url, offset, update_observers_)); @@ -158,10 +158,10 @@ FileSystemQuotaUtil* SandboxFileSystemBackend::GetQuotaUtil() { return this; } -SandboxContext::OriginEnumerator* +SandboxFileSystemBackendDelegate::OriginEnumerator* SandboxFileSystemBackend::CreateOriginEnumerator() { - DCHECK(sandbox_context_); - return sandbox_context_->CreateOriginEnumerator(); + DCHECK(delegate_); + return delegate_->CreateOriginEnumerator(); } base::PlatformFileError @@ -171,16 +171,16 @@ SandboxFileSystemBackend::DeleteOriginDataOnFileThread( const GURL& origin_url, fileapi::FileSystemType type) { DCHECK(CanHandleType(type)); - DCHECK(sandbox_context_); - return sandbox_context_->DeleteOriginDataOnFileThread( + DCHECK(delegate_); + return delegate_->DeleteOriginDataOnFileThread( file_system_context, proxy, origin_url, type); } void SandboxFileSystemBackend::GetOriginsForTypeOnFileThread( fileapi::FileSystemType type, std::set<GURL>* origins) { DCHECK(CanHandleType(type)); - DCHECK(sandbox_context_); - sandbox_context_->GetOriginsForTypeOnFileThread(type, origins); + DCHECK(delegate_); + delegate_->GetOriginsForTypeOnFileThread(type, origins); switch (type) { case kFileSystemTypeTemporary: UMA_HISTOGRAM_COUNTS(kTemporaryOriginsCountLabel, origins->size()); @@ -197,8 +197,8 @@ void SandboxFileSystemBackend::GetOriginsForHostOnFileThread( fileapi::FileSystemType type, const std::string& host, std::set<GURL>* origins) { DCHECK(CanHandleType(type)); - DCHECK(sandbox_context_); - sandbox_context_->GetOriginsForHostOnFileThread(type, host, origins); + DCHECK(delegate_); + delegate_->GetOriginsForHostOnFileThread(type, host, origins); } int64 SandboxFileSystemBackend::GetOriginUsageOnFileThread( @@ -206,8 +206,8 @@ int64 SandboxFileSystemBackend::GetOriginUsageOnFileThread( const GURL& origin_url, fileapi::FileSystemType type) { DCHECK(CanHandleType(type)); - DCHECK(sandbox_context_); - return sandbox_context_->GetOriginUsageOnFileThread( + DCHECK(delegate_); + return delegate_->GetOriginUsageOnFileThread( file_system_context, origin_url, type); } diff --git a/webkit/browser/fileapi/sandbox_file_system_backend.h b/webkit/browser/fileapi/sandbox_file_system_backend.h index dec289b..a1a5686 100644 --- a/webkit/browser/fileapi/sandbox_file_system_backend.h +++ b/webkit/browser/fileapi/sandbox_file_system_backend.h @@ -14,7 +14,7 @@ #include "base/memory/scoped_ptr.h" #include "webkit/browser/fileapi/file_system_backend.h" #include "webkit/browser/fileapi/file_system_quota_util.h" -#include "webkit/browser/fileapi/sandbox_context.h" +#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" #include "webkit/browser/fileapi/task_runner_bound_observer_list.h" #include "webkit/browser/quota/special_storage_policy.h" #include "webkit/browser/webkit_storage_browser_export.h" @@ -30,7 +30,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend : public FileSystemBackend, public FileSystemQuotaUtil { public: - explicit SandboxFileSystemBackend(SandboxContext* sandbox_context); + explicit SandboxFileSystemBackend(SandboxFileSystemBackendDelegate* delegate); virtual ~SandboxFileSystemBackend(); // FileSystemBackend overrides. @@ -63,7 +63,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend // Returns an origin enumerator of this backend. // This method can only be called on the file thread. - SandboxContext::OriginEnumerator* CreateOriginEnumerator(); + SandboxFileSystemBackendDelegate::OriginEnumerator* CreateOriginEnumerator(); // FileSystemQuotaUtil overrides. virtual base::PlatformFileError DeleteOriginDataOnFileThread( @@ -106,7 +106,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend } private: - SandboxContext* sandbox_context_; // Not owned. + SandboxFileSystemBackendDelegate* delegate_; // Not owned. bool enable_temporary_file_system_in_incognito_; diff --git a/webkit/browser/fileapi/sandbox_context.cc b/webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc index 6217657..0a6034e 100644 --- a/webkit/browser/fileapi/sandbox_context.cc +++ b/webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "webkit/browser/fileapi/sandbox_context.h" +#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" #include "base/command_line.h" #include "base/file_util.h" @@ -53,7 +53,7 @@ const base::FilePath::CharType kRestrictedChars[] = { }; class ObfuscatedOriginEnumerator - : public SandboxContext::OriginEnumerator { + : public SandboxFileSystemBackendDelegate::OriginEnumerator { public: explicit ObfuscatedOriginEnumerator(ObfuscatedFileUtil* file_util) { enum_.reset(file_util->CreateOriginEnumerator()); @@ -94,20 +94,21 @@ void OpenFileSystemOnFileThread( } void DidOpenFileSystem( - base::WeakPtr<SandboxContext> sandbox_context, + base::WeakPtr<SandboxFileSystemBackendDelegate> delegate, const base::Callback<void(base::PlatformFileError error)>& callback, base::PlatformFileError* error) { - if (sandbox_context.get()) - sandbox_context.get()->CollectOpenFileSystemMetrics(*error); + if (delegate.get()) + delegate.get()->CollectOpenFileSystemMetrics(*error); callback.Run(*error); } } // namespace const base::FilePath::CharType -SandboxContext::kFileSystemDirectory[] = FILE_PATH_LITERAL("File System"); +SandboxFileSystemBackendDelegate::kFileSystemDirectory[] = + FILE_PATH_LITERAL("File System"); -SandboxContext::SandboxContext( +SandboxFileSystemBackendDelegate::SandboxFileSystemBackendDelegate( quota::QuotaManagerProxy* quota_manager_proxy, base::SequencedTaskRunner* file_task_runner, const base::FilePath& profile_path, @@ -130,7 +131,7 @@ SandboxContext::SandboxContext( weak_factory_(this) { } -SandboxContext::~SandboxContext() { +SandboxFileSystemBackendDelegate::~SandboxFileSystemBackendDelegate() { if (!file_task_runner_->RunsTasksOnCurrentThread()) { AsyncFileUtil* sandbox_file_util = sandbox_file_util_.release(); SandboxQuotaObserver* quota_observer = quota_observer_.release(); @@ -145,7 +146,8 @@ SandboxContext::~SandboxContext() { } } -bool SandboxContext::IsAccessValid(const FileSystemURL& url) const { +bool SandboxFileSystemBackendDelegate::IsAccessValid( + const FileSystemURL& url) const { if (!IsAllowedScheme(url.origin())) return false; @@ -176,7 +178,7 @@ bool SandboxContext::IsAccessValid(const FileSystemURL& url) const { return true; } -bool SandboxContext::IsAllowedScheme(const GURL& url) const { +bool SandboxFileSystemBackendDelegate::IsAllowedScheme(const GURL& url) const { // Basically we only accept http or https. We allow file:// URLs // only if --allow-file-access-from-files flag is given. if (url.SchemeIs("http") || url.SchemeIs("https")) @@ -194,12 +196,16 @@ bool SandboxContext::IsAllowedScheme(const GURL& url) const { return false; } -SandboxContext::OriginEnumerator* SandboxContext::CreateOriginEnumerator() { +SandboxFileSystemBackendDelegate::OriginEnumerator* +SandboxFileSystemBackendDelegate::CreateOriginEnumerator() { return new ObfuscatedOriginEnumerator(obfuscated_file_util()); } -base::FilePath SandboxContext::GetBaseDirectoryForOriginAndType( - const GURL& origin_url, fileapi::FileSystemType type, bool create) { +base::FilePath +SandboxFileSystemBackendDelegate::GetBaseDirectoryForOriginAndType( + const GURL& origin_url, + fileapi::FileSystemType type, + bool create) { base::PlatformFileError error = base::PLATFORM_FILE_OK; base::FilePath path = obfuscated_file_util()->GetDirectoryForOriginAndType( origin_url, type, create, &error); @@ -208,7 +214,7 @@ base::FilePath SandboxContext::GetBaseDirectoryForOriginAndType( return path; } -void SandboxContext::OpenFileSystem( +void SandboxFileSystemBackendDelegate::OpenFileSystem( const GURL& origin_url, fileapi::FileSystemType type, OpenFileSystemMode mode, @@ -233,7 +239,8 @@ void SandboxContext::OpenFileSystem( base::Owned(error_ptr))); } -base::PlatformFileError SandboxContext::DeleteOriginDataOnFileThread( +base::PlatformFileError +SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileThread( FileSystemContext* file_system_context, quota::QuotaManagerProxy* proxy, const GURL& origin_url, @@ -256,7 +263,7 @@ base::PlatformFileError SandboxContext::DeleteOriginDataOnFileThread( return base::PLATFORM_FILE_ERROR_FAILED; } -void SandboxContext::GetOriginsForTypeOnFileThread( +void SandboxFileSystemBackendDelegate::GetOriginsForTypeOnFileThread( fileapi::FileSystemType type, std::set<GURL>* origins) { DCHECK(origins); scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator()); @@ -267,7 +274,7 @@ void SandboxContext::GetOriginsForTypeOnFileThread( } } -void SandboxContext::GetOriginsForHostOnFileThread( +void SandboxFileSystemBackendDelegate::GetOriginsForHostOnFileThread( fileapi::FileSystemType type, const std::string& host, std::set<GURL>* origins) { DCHECK(origins); @@ -280,7 +287,7 @@ void SandboxContext::GetOriginsForHostOnFileThread( } } -int64 SandboxContext::GetOriginUsageOnFileThread( +int64 SandboxFileSystemBackendDelegate::GetOriginUsageOnFileThread( FileSystemContext* file_system_context, const GURL& origin_url, fileapi::FileSystemType type) { @@ -318,7 +325,7 @@ int64 SandboxContext::GetOriginUsageOnFileThread( return usage; } -void SandboxContext::InvalidateUsageCache( +void SandboxFileSystemBackendDelegate::InvalidateUsageCache( const GURL& origin, fileapi::FileSystemType type) { base::PlatformFileError error = base::PLATFORM_FILE_OK; @@ -329,7 +336,7 @@ void SandboxContext::InvalidateUsageCache( usage_cache()->IncrementDirty(usage_file_path); } -void SandboxContext::StickyInvalidateUsageCache( +void SandboxFileSystemBackendDelegate::StickyInvalidateUsageCache( const GURL& origin, fileapi::FileSystemType type) { sticky_dirty_origins_.insert(std::make_pair(origin, type)); @@ -337,11 +344,12 @@ void SandboxContext::StickyInvalidateUsageCache( InvalidateUsageCache(origin, type); } -FileSystemFileUtil* SandboxContext::sync_file_util() { +FileSystemFileUtil* SandboxFileSystemBackendDelegate::sync_file_util() { return static_cast<AsyncFileUtilAdapter*>(file_util())->sync_file_util(); } -base::FilePath SandboxContext::GetUsageCachePathForOriginAndType( +base::FilePath +SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType( const GURL& origin_url, FileSystemType type) { base::PlatformFileError error; @@ -353,7 +361,8 @@ base::FilePath SandboxContext::GetUsageCachePathForOriginAndType( } // static -base::FilePath SandboxContext::GetUsageCachePathForOriginAndType( +base::FilePath +SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType( ObfuscatedFileUtil* sandbox_file_util, const GURL& origin_url, fileapi::FileSystemType type, @@ -367,9 +376,10 @@ base::FilePath SandboxContext::GetUsageCachePathForOriginAndType( return base_path.Append(FileSystemUsageCache::kUsageFileName); } -int64 SandboxContext::RecalculateUsage(FileSystemContext* context, - const GURL& origin, - FileSystemType type) { +int64 SandboxFileSystemBackendDelegate::RecalculateUsage( + FileSystemContext* context, + const GURL& origin, + FileSystemType type) { FileSystemOperationContext operation_context(context); FileSystemURL url = context->CreateCrackedFileSystemURL( origin, type, base::FilePath()); @@ -388,7 +398,7 @@ int64 SandboxContext::RecalculateUsage(FileSystemContext* context, return usage; } -void SandboxContext::CollectOpenFileSystemMetrics( +void SandboxFileSystemBackendDelegate::CollectOpenFileSystemMetrics( base::PlatformFileError error_code) { base::Time now = base::Time::Now(); bool throttled = now < next_release_time_for_open_filesystem_stat_; @@ -425,7 +435,7 @@ void SandboxContext::CollectOpenFileSystemMetrics( #undef REPORT } -ObfuscatedFileUtil* SandboxContext::obfuscated_file_util() { +ObfuscatedFileUtil* SandboxFileSystemBackendDelegate::obfuscated_file_util() { return static_cast<ObfuscatedFileUtil*>(sync_file_util()); } diff --git a/webkit/browser/fileapi/sandbox_context.h b/webkit/browser/fileapi/sandbox_file_system_backend_delegate.h index 8408d42..5fb83f0 100644 --- a/webkit/browser/fileapi/sandbox_context.h +++ b/webkit/browser/fileapi/sandbox_file_system_backend_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_CONTEXT_H_ -#define WEBKIT_BROWSER_FILEAPI_SANDBOX_CONTEXT_H_ +#ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_ +#define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_ #include <set> #include <string> @@ -39,9 +39,9 @@ class SandboxFileSystemBackend; class SandboxFileSystemTestHelper; class SandboxQuotaObserver; -// This class keeps and provides a sandbox file system context. +// Delegate implementation of the some methods in Sandbox/SyncFileSystemBackend. // An instance of this class is created and owned by FileSystemContext. -class WEBKIT_STORAGE_BROWSER_EXPORT SandboxContext { +class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate { public: typedef FileSystemBackend::OpenFileSystemCallback OpenFileSystemCallback; @@ -61,14 +61,14 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxContext { virtual bool HasFileSystemType(FileSystemType type) const = 0; }; - SandboxContext( + SandboxFileSystemBackendDelegate( quota::QuotaManagerProxy* quota_manager_proxy, base::SequencedTaskRunner* file_task_runner, const base::FilePath& profile_path, quota::SpecialStoragePolicy* special_storage_policy, const FileSystemOptions& file_system_options); - ~SandboxContext(); + ~SandboxFileSystemBackendDelegate(); // Performs API-specific validity checks on the given path |url|. // Returns true if access to |url| is valid in this filesystem. @@ -184,11 +184,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxContext { base::Time next_release_time_for_open_filesystem_stat_; - base::WeakPtrFactory<SandboxContext> weak_factory_; + base::WeakPtrFactory<SandboxFileSystemBackendDelegate> weak_factory_; - DISALLOW_COPY_AND_ASSIGN(SandboxContext); + DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackendDelegate); }; } // namespace fileapi -#endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_CONTEXT_H_ +#endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_DELEGATE_H_ diff --git a/webkit/browser/fileapi/sandbox_context_unittest.cc b/webkit/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc index 841e10b..48c3b8c 100644 --- a/webkit/browser/fileapi/sandbox_context_unittest.cc +++ b/webkit/browser/fileapi/sandbox_file_system_backend_delegate_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "webkit/browser/fileapi/sandbox_context.h" +#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" #include "base/basictypes.h" #include "base/file_util.h" @@ -27,11 +27,11 @@ FileSystemURL CreateFileSystemURL(const char* path) { } // namespace -class SandboxContextTest : public testing::Test { +class SandboxFileSystemBackendDelegateTest : public testing::Test { protected: virtual void SetUp() { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); - context_.reset(new SandboxContext( + delegate_.reset(new SandboxFileSystemBackendDelegate( NULL /* quota_manager_proxy */, base::MessageLoopProxy::current().get(), data_dir_.path(), @@ -41,42 +41,42 @@ class SandboxContextTest : public testing::Test { base::ScopedTempDir data_dir_; base::MessageLoop message_loop_; - scoped_ptr<SandboxContext> context_; + scoped_ptr<SandboxFileSystemBackendDelegate> delegate_; }; -TEST_F(SandboxContextTest, IsAccessValid) { +TEST_F(SandboxFileSystemBackendDelegateTest, IsAccessValid) { // Normal case. - EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL("a"))); + EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL("a"))); // Access to a path with parent references ('..') should be disallowed. - EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL("a/../b"))); + EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL("a/../b"))); // Access from non-allowed scheme should be disallowed. - EXPECT_FALSE(context_->IsAccessValid( + EXPECT_FALSE(delegate_->IsAccessValid( FileSystemURL::CreateForTest( GURL("unknown://bar"), kFileSystemTypeTemporary, base::FilePath::FromUTF8Unsafe("foo")))); // Access with restricted name should be disallowed. - EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL("."))); - EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL(".."))); + EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL("."))); + EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL(".."))); // This is also disallowed due to Windows XP parent path handling. - EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL("..."))); + EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL("..."))); // These are identified as unsafe cases due to weird path handling // on Windows. - EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL(" .."))); - EXPECT_FALSE(context_->IsAccessValid(CreateFileSystemURL(".. "))); + EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL(" .."))); + EXPECT_FALSE(delegate_->IsAccessValid(CreateFileSystemURL(".. "))); // Similar but safe cases. - EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL(" ."))); - EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL(". "))); - EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL("b."))); - EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL(".b"))); + EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL(" ."))); + EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL(". "))); + EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL("b."))); + EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL(".b"))); // A path that looks like a drive letter. - EXPECT_TRUE(context_->IsAccessValid(CreateFileSystemURL("c:"))); + EXPECT_TRUE(delegate_->IsAccessValid(CreateFileSystemURL("c:"))); } } // namespace fileapi diff --git a/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc b/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc index ec213a3..c7f0317 100644 --- a/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc +++ b/webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc @@ -17,7 +17,7 @@ #include "webkit/browser/fileapi/file_system_backend.h" #include "webkit/browser/fileapi/file_system_url.h" #include "webkit/browser/fileapi/mock_file_system_options.h" -#include "webkit/browser/fileapi/sandbox_context.h" +#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" #include "webkit/common/fileapi/file_system_util.h" // PS stands for path separator. @@ -85,11 +85,11 @@ class SandboxFileSystemBackendTest : public testing::Test { protected: virtual void SetUp() { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); - SetUpNewSandboxContext(CreateAllowFileAccessOptions()); + SetUpNewDelegate(CreateAllowFileAccessOptions()); } - void SetUpNewSandboxContext(const FileSystemOptions& options) { - context_.reset(new SandboxContext( + void SetUpNewDelegate(const FileSystemOptions& options) { + delegate_.reset(new SandboxFileSystemBackendDelegate( NULL /* quota_manager_proxy */, base::MessageLoopProxy::current().get(), data_dir_.path(), @@ -98,17 +98,18 @@ class SandboxFileSystemBackendTest : public testing::Test { } void SetUpNewBackend(const FileSystemOptions& options) { - SetUpNewSandboxContext(options); - backend_.reset(new SandboxFileSystemBackend(context_.get())); + SetUpNewDelegate(options); + backend_.reset(new SandboxFileSystemBackend(delegate_.get())); } - SandboxContext::OriginEnumerator* CreateOriginEnumerator() const { + SandboxFileSystemBackendDelegate::OriginEnumerator* + CreateOriginEnumerator() const { return backend_->CreateOriginEnumerator(); } void CreateOriginTypeDirectory(const GURL& origin, fileapi::FileSystemType type) { - base::FilePath target = context_-> + base::FilePath target = delegate_-> GetBaseDirectoryForOriginAndType(origin, type, true); ASSERT_TRUE(!target.empty()); ASSERT_TRUE(base::DirectoryExists(target)); @@ -126,7 +127,7 @@ class SandboxFileSystemBackendTest : public testing::Test { if (error != base::PLATFORM_FILE_OK) return false; base::FilePath returned_root_path = - context_->GetBaseDirectoryForOriginAndType( + delegate_->GetBaseDirectoryForOriginAndType( origin_url, type, false /* create */); if (root_path) *root_path = returned_root_path; @@ -134,18 +135,19 @@ class SandboxFileSystemBackendTest : public testing::Test { } base::FilePath file_system_path() const { - return data_dir_.path().Append(SandboxContext::kFileSystemDirectory); + return data_dir_.path().Append( + SandboxFileSystemBackendDelegate::kFileSystemDirectory); } base::ScopedTempDir data_dir_; base::MessageLoop message_loop_; - scoped_ptr<SandboxContext> context_; + scoped_ptr<SandboxFileSystemBackendDelegate> delegate_; scoped_ptr<SandboxFileSystemBackend> backend_; }; TEST_F(SandboxFileSystemBackendTest, Empty) { SetUpNewBackend(CreateAllowFileAccessOptions()); - scoped_ptr<SandboxContext::OriginEnumerator> enumerator( + scoped_ptr<SandboxFileSystemBackendDelegate::OriginEnumerator> enumerator( CreateOriginEnumerator()); ASSERT_TRUE(enumerator->Next().is_empty()); } @@ -178,7 +180,7 @@ TEST_F(SandboxFileSystemBackendTest, EnumerateOrigins) { persistent_set.insert(GURL(persistent_origins[i])); } - scoped_ptr<SandboxContext::OriginEnumerator> enumerator( + scoped_ptr<SandboxFileSystemBackendDelegate::OriginEnumerator> enumerator( CreateOriginEnumerator()); size_t temporary_actual_size = 0; size_t persistent_actual_size = 0; diff --git a/webkit/browser/fileapi/sandbox_file_system_test_helper.cc b/webkit/browser/fileapi/sandbox_file_system_test_helper.cc index 179bf9b..97d7a5f 100644 --- a/webkit/browser/fileapi/sandbox_file_system_test_helper.cc +++ b/webkit/browser/fileapi/sandbox_file_system_test_helper.cc @@ -61,7 +61,7 @@ void SandboxFileSystemTestHelper::TearDown() { } base::FilePath SandboxFileSystemTestHelper::GetOriginRootPath() { - return file_system_context_->sandbox_context()-> + return file_system_context_->sandbox_delegate()-> GetBaseDirectoryForOriginAndType(origin_, type_, false); } @@ -80,8 +80,8 @@ base::FilePath SandboxFileSystemTestHelper::GetLocalPathFromASCII( } base::FilePath SandboxFileSystemTestHelper::GetUsageCachePath() const { - return file_system_context_-> - sandbox_context()->GetUsageCachePathForOriginAndType(origin_, type_); + return file_system_context_->sandbox_delegate()-> + GetUsageCachePathForOriginAndType(origin_, type_); } FileSystemURL SandboxFileSystemTestHelper::CreateURL( @@ -129,7 +129,7 @@ void SandboxFileSystemTestHelper::AddFileChangeObserver( } FileSystemUsageCache* SandboxFileSystemTestHelper::usage_cache() { - return file_system_context()->sandbox_context()->usage_cache(); + return file_system_context()->sandbox_delegate()->usage_cache(); } void SandboxFileSystemTestHelper::SetUpFileSystem() { @@ -140,7 +140,7 @@ void SandboxFileSystemTestHelper::SetUpFileSystem() { DCHECK(file_util_); // Prepare the origin's root directory. - file_system_context_->sandbox_context()-> + file_system_context_->sandbox_delegate()-> GetBaseDirectoryForOriginAndType(origin_, type_, true /* create */); // Initialize the usage cache file. diff --git a/webkit/browser/fileapi/sandbox_quota_observer.cc b/webkit/browser/fileapi/sandbox_quota_observer.cc index 02a47ee..fe5ee37 100644 --- a/webkit/browser/fileapi/sandbox_quota_observer.cc +++ b/webkit/browser/fileapi/sandbox_quota_observer.cc @@ -7,7 +7,7 @@ #include "base/sequenced_task_runner.h" #include "webkit/browser/fileapi/file_system_url.h" #include "webkit/browser/fileapi/file_system_usage_cache.h" -#include "webkit/browser/fileapi/sandbox_context.h" +#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" #include "webkit/browser/fileapi/timed_task_helper.h" #include "webkit/browser/quota/quota_client.h" #include "webkit/browser/quota/quota_manager.h" @@ -107,7 +107,7 @@ base::FilePath SandboxQuotaObserver::GetUsageCachePath( DCHECK(sandbox_file_util_); base::PlatformFileError error = base::PLATFORM_FILE_OK; base::FilePath path = - SandboxContext::GetUsageCachePathForOriginAndType( + SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType( sandbox_file_util_, url.origin(), url.type(), &error); if (error != base::PLATFORM_FILE_OK) { LOG(WARNING) << "Could not get usage cache path for: " diff --git a/webkit/storage_browser.gyp b/webkit/storage_browser.gyp index 04e609a..04d2565 100644 --- a/webkit/storage_browser.gyp +++ b/webkit/storage_browser.gyp @@ -154,14 +154,14 @@ 'browser/fileapi/recursive_operation_delegate.h', 'browser/fileapi/remove_operation_delegate.cc', 'browser/fileapi/remove_operation_delegate.h', - 'browser/fileapi/sandbox_context.cc', - 'browser/fileapi/sandbox_context.h', 'browser/fileapi/sandbox_directory_database.cc', 'browser/fileapi/sandbox_directory_database.h', 'browser/fileapi/sandbox_file_stream_writer.cc', 'browser/fileapi/sandbox_file_stream_writer.h', 'browser/fileapi/sandbox_file_system_backend.cc', 'browser/fileapi/sandbox_file_system_backend.h', + 'browser/fileapi/sandbox_file_system_backend_delegate.cc', + 'browser/fileapi/sandbox_file_system_backend_delegate.h', 'browser/fileapi/sandbox_isolated_origin_database.cc', 'browser/fileapi/sandbox_isolated_origin_database.h', 'browser/fileapi/sandbox_origin_database.cc', |