Commit f711488d authored by serya@chromium.org's avatar serya@chromium.org

Not creating ClientUsageTracker for unsupported storage type.

Extracted from https://chromiumcodereview.appspot.com/23240002/

Currently we create all usage trackers for each pair QuotaClient/StorageType.
Most clients only support one storage type and filesystem support variable
list of types (it doesn't have kStorageTypeSyncable in unittests).

If filesystem has no syncable storage backend it not useless to keep create ClientUsageTracker. This tracker fails when GetHostUsage is invoked. So let's don't create it.

BUG=281252

Review URL: https://chromiumcodereview.appspot.com/23545016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221244 0039d316-1c4b-4281-b951-d872f2087c98
parent 770af9de
......@@ -175,4 +175,8 @@ void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin,
callback);
}
bool IndexedDBQuotaClient::DoesSupport(quota::StorageType type) const {
return type == quota::kStorageTypeTemporary;
}
} // namespace content
......@@ -43,6 +43,7 @@ class IndexedDBQuotaClient : public quota::QuotaClient,
virtual void DeleteOriginData(const GURL& origin,
quota::StorageType type,
const DeletionCallback& callback) OVERRIDE;
virtual bool DoesSupport(quota::StorageType type) const OVERRIDE;
private:
scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
......
......@@ -139,6 +139,10 @@ void AppCacheQuotaClient::DeleteOriginData(const GURL& origin,
origin, GetServiceDeleteCallback()->callback());
}
bool AppCacheQuotaClient::DoesSupport(quota::StorageType type) const {
return type == quota::kStorageTypeTemporary;
}
void AppCacheQuotaClient::DidDeleteAppCachesForOrigin(int rv) {
DCHECK(service_);
if (quota_manager_is_destroyed_)
......
......@@ -50,6 +50,7 @@ class AppCacheQuotaClient : public quota::QuotaClient {
virtual void DeleteOriginData(const GURL& origin,
quota::StorageType type,
const DeletionCallback& callback) OVERRIDE;
virtual bool DoesSupport(quota::StorageType type) const OVERRIDE;
private:
friend class AppCacheService; // for NotifyAppCacheIsDestroyed
......
......@@ -215,4 +215,8 @@ void DatabaseQuotaClient::DeleteOriginData(
delete_callback);
}
bool DatabaseQuotaClient::DoesSupport(quota::StorageType type) const {
return type == quota::kStorageTypeTemporary;
}
} // namespace webkit_database
......@@ -39,10 +39,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE DatabaseQuotaClient
const GetOriginsCallback& callback) OVERRIDE;
virtual void GetOriginsForHost(quota::StorageType type,
const std::string& host,
const GetOriginsCallback& callback) OVERRIDE;
const GetOriginsCallback& callback) OVERRIDE;
virtual void DeleteOriginData(const GURL& origin,
quota::StorageType type,
const DeletionCallback& callback) OVERRIDE;
virtual bool DoesSupport(quota::StorageType type) const OVERRIDE;
private:
scoped_refptr<base::MessageLoopProxy> db_tracker_thread_;
scoped_refptr<DatabaseTracker> db_tracker_; // only used on its thread
......
......@@ -121,11 +121,6 @@ FileSystemContext::FileSystemContext(
external_mount_points_(external_mount_points),
partition_path_(partition_path),
operation_runner_(new FileSystemOperationRunner(this)) {
if (quota_manager_proxy) {
quota_manager_proxy->RegisterClient(CreateQuotaClient(
this, options.is_incognito()));
}
RegisterBackend(sandbox_backend_.get());
RegisterBackend(isolated_backend_.get());
......@@ -135,6 +130,12 @@ FileSystemContext::FileSystemContext(
RegisterBackend(*iter);
}
if (quota_manager_proxy) {
// Quota client assumes all backends have registered.
quota_manager_proxy->RegisterClient(CreateQuotaClient(
this, options.is_incognito()));
}
sandbox_backend_->Initialize(this);
isolated_backend_->Initialize(this);
for (ScopedVector<FileSystemBackend>::const_iterator iter =
......@@ -222,7 +223,8 @@ FileSystemBackend* FileSystemContext::GetFileSystemBackend(
}
bool FileSystemContext::IsSandboxFileSystem(FileSystemType type) const {
return GetQuotaUtil(type) != NULL;
FileSystemBackendMap::const_iterator found = backend_map_.find(type);
return found != backend_map_.end() && found->second->GetQuotaUtil();
}
const UpdateObserverList* FileSystemContext::GetUpdateObservers(
......
......@@ -197,6 +197,12 @@ void FileSystemQuotaClient::DeleteOriginData(
callback);
}
bool FileSystemQuotaClient::DoesSupport(quota::StorageType storage_type) const {
FileSystemType type = QuotaStorageTypeToFileSystemType(storage_type);
DCHECK(type != kFileSystemTypeUnknown);
return file_system_context_->IsSandboxFileSystem(type);
}
base::SequencedTaskRunner* FileSystemQuotaClient::file_task_runner() const {
return file_system_context_->default_file_task_runner();
}
......
......@@ -56,6 +56,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemQuotaClient
const GURL& origin,
quota::StorageType type,
const DeletionCallback& callback) OVERRIDE;
virtual bool DoesSupport(quota::StorageType type) const OVERRIDE;
private:
base::SequencedTaskRunner* file_task_runner() const;
......
......@@ -121,6 +121,10 @@ void MockStorageClient::DeleteOriginData(
weak_factory_.GetWeakPtr(), origin, type, callback));
}
bool MockStorageClient::DoesSupport(quota::StorageType type) const {
return true;
}
void MockStorageClient::RunGetOriginUsage(
const GURL& origin_url, StorageType type,
const GetUsageCallback& callback) {
......
......@@ -59,6 +59,7 @@ class MockStorageClient : public QuotaClient {
virtual void DeleteOriginData(const GURL& origin,
StorageType type,
const DeletionCallback& callback) OVERRIDE;
virtual bool DoesSupport(quota::StorageType type) const OVERRIDE;
private:
void RunGetOriginUsage(const GURL& origin_url,
......
......@@ -69,6 +69,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT QuotaClient {
virtual void DeleteOriginData(const GURL& origin,
StorageType type,
const DeletionCallback& callback) = 0;
virtual bool DoesSupport(StorageType type) const = 0;
};
// TODO(dmikurube): Replace it to std::vector for efficiency.
......
......@@ -78,8 +78,10 @@ UsageTracker::UsageTracker(const QuotaClientList& clients,
for (QuotaClientList::const_iterator iter = clients.begin();
iter != clients.end();
++iter) {
client_tracker_map_[(*iter)->id()] =
new ClientUsageTracker(this, *iter, type, special_storage_policy);
if ((*iter)->DoesSupport(type)) {
client_tracker_map_[(*iter)->id()] =
new ClientUsageTracker(this, *iter, type, special_storage_policy);
}
}
}
......
......@@ -89,6 +89,10 @@ class MockQuotaClient : public QuotaClient {
FROM_HERE, base::Bind(callback, kQuotaStatusOk));
}
virtual bool DoesSupport(quota::StorageType type) const OVERRIDE {
return type == quota::kStorageTypeTemporary;
}
int64 GetUsage(const GURL& origin) {
UsageMap::const_iterator found = usage_map_.find(origin);
if (found == usage_map_.end())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment