From 4ac23ad25a6467cc360cc10bd05946a0936cac5c Mon Sep 17 00:00:00 2001 From: "mkwst@chromium.org" Date: Fri, 5 Aug 2011 08:39:54 +0000 Subject: Quota: Add quota::StorageType to the GetOriginsCallback definition. BUG=90996 TEST=test_shell_tests Review URL: http://codereview.chromium.org/7533013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95591 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/database/database_quota_client.cc | 38 ++++++++++++++--------- webkit/database/database_quota_client.h | 17 +++++----- webkit/database/database_quota_client_unittest.cc | 5 ++- 3 files changed, 38 insertions(+), 22 deletions(-) (limited to 'webkit/database') diff --git a/webkit/database/database_quota_client.cc b/webkit/database/database_quota_client.cc index 4ebfaf8..52f1fd5 100644 --- a/webkit/database/database_quota_client.cc +++ b/webkit/database/database_quota_client.cc @@ -89,8 +89,10 @@ class DatabaseQuotaClient::GetAllOriginsTask : public GetOriginsTaskBase { public: GetAllOriginsTask( DatabaseQuotaClient* client, - base::MessageLoopProxy* db_tracker_thread) - : GetOriginsTaskBase(client, db_tracker_thread) { + base::MessageLoopProxy* db_tracker_thread, + quota::StorageType type) + : GetOriginsTaskBase(client, db_tracker_thread), + type_(type) { } protected: @@ -98,8 +100,11 @@ class DatabaseQuotaClient::GetAllOriginsTask : public GetOriginsTaskBase { return true; } virtual void Completed() OVERRIDE { - client_->DidGetAllOrigins(origins_); + client_->DidGetAllOrigins(origins_, type_); } + + private: + quota::StorageType type_; }; class DatabaseQuotaClient::GetOriginsForHostTask : public GetOriginsTaskBase { @@ -107,9 +112,11 @@ class DatabaseQuotaClient::GetOriginsForHostTask : public GetOriginsTaskBase { GetOriginsForHostTask( DatabaseQuotaClient* client, base::MessageLoopProxy* db_tracker_thread, - const std::string& host) + const std::string& host, + quota::StorageType type) : GetOriginsTaskBase(client, db_tracker_thread), - host_(host) { + host_(host), + type_(type) { } private: @@ -117,9 +124,10 @@ class DatabaseQuotaClient::GetOriginsForHostTask : public GetOriginsTaskBase { return host_ == net::GetHostOrSpecFromURL(origin); } virtual void Completed() OVERRIDE { - client_->DidGetOriginsForHost(host_, origins_); + client_->DidGetOriginsForHost(host_, origins_, type_); } std::string host_; + quota::StorageType type_; }; class DatabaseQuotaClient::DeleteOriginTask : public HelperTask { @@ -222,13 +230,13 @@ void DatabaseQuotaClient::GetOriginsForType( // All databases are in the temp namespace for now. if (type != quota::kStorageTypeTemporary) { - callback->Run(std::set()); + callback->Run(std::set(), type); return; } if (origins_for_type_callbacks_.Add(callback.release())) { scoped_refptr task( - new GetAllOriginsTask(this, db_tracker_thread_)); + new GetAllOriginsTask(this, db_tracker_thread_, type)); task->Start(); } } @@ -243,13 +251,13 @@ void DatabaseQuotaClient::GetOriginsForHost( // All databases are in the temp namespace for now. if (type != quota::kStorageTypeTemporary) { - callback->Run(std::set()); + callback->Run(std::set(), type); return; } if (origins_for_host_callbacks_.Add(host, callback.release())) { scoped_refptr task( - new GetOriginsForHostTask(this, db_tracker_thread_, host)); + new GetOriginsForHostTask(this, db_tracker_thread_, host, type)); task->Start(); } } @@ -279,15 +287,17 @@ void DatabaseQuotaClient::DidGetOriginUsage( usage_for_origin_callbacks_.Run(origin_url, usage); } -void DatabaseQuotaClient::DidGetAllOrigins(const std::set& origins) { +void DatabaseQuotaClient::DidGetAllOrigins(const std::set& origins, + quota::StorageType type) { DCHECK(origins_for_type_callbacks_.HasCallbacks()); - origins_for_type_callbacks_.Run(origins); + origins_for_type_callbacks_.Run(origins, type); } void DatabaseQuotaClient::DidGetOriginsForHost( - const std::string& host, const std::set& origins) { + const std::string& host, const std::set& origins, + quota::StorageType type) { DCHECK(origins_for_host_callbacks_.HasCallbacks(host)); - origins_for_host_callbacks_.Run(host, origins); + origins_for_host_callbacks_.Run(host, origins, type); } } // namespace webkit_database diff --git a/webkit/database/database_quota_client.h b/webkit/database/database_quota_client.h index acc839e..fb37ff61 100644 --- a/webkit/database/database_quota_client.h +++ b/webkit/database/database_quota_client.h @@ -56,20 +56,23 @@ class DatabaseQuotaClient : public quota::QuotaClient, GURL, // origin int64 > UsageForOriginCallbackMap; - typedef quota::CallbackQueue1 + typedef quota::CallbackQueue2 & + const std::set&, + quota::StorageType > OriginsForTypeCallbackQueue; - typedef quota::CallbackQueueMap1 + typedef quota::CallbackQueueMap2 & + const std::set&, + quota::StorageType > OriginsForHostCallbackMap; void DidGetOriginUsage(const GURL& origin_url, int64 usage); - void DidGetAllOrigins(const std::set& origins); - void DidGetOriginsForHost( - const std::string& host, const std::set& origins); + void DidGetAllOrigins(const std::set& origins, quota::StorageType type); + void DidGetOriginsForHost(const std::string& host, + const std::set& origins, + quota::StorageType type); scoped_refptr db_tracker_thread_; scoped_refptr db_tracker_; // only used on its thread diff --git a/webkit/database/database_quota_client_unittest.cc b/webkit/database/database_quota_client_unittest.cc index 9bbae9e..cc2762a 100644 --- a/webkit/database/database_quota_client_unittest.cc +++ b/webkit/database/database_quota_client_unittest.cc @@ -184,8 +184,10 @@ class DatabaseQuotaClientTest : public testing::Test { usage_ = usage; } - void OnGetOriginsComplete(const std::set& origins) { + void OnGetOriginsComplete(const std::set& origins, + quota::StorageType type) { origins_ = origins; + type_ = type; } void OnDeleteOriginDataComplete(quota::QuotaStatusCode status) { @@ -194,6 +196,7 @@ class DatabaseQuotaClientTest : public testing::Test { int64 usage_; std::set origins_; + quota::StorageType type_; quota::QuotaStatusCode delete_status_; scoped_refptr mock_tracker_; base::ScopedCallbackFactory callback_factory_; -- cgit v1.1