diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-17 07:42:07 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-17 07:42:07 +0000 |
commit | 5caeb20dd7e216f4bfbdb3aa25930e842f68377e (patch) | |
tree | e21e2b65e3e93156367657ddfe68e144114d0337 /webkit | |
parent | 216c17f4d83ba354f911b13fafd18c030169a23e (diff) | |
download | chromium_src-5caeb20dd7e216f4bfbdb3aa25930e842f68377e.zip chromium_src-5caeb20dd7e216f4bfbdb3aa25930e842f68377e.tar.gz chromium_src-5caeb20dd7e216f4bfbdb3aa25930e842f68377e.tar.bz2 |
Factor out quota-related filesysem internal code into QuotaUtil class
- moved usage-cache related implementation from SandboxQuotaClient to SandboxMountPointProvider, and
- renamed SandboxQuotaClient and FileSystemQuotaClient as now it doesn't depend on sandbox_provider.
BUG=74841
TEST=FileSystemQuotaClient.*
Review URL: http://codereview.chromium.org/6973005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85605 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/fileapi/file_system_context.cc | 40 | ||||
-rw-r--r-- | webkit/fileapi/file_system_context.h | 6 | ||||
-rw-r--r-- | webkit/fileapi/file_system_path_manager.h | 9 | ||||
-rw-r--r-- | webkit/fileapi/file_system_quota_client.cc (renamed from webkit/fileapi/sandbox_quota_client.cc) | 165 | ||||
-rw-r--r-- | webkit/fileapi/file_system_quota_client.h (renamed from webkit/fileapi/sandbox_quota_client.h) | 21 | ||||
-rw-r--r-- | webkit/fileapi/file_system_quota_client_unittest.cc (renamed from webkit/fileapi/sandbox_quota_client_unittest.cc) | 90 | ||||
-rw-r--r-- | webkit/fileapi/file_system_quota_util.h | 72 | ||||
-rw-r--r-- | webkit/fileapi/sandbox_mount_point_provider.cc | 137 | ||||
-rw-r--r-- | webkit/fileapi/sandbox_mount_point_provider.h | 58 | ||||
-rw-r--r-- | webkit/fileapi/webkit_fileapi.gypi | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.gypi | 2 |
11 files changed, 419 insertions, 186 deletions
diff --git a/webkit/fileapi/file_system_context.cc b/webkit/fileapi/file_system_context.cc index 14fcd496..ff4520a 100644 --- a/webkit/fileapi/file_system_context.cc +++ b/webkit/fileapi/file_system_context.cc @@ -8,8 +8,9 @@ #include "base/message_loop_proxy.h" #include "googleurl/src/gurl.h" #include "webkit/fileapi/file_system_path_manager.h" +#include "webkit/fileapi/file_system_util.h" #include "webkit/fileapi/sandbox_mount_point_provider.h" -#include "webkit/fileapi/sandbox_quota_client.h" +#include "webkit/fileapi/file_system_quota_client.h" #include "webkit/quota/quota_manager.h" using quota::QuotaClient; @@ -21,11 +22,7 @@ QuotaClient* CreateQuotaClient( scoped_refptr<base::MessageLoopProxy> file_message_loop, FileSystemContext* context, bool is_incognito) { - // TODO(kinuko): For now we assume only sandbox filesystem uses - // the quota feature. If we want to support multiple filesystem types - // that require different quota we'll need to add more QuotaClientID - // and more factory-like code around QuotaClient. - return new SandboxQuotaClient(file_message_loop, context, is_incognito); + return new FileSystemQuotaClient(file_message_loop, context, is_incognito); } } // anonymous namespace @@ -73,8 +70,15 @@ bool FileSystemContext::IsStorageUnlimited(const GURL& origin) { bool FileSystemContext::DeleteDataForOriginOnFileThread( const GURL& origin_url) { DCHECK(file_message_loop_->BelongsToCurrentThread()); - // TODO(tzik): Report the amount of deleted data to QuotaManager. + DCHECK(sandbox_provider()); + // Delete temporary and persistent data. + sandbox_provider()->DeleteOriginDataOnFileThread( + quota_manager_proxy(), origin_url, kFileSystemTypeTemporary); + sandbox_provider()->DeleteOriginDataOnFileThread( + quota_manager_proxy(), origin_url, kFileSystemTypePersistent); + + // Delete the upper level directory. FilePath path_for_origin = sandbox_provider()->GetBaseDirectoryForOrigin(origin_url); if (!file_util::PathExists(path_for_origin)) @@ -85,13 +89,23 @@ bool FileSystemContext::DeleteDataForOriginOnFileThread( bool FileSystemContext::DeleteDataForOriginAndTypeOnFileThread( const GURL& origin_url, FileSystemType type) { DCHECK(file_message_loop_->BelongsToCurrentThread()); - // TODO(tzik): ditto. Report the amount of deleted data to QuotaManager. + if (type == fileapi::kFileSystemTypeTemporary || + type == fileapi::kFileSystemTypePersistent) { + DCHECK(sandbox_provider()); + return sandbox_provider()->DeleteOriginDataOnFileThread( + quota_manager_proxy(), origin_url, type); + } + return false; +} - FilePath path_for_origin = - sandbox_provider()->GetBaseDirectoryForOriginAndType(origin_url, type); - if (!file_util::PathExists(path_for_origin)) - return true; - return file_util::Delete(path_for_origin, true /* recursive */); +FileSystemQuotaUtil* +FileSystemContext::GetQuotaUtil(FileSystemType type) const { + if (type == fileapi::kFileSystemTypeTemporary || + type == fileapi::kFileSystemTypePersistent) { + DCHECK(sandbox_provider()); + return sandbox_provider()->quota_util(); + } + return NULL; } void FileSystemContext::DeleteOnCorrectThread() const { diff --git a/webkit/fileapi/file_system_context.h b/webkit/fileapi/file_system_context.h index 9a48023..ef99df8 100644 --- a/webkit/fileapi/file_system_context.h +++ b/webkit/fileapi/file_system_context.h @@ -26,6 +26,7 @@ namespace fileapi { class FileSystemContext; class FileSystemPathManager; +class FileSystemQuotaUtil; class FileSystemUsageTracker; class SandboxMountPointProvider; @@ -60,6 +61,11 @@ class FileSystemContext return quota_manager_proxy_.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. + FileSystemQuotaUtil* GetQuotaUtil(FileSystemType type) const; + private: friend struct DefaultContextDeleter; void DeleteOnCorrectThread() const; diff --git a/webkit/fileapi/file_system_path_manager.h b/webkit/fileapi/file_system_path_manager.h index 6754cb3..2fbd273 100644 --- a/webkit/fileapi/file_system_path_manager.h +++ b/webkit/fileapi/file_system_path_manager.h @@ -23,15 +23,6 @@ namespace fileapi { class ExternalFileSystemMountPointProvider; class SandboxMountPointProvider; -// TODO(kinuko): Probably this module must be called FileSystemPathUtil -// or something similar. - -// An interface to construct or crack sandboxed filesystem paths. -// Currently each sandboxed filesystem path looks like: -// -// <profile_dir>/FileSystem/<origin_identifier>/<type>/chrome-<unique>/... -// -// <type> is either one of "Temporary" or "Persistent". class FileSystemPathManager { public: FileSystemPathManager( diff --git a/webkit/fileapi/sandbox_quota_client.cc b/webkit/fileapi/file_system_quota_client.cc index 541ecf1..f3fec60 100644 --- a/webkit/fileapi/sandbox_quota_client.cc +++ b/webkit/fileapi/file_system_quota_client.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/fileapi/sandbox_quota_client.h" +#include "webkit/fileapi/file_system_quota_client.h" #include <algorithm> #include <set> @@ -17,9 +17,9 @@ #include "net/base/net_util.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_path_manager.h" +#include "webkit/fileapi/file_system_quota_util.h" #include "webkit/fileapi/file_system_usage_cache.h" #include "webkit/fileapi/file_system_util.h" -#include "webkit/fileapi/sandbox_mount_point_provider.h" using base::MessageLoopProxy; using quota::QuotaThreadTask; @@ -27,10 +27,10 @@ using quota::StorageType; namespace fileapi { -class SandboxQuotaClient::GetOriginUsageTask : public QuotaThreadTask { +class FileSystemQuotaClient::GetOriginUsageTask : public QuotaThreadTask { public: GetOriginUsageTask( - SandboxQuotaClient* quota_client, + FileSystemQuotaClient* quota_client, scoped_refptr<MessageLoopProxy> file_message_loop, const GURL& origin_url, FileSystemType type) @@ -41,58 +41,32 @@ class SandboxQuotaClient::GetOriginUsageTask : public QuotaThreadTask { fs_usage_(0) { DCHECK(quota_client_); file_system_context_ = quota_client_->file_system_context_; - visited_ = (quota_client_->visited_origins_.find(origin_url) != - quota_client_->visited_origins_.end()); } virtual ~GetOriginUsageTask() {} protected: virtual void RunOnTargetThread() OVERRIDE { - FilePath base_path = - file_system_context_->path_manager()->sandbox_provider()-> - GetBaseDirectoryForOriginAndType(origin_url_, type_); - if (!file_util::DirectoryExists(base_path)) { - fs_usage_ = 0; - } else { - FilePath usage_file_path = base_path.AppendASCII( - FileSystemUsageCache::kUsageFileName); - int32 dirty_status = FileSystemUsageCache::GetDirty(usage_file_path); - if (dirty_status == 0 || (dirty_status > 0 && visited_)) { - // The usage cache is clean (dirty == 0) or the origin has already - // initialized and running. Read the cache file to get the usage. - fs_usage_ = FileSystemUsageCache::GetUsage(usage_file_path); - } else { - // The usage cache has not been initialized or the cache is dirty. - // Get the directory size now and update the cache. - if (FileSystemUsageCache::Exists(usage_file_path)) - FileSystemUsageCache::Delete(usage_file_path); - int64 usage = file_util::ComputeDirectorySize(base_path); - // The result of ComputeDirectorySize does not include .usage file size. - usage += FileSystemUsageCache::kUsageFileSize; - // This clears the dirty flag too. - FileSystemUsageCache::UpdateUsage(usage_file_path, usage); - fs_usage_ = usage; - } - } + FileSystemQuotaUtil* quota_util = file_system_context_->GetQuotaUtil(type_); + if (quota_util) + fs_usage_ = quota_util->GetOriginUsageOnFileThread(origin_url_, type_); } virtual void Completed() OVERRIDE { quota_client_->DidGetOriginUsage(type_, origin_url_, fs_usage_); } - SandboxQuotaClient* quota_client_; + FileSystemQuotaClient* quota_client_; scoped_refptr<FileSystemContext> file_system_context_; GURL origin_url_; FileSystemType type_; int64 fs_usage_; - bool visited_; }; -class SandboxQuotaClient::GetOriginsTaskBase : public QuotaThreadTask { +class FileSystemQuotaClient::GetOriginsForTypeTask : public QuotaThreadTask { public: - GetOriginsTaskBase( - SandboxQuotaClient* quota_client, + GetOriginsForTypeTask( + FileSystemQuotaClient* quota_client, scoped_refptr<MessageLoopProxy> file_message_loop, FileSystemType type) : QuotaThreadTask(quota_client, file_message_loop), @@ -101,94 +75,66 @@ class SandboxQuotaClient::GetOriginsTaskBase : public QuotaThreadTask { DCHECK(quota_client_); file_system_context_ = quota_client_->file_system_context_; } - virtual ~GetOriginsTaskBase() {} + virtual ~GetOriginsForTypeTask() {} protected: - virtual bool ShouldAddThisOrigin(const GURL& origin) const = 0; - virtual void RunOnTargetThread() OVERRIDE { - scoped_ptr<SandboxMountPointProvider::OriginEnumerator> enumerator( - sandbox_provider()->CreateOriginEnumerator()); - GURL origin; - while (!(origin = enumerator->Next()).is_empty()) { - if (ShouldAddThisOrigin(origin) && enumerator->HasFileSystemType(type_)) - origins_.insert(origin); - } + FileSystemQuotaUtil* quota_util = file_system_context_->GetQuotaUtil(type_); + if (quota_util) + quota_util->GetOriginsForTypeOnFileThread(type_, &origins_); } - SandboxQuotaClient* quota_client() const { return quota_client_; } - const std::set<GURL>& origins() const { return origins_; } - FileSystemType type() const { return type_; } - SandboxMountPointProvider* sandbox_provider() const { - return file_system_context_->path_manager()->sandbox_provider(); + virtual void Completed() OVERRIDE { + quota_client_->DidGetOriginsForType(type_, origins_); } private: - SandboxQuotaClient * quota_client_; + FileSystemQuotaClient* quota_client_; scoped_refptr<FileSystemContext> file_system_context_; std::set<GURL> origins_; FileSystemType type_; }; -class SandboxQuotaClient::GetOriginsForTypeTask - : public SandboxQuotaClient::GetOriginsTaskBase { - public: - GetOriginsForTypeTask( - SandboxQuotaClient* quota_client, - scoped_refptr<MessageLoopProxy> file_message_loop, - FileSystemType type) - : GetOriginsTaskBase(quota_client, file_message_loop, type) {} - virtual ~GetOriginsForTypeTask() {} - - protected: - virtual bool ShouldAddThisOrigin(const GURL& origin) const OVERRIDE { - return true; - } - - virtual void Completed() OVERRIDE { - quota_client()->DidGetOriginsForType(type(), origins()); - } -}; - -quota::QuotaClient::ID SandboxQuotaClient::id() const { - return quota::QuotaClient::kFileSystem; -} - -void SandboxQuotaClient::OnQuotaManagerDestroyed() { - delete this; -} - -class SandboxQuotaClient::GetOriginsForHostTask - : public SandboxQuotaClient::GetOriginsTaskBase { +class FileSystemQuotaClient::GetOriginsForHostTask : public QuotaThreadTask { public: GetOriginsForHostTask( - SandboxQuotaClient* quota_client, + FileSystemQuotaClient* quota_client, scoped_refptr<MessageLoopProxy> file_message_loop, FileSystemType type, const std::string& host) - : GetOriginsTaskBase(quota_client, file_message_loop, type), - host_(host) {} + : QuotaThreadTask(quota_client, file_message_loop), + quota_client_(quota_client), + type_(type), + host_(host) { + DCHECK(quota_client_); + file_system_context_ = quota_client_->file_system_context_; + } virtual ~GetOriginsForHostTask() {} protected: - virtual bool ShouldAddThisOrigin(const GURL& origin) const OVERRIDE { - return (host_ == net::GetHostOrSpecFromURL(origin)); + virtual void RunOnTargetThread() OVERRIDE { + FileSystemQuotaUtil* quota_util = file_system_context_->GetQuotaUtil(type_); + if (quota_util) + quota_util->GetOriginsForHostOnFileThread(type_, host_, &origins_); } virtual void Completed() OVERRIDE { - quota_client()->DidGetOriginsForHost(std::make_pair(type(), host_), - origins()); + quota_client_->DidGetOriginsForHost(std::make_pair(type_, host_), origins_); } private: + FileSystemQuotaClient* quota_client_; + scoped_refptr<FileSystemContext> file_system_context_; + std::set<GURL> origins_; + FileSystemType type_; std::string host_; }; -class SandboxQuotaClient::DeleteOriginTask +class FileSystemQuotaClient::DeleteOriginTask : public QuotaThreadTask { public: DeleteOriginTask( - SandboxQuotaClient* quota_client, + FileSystemQuotaClient* quota_client, scoped_refptr<MessageLoopProxy> file_message_loop, const GURL& origin, FileSystemType type, @@ -204,8 +150,8 @@ class SandboxQuotaClient::DeleteOriginTask virtual ~DeleteOriginTask() {} virtual void RunOnTargetThread() OVERRIDE { - if (file_system_context_-> - DeleteDataForOriginAndTypeOnFileThread(origin_, type_)) + if (file_system_context_->DeleteDataForOriginAndTypeOnFileThread( + origin_, type_)) status_ = quota::kQuotaStatusOk; else status_ = quota::kQuotaErrorInvalidModification; @@ -222,7 +168,7 @@ class SandboxQuotaClient::DeleteOriginTask scoped_ptr<DeletionCallback> callback_; }; -SandboxQuotaClient::SandboxQuotaClient( +FileSystemQuotaClient::FileSystemQuotaClient( scoped_refptr<base::MessageLoopProxy> file_message_loop, FileSystemContext* file_system_context, bool is_incognito) @@ -232,10 +178,18 @@ SandboxQuotaClient::SandboxQuotaClient( DCHECK(file_message_loop); } -SandboxQuotaClient::~SandboxQuotaClient() { +FileSystemQuotaClient::~FileSystemQuotaClient() { +} + +quota::QuotaClient::ID FileSystemQuotaClient::id() const { + return quota::QuotaClient::kFileSystem; +} + +void FileSystemQuotaClient::OnQuotaManagerDestroyed() { + delete this; } -void SandboxQuotaClient::GetOriginUsage( +void FileSystemQuotaClient::GetOriginUsage( const GURL& origin_url, StorageType storage_type, GetUsageCallback* callback_ptr) { @@ -259,7 +213,7 @@ void SandboxQuotaClient::GetOriginUsage( } } -void SandboxQuotaClient::GetOriginsForType( +void FileSystemQuotaClient::GetOriginsForType( StorageType storage_type, GetOriginsCallback* callback_ptr) { std::set<GURL> origins; @@ -280,7 +234,7 @@ void SandboxQuotaClient::GetOriginsForType( } } -void SandboxQuotaClient::GetOriginsForHost( +void FileSystemQuotaClient::GetOriginsForHost( StorageType storage_type, const std::string& host, GetOriginsCallback* callback_ptr) { @@ -304,9 +258,9 @@ void SandboxQuotaClient::GetOriginsForHost( } } -void SandboxQuotaClient::DeleteOriginData(const GURL& origin, - StorageType type, - DeletionCallback* callback) { +void FileSystemQuotaClient::DeleteOriginData(const GURL& origin, + StorageType type, + DeletionCallback* callback) { FileSystemType fs_type = QuotaStorageTypeToFileSystemType(type); DCHECK(fs_type != kFileSystemTypeUnknown); scoped_refptr<DeleteOriginTask> task( @@ -315,22 +269,21 @@ void SandboxQuotaClient::DeleteOriginData(const GURL& origin, task->Start(); } -void SandboxQuotaClient::DidGetOriginUsage( +void FileSystemQuotaClient::DidGetOriginUsage( FileSystemType type, const GURL& origin_url, int64 usage) { - visited_origins_.insert(origin_url); TypeAndHostOrOrigin type_and_origin(std::make_pair( type, origin_url.spec())); DCHECK(pending_usage_callbacks_.HasCallbacks(type_and_origin)); pending_usage_callbacks_.Run(type_and_origin, usage); } -void SandboxQuotaClient::DidGetOriginsForType( +void FileSystemQuotaClient::DidGetOriginsForType( FileSystemType type, const std::set<GURL>& origins) { DCHECK(pending_origins_for_type_callbacks_.HasCallbacks(type)); pending_origins_for_type_callbacks_.Run(type, origins); } -void SandboxQuotaClient::DidGetOriginsForHost( +void FileSystemQuotaClient::DidGetOriginsForHost( const TypeAndHostOrOrigin& type_and_host, const std::set<GURL>& origins) { DCHECK(pending_origins_for_host_callbacks_.HasCallbacks(type_and_host)); pending_origins_for_host_callbacks_.Run(type_and_host, origins); diff --git a/webkit/fileapi/sandbox_quota_client.h b/webkit/fileapi/file_system_quota_client.h index db39e08..fb553c9 100644 --- a/webkit/fileapi/sandbox_quota_client.h +++ b/webkit/fileapi/file_system_quota_client.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_FILEAPI_SANDBOX_QUOTA_CLIENT_H_ -#define WEBKIT_FILEAPI_SANDBOX_QUOTA_CLIENT_H_ +#ifndef WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_CLIENT_H_ +#define WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_CLIENT_H_ #include <deque> #include <list> @@ -15,6 +15,7 @@ #include "base/file_path.h" #include "base/memory/scoped_ptr.h" #include "webkit/fileapi/file_system_path_manager.h" +#include "webkit/fileapi/file_system_quota_util.h" #include "webkit/fileapi/file_system_types.h" #include "webkit/quota/quota_client.h" #include "webkit/quota/quota_task.h" @@ -26,14 +27,16 @@ class FileSystemContext; // An instance of this class is created per-profile. This class // is self-destructed and will delete itself when OnQuotaManagerDestroyed // is called. -class SandboxQuotaClient : public quota::QuotaClient, - public quota::QuotaTaskObserver { +// All of the public methods of this class are called by the quota manager +// (except for the constructor/destructor). +class FileSystemQuotaClient : public quota::QuotaClient, + public quota::QuotaTaskObserver { public: - SandboxQuotaClient( + FileSystemQuotaClient( scoped_refptr<base::MessageLoopProxy> file_message_loop, FileSystemContext* file_system_context, bool is_incognito); - virtual ~SandboxQuotaClient(); + virtual ~FileSystemQuotaClient(); // QuotaClient methods. virtual quota::QuotaClient::ID id() const OVERRIDE; @@ -83,16 +86,14 @@ class SandboxQuotaClient : public quota::QuotaClient, bool is_incognito_; - std::set<GURL> visited_origins_; - // Pending callbacks. UsageCallbackMap pending_usage_callbacks_; OriginsForTypeCallbackMap pending_origins_for_type_callbacks_; OriginsForHostCallbackMap pending_origins_for_host_callbacks_; - DISALLOW_COPY_AND_ASSIGN(SandboxQuotaClient); + DISALLOW_COPY_AND_ASSIGN(FileSystemQuotaClient); }; } // namespace fileapi -#endif // WEBKIT_FILEAPI_SANDBOX_QUOTA_CLIENT_H_ +#endif // WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_CLIENT_H_ diff --git a/webkit/fileapi/sandbox_quota_client_unittest.cc b/webkit/fileapi/file_system_quota_client_unittest.cc index 09da1dd..49927af 100644 --- a/webkit/fileapi/sandbox_quota_client_unittest.cc +++ b/webkit/fileapi/file_system_quota_client_unittest.cc @@ -12,11 +12,11 @@ #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/fileapi/file_system_context.h" +#include "webkit/fileapi/file_system_quota_client.h" #include "webkit/fileapi/file_system_types.h" #include "webkit/fileapi/file_system_usage_cache.h" #include "webkit/fileapi/file_system_util.h" #include "webkit/fileapi/sandbox_mount_point_provider.h" -#include "webkit/fileapi/sandbox_quota_client.h" #include "webkit/quota/quota_types.h" namespace fileapi { @@ -40,9 +40,9 @@ class MockFileSystemPathManager : public FileSystemPathManager { } // namespace -class SandboxQuotaClientTest : public testing::Test { +class FileSystemQuotaClientTest : public testing::Test { public: - SandboxQuotaClientTest() + FileSystemQuotaClientTest() : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), additional_callback_count_(0), deletion_status_(quota::kQuotaStatusUnknown) { @@ -69,21 +69,21 @@ class SandboxQuotaClientTest : public testing::Test { }; protected: - SandboxQuotaClient* NewQuotaClient(bool is_incognito) { - return new SandboxQuotaClient( + FileSystemQuotaClient* NewQuotaClient(bool is_incognito) { + return new FileSystemQuotaClient( base::MessageLoopProxy::CreateForCurrentThread(), file_system_context_, is_incognito); } - void GetOriginUsageAsync(SandboxQuotaClient* quota_client, + void GetOriginUsageAsync(FileSystemQuotaClient* quota_client, const char* origin_url, quota::StorageType type) { quota_client->GetOriginUsage(GURL(origin_url), type, callback_factory_.NewCallback( - &SandboxQuotaClientTest::OnGetUsage)); + &FileSystemQuotaClientTest::OnGetUsage)); } - int64 GetOriginUsage(SandboxQuotaClient* quota_client, + int64 GetOriginUsage(FileSystemQuotaClient* quota_client, const char* origin_url, quota::StorageType type) { GetOriginUsageAsync(quota_client, origin_url, type); @@ -91,37 +91,39 @@ class SandboxQuotaClientTest : public testing::Test { return usage_; } - const std::set<GURL>& GetOriginsForType(SandboxQuotaClient* quota_client, + const std::set<GURL>& GetOriginsForType(FileSystemQuotaClient* quota_client, quota::StorageType type) { origins_.clear(); quota_client->GetOriginsForType(type, callback_factory_.NewCallback( - &SandboxQuotaClientTest::OnGetOrigins)); + &FileSystemQuotaClientTest::OnGetOrigins)); MessageLoop::current()->RunAllPending(); return origins_; } - const std::set<GURL>& GetOriginsForHost(SandboxQuotaClient* quota_client, + const std::set<GURL>& GetOriginsForHost(FileSystemQuotaClient* quota_client, quota::StorageType type, const char* host) { origins_.clear(); quota_client->GetOriginsForHost(type, host, callback_factory_.NewCallback( - &SandboxQuotaClientTest::OnGetOrigins)); + &FileSystemQuotaClientTest::OnGetOrigins)); MessageLoop::current()->RunAllPending(); return origins_; } - void RunAdditionalOriginUsageTask(SandboxQuotaClient* quota_client, + void RunAdditionalOriginUsageTask(FileSystemQuotaClient* quota_client, const char* origin_url, quota::StorageType type) { quota_client->GetOriginUsage(GURL(origin_url), type, callback_factory_.NewCallback( - &SandboxQuotaClientTest::OnGetAdditionalUsage)); + &FileSystemQuotaClientTest::OnGetAdditionalUsage)); } FilePath GetOriginBasePath(const char* origin_url, quota::StorageType type) { + // Note: this test assumes sandbox_provider impl is used for + // temporary and persistent filesystem. return file_system_context_->path_manager()->sandbox_provider()-> GetBaseDirectoryForOriginAndType( GURL(origin_url), QuotaStorageTypeToFileSystemType(type)); @@ -178,14 +180,14 @@ class SandboxQuotaClientTest : public testing::Test { } } - void DeleteOriginData(SandboxQuotaClient* quota_client, + void DeleteOriginData(FileSystemQuotaClient* quota_client, const char* origin, quota::StorageType type) { deletion_status_ = quota::kQuotaStatusUnknown; quota_client->DeleteOriginData( GURL(origin), type, callback_factory_.NewCallback( - &SandboxQuotaClientTest::OnDeleteOrigin)); + &FileSystemQuotaClientTest::OnDeleteOrigin)); } int64 usage() const { return usage_; } @@ -214,23 +216,23 @@ class SandboxQuotaClientTest : public testing::Test { ScopedTempDir data_dir_; scoped_refptr<FileSystemContext> file_system_context_; - base::ScopedCallbackFactory<SandboxQuotaClientTest> callback_factory_; + base::ScopedCallbackFactory<FileSystemQuotaClientTest> callback_factory_; int64 usage_; int additional_callback_count_; std::set<GURL> origins_; quota::QuotaStatusCode deletion_status_; - DISALLOW_COPY_AND_ASSIGN(SandboxQuotaClientTest); + DISALLOW_COPY_AND_ASSIGN(FileSystemQuotaClientTest); }; -TEST_F(SandboxQuotaClientTest, NoFileSystemTest) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); +TEST_F(FileSystemQuotaClientTest, NoFileSystemTest) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); EXPECT_EQ(0, GetOriginUsage(quota_client.get(), kDummyURL1, kTemporary)); } -TEST_F(SandboxQuotaClientTest, NoFileTest) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); +TEST_F(FileSystemQuotaClientTest, NoFileTest) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); const TestFile kFiles[] = { {true, NULL, 0, kDummyURL1, kTemporary}, }; @@ -242,8 +244,8 @@ TEST_F(SandboxQuotaClientTest, NoFileTest) { } } -TEST_F(SandboxQuotaClientTest, OneFileTest) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); +TEST_F(FileSystemQuotaClientTest, OneFileTest) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); const TestFile kFiles[] = { {true, NULL, 0, kDummyURL1, kTemporary}, {false, "foo", 4921, kDummyURL1, kTemporary}, @@ -256,8 +258,8 @@ TEST_F(SandboxQuotaClientTest, OneFileTest) { } } -TEST_F(SandboxQuotaClientTest, TwoFilesTest) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); +TEST_F(FileSystemQuotaClientTest, TwoFilesTest) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); const TestFile kFiles[] = { {true, NULL, 0, kDummyURL1, kTemporary}, {false, "foo", 10310, kDummyURL1, kTemporary}, @@ -271,8 +273,8 @@ TEST_F(SandboxQuotaClientTest, TwoFilesTest) { } } -TEST_F(SandboxQuotaClientTest, EmptyFilesTest) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); +TEST_F(FileSystemQuotaClientTest, EmptyFilesTest) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); const TestFile kFiles[] = { {true, NULL, 0, kDummyURL1, kTemporary}, {false, "foo", 0, kDummyURL1, kTemporary}, @@ -287,8 +289,8 @@ TEST_F(SandboxQuotaClientTest, EmptyFilesTest) { } } -TEST_F(SandboxQuotaClientTest, SubDirectoryTest) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); +TEST_F(FileSystemQuotaClientTest, SubDirectoryTest) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); const TestFile kFiles[] = { {true, NULL, 0, kDummyURL1, kTemporary}, {true, "dirtest", 0, kDummyURL1, kTemporary}, @@ -303,8 +305,8 @@ TEST_F(SandboxQuotaClientTest, SubDirectoryTest) { } } -TEST_F(SandboxQuotaClientTest, MultiTypeTest) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); +TEST_F(FileSystemQuotaClientTest, MultiTypeTest) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); const TestFile kFiles[] = { {true, NULL, 0, kDummyURL1, kTemporary}, {true, "dirtest", 0, kDummyURL1, kTemporary}, @@ -325,8 +327,8 @@ TEST_F(SandboxQuotaClientTest, MultiTypeTest) { } } -TEST_F(SandboxQuotaClientTest, MultiDomainTest) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); +TEST_F(FileSystemQuotaClientTest, MultiDomainTest) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); const TestFile kFiles[] = { {true, NULL, 0, kDummyURL1, kTemporary}, {true, "dir1", 0, kDummyURL1, kTemporary}, @@ -359,8 +361,8 @@ TEST_F(SandboxQuotaClientTest, MultiDomainTest) { } } -TEST_F(SandboxQuotaClientTest, GetUsage_MultipleTasks) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); +TEST_F(FileSystemQuotaClientTest, GetUsage_MultipleTasks) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); const TestFile kFiles[] = { {true, NULL, 0, kDummyURL1, kTemporary}, {false, "foo", 11, kDummyURL1, kTemporary}, @@ -387,8 +389,8 @@ TEST_F(SandboxQuotaClientTest, GetUsage_MultipleTasks) { EXPECT_EQ(2, additional_callback_count()); } -TEST_F(SandboxQuotaClientTest, GetOriginsForType) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); +TEST_F(FileSystemQuotaClientTest, GetOriginsForType) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); const TestFile kFiles[] = { {true, NULL, 0, kDummyURL1, kTemporary}, {true, NULL, 0, kDummyURL2, kTemporary}, @@ -403,8 +405,8 @@ TEST_F(SandboxQuotaClientTest, GetOriginsForType) { EXPECT_TRUE(origins.find(GURL(kDummyURL3)) == origins.end()); } -TEST_F(SandboxQuotaClientTest, GetOriginsForHost) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); +TEST_F(FileSystemQuotaClientTest, GetOriginsForHost) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); const char* kURL1 = "http://foo.com/"; const char* kURL2 = "https://foo.com/"; const char* kURL3 = "http://foo.com:1/"; @@ -429,8 +431,8 @@ TEST_F(SandboxQuotaClientTest, GetOriginsForHost) { EXPECT_TRUE(origins.find(GURL(kURL5)) == origins.end()); // Different type. } -TEST_F(SandboxQuotaClientTest, IncognitoTest) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(true)); +TEST_F(FileSystemQuotaClientTest, IncognitoTest) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(true)); const TestFile kFiles[] = { {true, NULL, 0, kDummyURL1, kTemporary}, {false, "foo", 10, kDummyURL1, kTemporary}, @@ -448,8 +450,8 @@ TEST_F(SandboxQuotaClientTest, IncognitoTest) { EXPECT_EQ(0U, origins.size()); } -TEST_F(SandboxQuotaClientTest, DeleteOriginTest) { - scoped_ptr<SandboxQuotaClient> quota_client(NewQuotaClient(false)); +TEST_F(FileSystemQuotaClientTest, DeleteOriginTest) { + scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); const TestFile kFiles[] = { {true, NULL, 0, "http://foo.com/", kTemporary}, {false, "a", 1, "http://foo.com/", kTemporary}, diff --git a/webkit/fileapi/file_system_quota_util.h b/webkit/fileapi/file_system_quota_util.h new file mode 100644 index 0000000..73e3373 --- /dev/null +++ b/webkit/fileapi/file_system_quota_util.h @@ -0,0 +1,72 @@ +// Copyright (c) 2011 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. + +#ifndef WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_UTIL_H_ +#define WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_UTIL_H_ + +#include <set> +#include <string> + +#include "base/basictypes.h" +#include "googleurl/src/gurl.h" +#include "webkit/fileapi/file_system_types.h" + +namespace quota { +class QuotaManagerProxy; +} + +namespace fileapi { + +// An abstract interface that provides common quota-related utility functions +// for internal filesystem modules. The main consumer of this class is +// file_system_quota_client and quota_file_util. +// All the methods of this class are synchronous and need to be called on +// the thread that the method name implies. +class FileSystemQuotaUtil { + public: + // Called by quota client. + virtual void GetOriginsForTypeOnFileThread(fileapi::FileSystemType type, + std::set<GURL>* origins) = 0; + + // Called by quota client. + virtual void GetOriginsForHostOnFileThread(fileapi::FileSystemType type, + const std::string& host, + std::set<GURL>* origins) = 0; + + // Called by quota client. + // Returns the amount of data used for the origin for usage tracking. + virtual int64 GetOriginUsageOnFileThread(const GURL& origin_url, + fileapi::FileSystemType type) = 0; + + // Called by quota file util. + // Returns the amount of data used for the origin for usage tracking. + virtual void UpdateOriginUsageOnFileThread(quota::QuotaManagerProxy* proxy, + const GURL& origin_url, + fileapi::FileSystemType type, + int64 delta) = 0; + + // Called by file_system_operation. + // Called when a read operation accesses the origin's storage data. + virtual void NotifyOriginWasAccessedOnIOThread( + quota::QuotaManagerProxy* proxy, + const GURL& origin_url, + fileapi::FileSystemType type) = 0; + + // Called by quota_file_util or file_writer_delegate. + // Called before an write operation modifies the origin's storage data. + virtual void StartUpdateOriginOnFileThread(const GURL& origin_url, + fileapi::FileSystemType type) = 0; + + // Called by quota_file_util or file_writer_delegate. + // Called after an write operation modifies the origin's storage data. + virtual void EndUpdateOriginOnFileThread(const GURL& origin_url, + fileapi::FileSystemType type) = 0; + + protected: + virtual ~FileSystemQuotaUtil() {} +}; + +} // namespace fileapi + +#endif // WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_UTIL_H_ diff --git a/webkit/fileapi/sandbox_mount_point_provider.cc b/webkit/fileapi/sandbox_mount_point_provider.cc index d344e63..8f6d776 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.cc +++ b/webkit/fileapi/sandbox_mount_point_provider.cc @@ -14,13 +14,18 @@ #include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "googleurl/src/gurl.h" +#include "net/base/net_util.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "webkit/fileapi/file_system_path_manager.h" +#include "webkit/fileapi/file_system_usage_cache.h" #include "webkit/fileapi/file_system_util.h" #include "webkit/fileapi/sandbox_mount_point_provider.h" #include "webkit/glue/webkit_glue.h" +#include "webkit/quota/quota_manager.h" + +using quota::QuotaManagerProxy; namespace { @@ -328,6 +333,132 @@ FilePath SandboxMountPointProvider::GetBaseDirectoryForOriginAndType( return GetBaseDirectoryForOrigin(origin_url).AppendASCII(type_string); } +bool SandboxMountPointProvider::DeleteOriginDataOnFileThread( + QuotaManagerProxy* proxy, const GURL& origin_url, + fileapi::FileSystemType type) { + FilePath path_for_origin = GetBaseDirectoryForOriginAndType(origin_url, + type); + if (!file_util::PathExists(path_for_origin)) + return true; + + int64 usage = GetOriginUsageOnFileThread(origin_url, type); + bool result = file_util::Delete(path_for_origin, true /* recursive */); + if (result && proxy) { + proxy->NotifyStorageModified( + quota::QuotaClient::kFileSystem, + origin_url, + FileSystemTypeToQuotaStorageType(type), + -usage); + } + return result; +} + +void SandboxMountPointProvider::GetOriginsForTypeOnFileThread( + fileapi::FileSystemType type, std::set<GURL>* origins) { + DCHECK(type == fileapi::kFileSystemTypeTemporary || + type == fileapi::kFileSystemTypePersistent); + DCHECK(origins); + scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator()); + GURL origin; + while (!(origin = enumerator->Next()).is_empty()) { + if (enumerator->HasFileSystemType(type)) + origins->insert(origin); + } +} + +void SandboxMountPointProvider::GetOriginsForHostOnFileThread( + fileapi::FileSystemType type, const std::string& host, + std::set<GURL>* origins) { + DCHECK(type == fileapi::kFileSystemTypeTemporary || + type == fileapi::kFileSystemTypePersistent); + DCHECK(origins); + scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator()); + GURL origin; + while (!(origin = enumerator->Next()).is_empty()) { + if (host == net::GetHostOrSpecFromURL(origin) && + enumerator->HasFileSystemType(type)) + origins->insert(origin); + } +} + +int64 SandboxMountPointProvider::GetOriginUsageOnFileThread( + const GURL& origin_url, fileapi::FileSystemType type) { + DCHECK(type == fileapi::kFileSystemTypeTemporary || + type == fileapi::kFileSystemTypePersistent); + FilePath base_path = GetBaseDirectoryForOriginAndType(origin_url, type); + if (!file_util::DirectoryExists(base_path)) + return 0; + + FilePath usage_file_path = base_path.AppendASCII( + FileSystemUsageCache::kUsageFileName); + int32 dirty_status = FileSystemUsageCache::GetDirty(usage_file_path); + bool visited = (visited_origins_.find(origin_url) != visited_origins_.end()); + visited_origins_.insert(origin_url); + if (dirty_status == 0 || (dirty_status > 0 && visited)) { + // The usage cache is clean (dirty == 0) or the origin is already + // initialized and running. Read the cache file to get the usage. + return FileSystemUsageCache::GetUsage(usage_file_path); + } + // The usage cache has not been initialized or the cache is dirty. + // Get the directory size now and update the cache. + if (FileSystemUsageCache::Exists(usage_file_path)) + FileSystemUsageCache::Delete(usage_file_path); + int64 usage = file_util::ComputeDirectorySize(base_path); + // The result of ComputeDirectorySize does not include .usage file size. + usage += FileSystemUsageCache::kUsageFileSize; + // This clears the dirty flag too. + FileSystemUsageCache::UpdateUsage(usage_file_path, usage); + return usage; +} + +void SandboxMountPointProvider::NotifyOriginWasAccessedOnIOThread( + QuotaManagerProxy* proxy, const GURL& origin_url, + fileapi::FileSystemType type) { + DCHECK(type == fileapi::kFileSystemTypeTemporary || + type == fileapi::kFileSystemTypePersistent); + if (proxy) { + proxy->NotifyStorageAccessed( + quota::QuotaClient::kFileSystem, + origin_url, + FileSystemTypeToQuotaStorageType(type)); + } +} + +void SandboxMountPointProvider::UpdateOriginUsageOnFileThread( + QuotaManagerProxy* proxy, const GURL& origin_url, + fileapi::FileSystemType type, int64 delta) { + DCHECK(type == fileapi::kFileSystemTypeTemporary || + type == fileapi::kFileSystemTypePersistent); + FilePath usage_file_path = GetUsageCachePathForOriginAndType( + origin_url, type); + FileSystemUsageCache::AtomicUpdateUsageByDelta(usage_file_path, delta); + if (proxy) { + proxy->NotifyStorageModified( + quota::QuotaClient::kFileSystem, + origin_url, + FileSystemTypeToQuotaStorageType(type), + delta); + } +} + +void SandboxMountPointProvider::StartUpdateOriginOnFileThread( + const GURL& origin_url, fileapi::FileSystemType type) { + DCHECK(type == fileapi::kFileSystemTypeTemporary || + type == fileapi::kFileSystemTypePersistent); + FilePath usage_file_path = GetUsageCachePathForOriginAndType( + origin_url, type); + FileSystemUsageCache::IncrementDirty(usage_file_path); +} + +void SandboxMountPointProvider::EndUpdateOriginOnFileThread( + const GURL& origin_url, fileapi::FileSystemType type) { + DCHECK(type == fileapi::kFileSystemTypeTemporary || + type == fileapi::kFileSystemTypePersistent); + FilePath usage_file_path = GetUsageCachePathForOriginAndType( + origin_url, type); + FileSystemUsageCache::DecrementDirty(usage_file_path); +} + bool SandboxMountPointProvider::GetOriginBasePathAndName( const GURL& origin_url, FilePath* origin_base_path, @@ -354,4 +485,10 @@ bool SandboxMountPointProvider::GetOriginBasePathAndName( return true; } +FilePath SandboxMountPointProvider::GetUsageCachePathForOriginAndType( + const GURL& origin_url, fileapi::FileSystemType type) const { + FilePath base_path = GetBaseDirectoryForOriginAndType(origin_url, type); + return base_path.AppendASCII(FileSystemUsageCache::kUsageFileName); +} + } // namespace fileapi diff --git a/webkit/fileapi/sandbox_mount_point_provider.h b/webkit/fileapi/sandbox_mount_point_provider.h index 071a6fa..3dd8140 100644 --- a/webkit/fileapi/sandbox_mount_point_provider.h +++ b/webkit/fileapi/sandbox_mount_point_provider.h @@ -5,6 +5,7 @@ #ifndef WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ #define WEBKIT_FILEAPI_SANDBOX_MOUNT_POINT_PROVIDER_H_ +#include <set> #include <string> #include <vector> @@ -12,15 +13,26 @@ #include "base/memory/scoped_ptr.h" #include "googleurl/src/gurl.h" #include "webkit/fileapi/file_system_mount_point_provider.h" +#include "webkit/fileapi/file_system_quota_util.h" #include "webkit/fileapi/obfuscated_file_system_file_util.h" namespace base { class MessageLoopProxy; } +namespace quota { +class QuotaManagerProxy; +} + namespace fileapi { -class SandboxMountPointProvider : public FileSystemMountPointProvider { +// An interface to construct or crack sandboxed filesystem paths. +// Currently each sandboxed filesystem path looks like (soon will be changed): +// <profile_dir>/FileSystem/<origin_identifier>/<type>/chrome-<unique>/... +// <type> is either one of "Temporary" or "Persistent". +class SandboxMountPointProvider + : public FileSystemMountPointProvider, + public FileSystemQuotaUtil { public: // Origin enumerator interface. // An instance of this interface is assumed to be called on the file thread. @@ -100,6 +112,42 @@ class SandboxMountPointProvider : public FileSystemMountPointProvider { return sandbox_file_util_.get(); } + // Deletes the data on the origin and reports the amount of deleted data + // to the quota manager via |proxy|. + bool DeleteOriginDataOnFileThread( + quota::QuotaManagerProxy* proxy, + const GURL& origin_url, + fileapi::FileSystemType type); + + // Quota util methods. + virtual void GetOriginsForTypeOnFileThread( + fileapi::FileSystemType type, + std::set<GURL>* origins) OVERRIDE; + virtual void GetOriginsForHostOnFileThread( + fileapi::FileSystemType type, + const std::string& host, + std::set<GURL>* origins) OVERRIDE; + virtual int64 GetOriginUsageOnFileThread( + const GURL& origin_url, + fileapi::FileSystemType type) OVERRIDE; + virtual void NotifyOriginWasAccessedOnIOThread( + quota::QuotaManagerProxy* proxy, + const GURL& origin_url, + fileapi::FileSystemType type) OVERRIDE; + virtual void UpdateOriginUsageOnFileThread( + quota::QuotaManagerProxy* proxy, + const GURL& origin_url, + fileapi::FileSystemType type, + int64 delta) OVERRIDE; + virtual void StartUpdateOriginOnFileThread( + const GURL& origin_url, + fileapi::FileSystemType type) OVERRIDE; + virtual void EndUpdateOriginOnFileThread( + const GURL& origin_url, + fileapi::FileSystemType type) OVERRIDE; + + FileSystemQuotaUtil* quota_util() { return this; } + private: bool GetOriginBasePathAndName( const GURL& origin_url, @@ -107,6 +155,11 @@ class SandboxMountPointProvider : public FileSystemMountPointProvider { FileSystemType type, std::string* name); + // Returns a path to the usage cache file. + FilePath GetUsageCachePathForOriginAndType( + const GURL& origin_url, + fileapi::FileSystemType type) const; + class GetFileSystemRootPathTask; // The path_manager_ isn't owned by this instance; this instance is owned by @@ -119,6 +172,9 @@ class SandboxMountPointProvider : public FileSystemMountPointProvider { scoped_ptr<ObfuscatedFileSystemFileUtil> sandbox_file_util_; + // Acccessed only on the file thread. + std::set<GURL> visited_origins_; + DISALLOW_COPY_AND_ASSIGN(SandboxMountPointProvider); }; diff --git a/webkit/fileapi/webkit_fileapi.gypi b/webkit/fileapi/webkit_fileapi.gypi index 6f03750..d23a1f9 100644 --- a/webkit/fileapi/webkit_fileapi.gypi +++ b/webkit/fileapi/webkit_fileapi.gypi @@ -37,6 +37,9 @@ 'file_system_origin_database.h', 'file_system_path_manager.cc', 'file_system_path_manager.h', + 'file_system_quota_util.h', + 'file_system_quota_client.cc', + 'file_system_quota_client.h', 'file_system_types.h', 'file_system_url_request_job.cc', 'file_system_url_request_job.h', @@ -56,8 +59,6 @@ 'quota_file_util.h', 'sandbox_mount_point_provider.cc', 'sandbox_mount_point_provider.h', - 'sandbox_quota_client.cc', - 'sandbox_quota_client.h', 'webfilewriter_base.cc', 'webfilewriter_base.h', ], diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi index 2cfb78a..a14fa4a 100644 --- a/webkit/tools/test_shell/test_shell.gypi +++ b/webkit/tools/test_shell/test_shell.gypi @@ -382,13 +382,13 @@ '../../fileapi/file_system_operation_unittest.cc', '../../fileapi/file_system_origin_database_unittest.cc', '../../fileapi/file_system_path_manager_unittest.cc', + '../../fileapi/file_system_quota_client_unittest.cc', '../../fileapi/file_system_usage_cache_unittest.cc', '../../fileapi/file_system_util_unittest.cc', '../../fileapi/local_file_system_file_util_unittest.cc', '../../fileapi/obfuscated_file_system_file_util_unittest.cc', '../../fileapi/quota_file_util_unittest.cc', '../../fileapi/sandbox_mount_point_provider_unittest.cc', - '../../fileapi/sandbox_quota_client_unittest.cc', '../../fileapi/webfilewriter_base_unittest.cc', '../../glue/bookmarklet_unittest.cc', '../../glue/context_menu_unittest.cc', |