summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authormkwst@chromium.org <mkwst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-05 08:39:54 +0000
committermkwst@chromium.org <mkwst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-05 08:39:54 +0000
commit4ac23ad25a6467cc360cc10bd05946a0936cac5c (patch)
tree6a9fd5641ce5143ddb891a3ca16bf558afb4736f /webkit
parent90a47480a17322e3c095b9cc7eefd5498224f1a4 (diff)
downloadchromium_src-4ac23ad25a6467cc360cc10bd05946a0936cac5c.zip
chromium_src-4ac23ad25a6467cc360cc10bd05946a0936cac5c.tar.gz
chromium_src-4ac23ad25a6467cc360cc10bd05946a0936cac5c.tar.bz2
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
Diffstat (limited to 'webkit')
-rw-r--r--webkit/appcache/appcache_quota_client.cc11
-rw-r--r--webkit/appcache/appcache_quota_client_unittest.cc5
-rw-r--r--webkit/database/database_quota_client.cc38
-rw-r--r--webkit/database/database_quota_client.h17
-rw-r--r--webkit/database/database_quota_client_unittest.cc5
-rw-r--r--webkit/fileapi/file_system_quota_client.cc10
-rw-r--r--webkit/fileapi/file_system_quota_client.h10
-rw-r--r--webkit/fileapi/file_system_quota_client_unittest.cc5
-rw-r--r--webkit/quota/mock_quota_manager.cc9
-rw-r--r--webkit/quota/mock_quota_manager_unittest.cc95
-rw-r--r--webkit/quota/mock_storage_client.cc4
-rw-r--r--webkit/quota/quota_client.h3
-rw-r--r--webkit/quota/quota_manager.cc4
-rw-r--r--webkit/quota/quota_manager_unittest.cc10
-rw-r--r--webkit/quota/quota_types.h2
-rw-r--r--webkit/quota/usage_tracker.cc2
16 files changed, 139 insertions, 91 deletions
diff --git a/webkit/appcache/appcache_quota_client.cc b/webkit/appcache/appcache_quota_client.cc
index 14bdb2b..db41d5e 100644
--- a/webkit/appcache/appcache_quota_client.cc
+++ b/webkit/appcache/appcache_quota_client.cc
@@ -103,7 +103,7 @@ void AppCacheQuotaClient::GetOriginsForHost(
GetOriginsCallback* callback_ptr) {
DCHECK(callback_ptr);
if (host.empty()) {
- callback_ptr->Run(std::set<GURL>());
+ callback_ptr->Run(std::set<GURL>(), type);
delete callback_ptr;
return;
}
@@ -166,7 +166,7 @@ void AppCacheQuotaClient::GetOriginsHelper(
scoped_ptr<GetOriginsCallback> callback(callback_ptr);
if (!service_) {
- callback->Run(std::set<GURL>());
+ callback->Run(std::set<GURL>(), type);
return;
}
@@ -179,7 +179,7 @@ void AppCacheQuotaClient::GetOriginsHelper(
}
if (type == quota::kStorageTypePersistent) {
- callback->Run(std::set<GURL>());
+ callback->Run(std::set<GURL>(), type);
return;
}
@@ -190,7 +190,7 @@ void AppCacheQuotaClient::GetOriginsHelper(
if (opt_host.empty() || iter->first.host() == opt_host)
origins.insert(iter->first);
}
- callback->Run(origins);
+ callback->Run(origins, type);
}
void AppCacheQuotaClient::ProcessPendingRequests() {
@@ -220,7 +220,8 @@ void AppCacheQuotaClient::AbortPendingRequests() {
pending_usage_requests_.pop_front();
}
while (!pending_origins_requests_.empty()) {
- pending_origins_requests_.front().callback->Run(std::set<GURL>());
+ pending_origins_requests_.front().callback->Run(std::set<GURL>(),
+ pending_origins_requests_.front().type);
delete pending_origins_requests_.front().callback;
pending_origins_requests_.pop_front();
}
diff --git a/webkit/appcache/appcache_quota_client_unittest.cc b/webkit/appcache/appcache_quota_client_unittest.cc
index 9ab1b4b..fb967ac 100644
--- a/webkit/appcache/appcache_quota_client_unittest.cc
+++ b/webkit/appcache/appcache_quota_client_unittest.cc
@@ -137,9 +137,11 @@ class AppCacheQuotaClientTest : public testing::Test {
usage_ = usage;
}
- void OnGetOriginsComplete(const std::set<GURL>& origins) {
+ void OnGetOriginsComplete(const std::set<GURL>& origins,
+ quota::StorageType type) {
++num_get_origins_completions_;
origins_ = origins;
+ type_ = type;
}
void OnDeleteOriginDataComplete(quota::QuotaStatusCode status) {
@@ -149,6 +151,7 @@ class AppCacheQuotaClientTest : public testing::Test {
int64 usage_;
std::set<GURL> origins_;
+ quota::StorageType type_;
quota::QuotaStatusCode delete_status_;
int num_get_origin_usage_completions_;
int num_get_origins_completions_;
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<GURL>());
+ callback->Run(std::set<GURL>(), type);
return;
}
if (origins_for_type_callbacks_.Add(callback.release())) {
scoped_refptr<GetAllOriginsTask> 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<GURL>());
+ callback->Run(std::set<GURL>(), type);
return;
}
if (origins_for_host_callbacks_.Add(host, callback.release())) {
scoped_refptr<GetOriginsForHostTask> 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<GURL>& origins) {
+void DatabaseQuotaClient::DidGetAllOrigins(const std::set<GURL>& 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<GURL>& origins) {
+ const std::string& host, const std::set<GURL>& 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
<GetOriginsCallback*,
- const std::set<GURL>&
+ const std::set<GURL>&,
+ quota::StorageType
> OriginsForTypeCallbackQueue;
- typedef quota::CallbackQueueMap1
+ typedef quota::CallbackQueueMap2
<GetOriginsCallback*,
std::string, // host
- const std::set<GURL>&
+ const std::set<GURL>&,
+ quota::StorageType
> OriginsForHostCallbackMap;
void DidGetOriginUsage(const GURL& origin_url, int64 usage);
- void DidGetAllOrigins(const std::set<GURL>& origins);
- void DidGetOriginsForHost(
- const std::string& host, const std::set<GURL>& origins);
+ void DidGetAllOrigins(const std::set<GURL>& origins, quota::StorageType type);
+ void DidGetOriginsForHost(const std::string& host,
+ const std::set<GURL>& origins,
+ quota::StorageType type);
scoped_refptr<base::MessageLoopProxy> db_tracker_thread_;
scoped_refptr<DatabaseTracker> 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<GURL>& origins) {
+ void OnGetOriginsComplete(const std::set<GURL>& 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<GURL> origins_;
+ quota::StorageType type_;
quota::QuotaStatusCode delete_status_;
scoped_refptr<MockDatabaseTracker> mock_tracker_;
base::ScopedCallbackFactory<DatabaseQuotaClientTest> callback_factory_;
diff --git a/webkit/fileapi/file_system_quota_client.cc b/webkit/fileapi/file_system_quota_client.cc
index f3fec60..3f8e2e5 100644
--- a/webkit/fileapi/file_system_quota_client.cc
+++ b/webkit/fileapi/file_system_quota_client.cc
@@ -220,7 +220,7 @@ void FileSystemQuotaClient::GetOriginsForType(
scoped_ptr<GetOriginsCallback> callback(callback_ptr);
if (is_incognito_) {
// We don't support FileSystem in incognito mode yet.
- callback->Run(origins);
+ callback->Run(origins, storage_type);
return;
}
@@ -242,7 +242,7 @@ void FileSystemQuotaClient::GetOriginsForHost(
scoped_ptr<GetOriginsCallback> callback(callback_ptr);
if (is_incognito_) {
// We don't support FileSystem in incognito mode yet.
- callback->Run(origins);
+ callback->Run(origins, storage_type);
return;
}
@@ -280,13 +280,15 @@ void FileSystemQuotaClient::DidGetOriginUsage(
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);
+ pending_origins_for_type_callbacks_.Run(type, origins,
+ FileSystemTypeToQuotaStorageType(type));
}
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);
+ pending_origins_for_host_callbacks_.Run(type_and_host, origins,
+ FileSystemTypeToQuotaStorageType(type_and_host.first));
}
} // namespace fileapi
diff --git a/webkit/fileapi/file_system_quota_client.h b/webkit/fileapi/file_system_quota_client.h
index fb553c9..4045628 100644
--- a/webkit/fileapi/file_system_quota_client.h
+++ b/webkit/fileapi/file_system_quota_client.h
@@ -65,13 +65,15 @@ class FileSystemQuotaClient : public quota::QuotaClient,
TypeAndHostOrOrigin,
int64
> UsageCallbackMap;
- typedef quota::CallbackQueueMap1<GetOriginsCallback*,
+ typedef quota::CallbackQueueMap2<GetOriginsCallback*,
fileapi::FileSystemType,
- const std::set<GURL>&
+ const std::set<GURL>&,
+ quota::StorageType
> OriginsForTypeCallbackMap;
- typedef quota::CallbackQueueMap1<GetOriginsCallback*,
+ typedef quota::CallbackQueueMap2<GetOriginsCallback*,
TypeAndHostOrOrigin,
- const std::set<GURL>&
+ const std::set<GURL>&,
+ quota::StorageType
> OriginsForHostCallbackMap;
void DidGetOriginUsage(fileapi::FileSystemType type,
diff --git a/webkit/fileapi/file_system_quota_client_unittest.cc b/webkit/fileapi/file_system_quota_client_unittest.cc
index cbc3d75..2254f51 100644
--- a/webkit/fileapi/file_system_quota_client_unittest.cc
+++ b/webkit/fileapi/file_system_quota_client_unittest.cc
@@ -246,8 +246,10 @@ class FileSystemQuotaClientTest : public testing::Test {
usage_ = usage;
}
- void OnGetOrigins(const std::set<GURL>& origins) {
+ void OnGetOrigins(const std::set<GURL>& origins,
+ quota::StorageType type) {
origins_ = origins;
+ type_ = type;
}
void OnGetAdditionalUsage(int64 usage_unused) {
@@ -264,6 +266,7 @@ class FileSystemQuotaClientTest : public testing::Test {
int64 usage_;
int additional_callback_count_;
std::set<GURL> origins_;
+ quota::StorageType type_;
quota::QuotaStatusCode deletion_status_;
DISALLOW_COPY_AND_ASSIGN(FileSystemQuotaClientTest);
diff --git a/webkit/quota/mock_quota_manager.cc b/webkit/quota/mock_quota_manager.cc
index 9df3c6b..67f1ee3 100644
--- a/webkit/quota/mock_quota_manager.cc
+++ b/webkit/quota/mock_quota_manager.cc
@@ -22,24 +22,27 @@ class MockQuotaManager::GetModifiedSinceTask : public QuotaThreadTask {
public:
GetModifiedSinceTask(MockQuotaManager* manager,
const std::set<GURL>& origins,
+ StorageType type,
GetOriginsCallback* callback)
: QuotaThreadTask(manager, manager->io_thread_),
origins_(origins),
+ type_(type),
callback_(callback) {}
protected:
virtual void RunOnTargetThread() OVERRIDE {}
virtual void Completed() OVERRIDE {
- callback_->Run(origins_);
+ callback_->Run(origins_, type_);
}
virtual void Aborted() OVERRIDE {
- callback_->Run(std::set<GURL>());
+ callback_->Run(std::set<GURL>(), type_);
}
private:
std::set<GURL> origins_;
+ StorageType type_;
scoped_ptr<GetOriginsCallback> callback_;
DISALLOW_COPY_AND_ASSIGN(GetModifiedSinceTask);
@@ -116,7 +119,7 @@ void MockQuotaManager::GetOriginsModifiedSince(StorageType type,
if (current->type == type && current->modified >= modified_since)
origins_to_return.insert(current->origin);
}
- make_scoped_refptr(new GetModifiedSinceTask(this, origins_to_return,
+ make_scoped_refptr(new GetModifiedSinceTask(this, origins_to_return, type,
callback))->Start();
}
diff --git a/webkit/quota/mock_quota_manager_unittest.cc b/webkit/quota/mock_quota_manager_unittest.cc
index ee6a101..3416d5a 100644
--- a/webkit/quota/mock_quota_manager_unittest.cc
+++ b/webkit/quota/mock_quota_manager_unittest.cc
@@ -56,8 +56,9 @@ class MockQuotaManagerTest : public testing::Test {
&MockQuotaManagerTest::GotModifiedOrigins));
}
- void GotModifiedOrigins(const std::set<GURL>& origins) {
+ void GotModifiedOrigins(const std::set<GURL>& origins, StorageType type) {
origins_ = origins;
+ type_ = type;
}
void DeleteOriginData(const GURL& origin, StorageType type) {
@@ -71,18 +72,22 @@ class MockQuotaManagerTest : public testing::Test {
EXPECT_EQ(quota::kQuotaStatusOk, status);
}
- int GetDeletionCallbackCount() {
+ int deletion_callback_count() const {
return deletion_callback_count_;
}
- MockQuotaManager* GetManager() {
+ MockQuotaManager* manager() const {
return manager_.get();
}
- const std::set<GURL> GetOrigins() {
+ const std::set<GURL>& origins() const {
return origins_;
}
+ const StorageType type() const {
+ return type_;
+ }
+
private:
ScopedTempDir data_dir_;
base::ScopedCallbackFactory<MockQuotaManagerTest> callback_factory_;
@@ -92,45 +97,46 @@ class MockQuotaManagerTest : public testing::Test {
int deletion_callback_count_;
std::set<GURL> origins_;
+ StorageType type_;
DISALLOW_COPY_AND_ASSIGN(MockQuotaManagerTest);
};
TEST_F(MockQuotaManagerTest, BasicOriginManipulation) {
- EXPECT_FALSE(GetManager()->OriginHasData(kOrigin1, kStorageTypeTemporary));
- EXPECT_FALSE(GetManager()->OriginHasData(kOrigin2, kStorageTypeTemporary));
- EXPECT_FALSE(GetManager()->OriginHasData(kOrigin1, kStorageTypePersistent));
- EXPECT_FALSE(GetManager()->OriginHasData(kOrigin2, kStorageTypePersistent));
-
- GetManager()->AddOrigin(kOrigin1, kStorageTypeTemporary, base::Time::Now());
- EXPECT_TRUE(GetManager()->OriginHasData(kOrigin1, kStorageTypeTemporary));
- EXPECT_FALSE(GetManager()->OriginHasData(kOrigin2, kStorageTypeTemporary));
- EXPECT_FALSE(GetManager()->OriginHasData(kOrigin1, kStorageTypePersistent));
- EXPECT_FALSE(GetManager()->OriginHasData(kOrigin2, kStorageTypePersistent));
-
- GetManager()->AddOrigin(kOrigin1, kStorageTypePersistent, base::Time::Now());
- EXPECT_TRUE(GetManager()->OriginHasData(kOrigin1, kStorageTypeTemporary));
- EXPECT_FALSE(GetManager()->OriginHasData(kOrigin2, kStorageTypeTemporary));
- EXPECT_TRUE(GetManager()->OriginHasData(kOrigin1, kStorageTypePersistent));
- EXPECT_FALSE(GetManager()->OriginHasData(kOrigin2, kStorageTypePersistent));
-
- GetManager()->AddOrigin(kOrigin2, kStorageTypeTemporary, base::Time::Now());
- EXPECT_TRUE(GetManager()->OriginHasData(kOrigin1, kStorageTypeTemporary));
- EXPECT_TRUE(GetManager()->OriginHasData(kOrigin2, kStorageTypeTemporary));
- EXPECT_TRUE(GetManager()->OriginHasData(kOrigin1, kStorageTypePersistent));
- EXPECT_FALSE(GetManager()->OriginHasData(kOrigin2, kStorageTypePersistent));
+ EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kStorageTypeTemporary));
+ EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kStorageTypeTemporary));
+ EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kStorageTypePersistent));
+ EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kStorageTypePersistent));
+
+ manager()->AddOrigin(kOrigin1, kStorageTypeTemporary, base::Time::Now());
+ EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kStorageTypeTemporary));
+ EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kStorageTypeTemporary));
+ EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kStorageTypePersistent));
+ EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kStorageTypePersistent));
+
+ manager()->AddOrigin(kOrigin1, kStorageTypePersistent, base::Time::Now());
+ EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kStorageTypeTemporary));
+ EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kStorageTypeTemporary));
+ EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kStorageTypePersistent));
+ EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kStorageTypePersistent));
+
+ manager()->AddOrigin(kOrigin2, kStorageTypeTemporary, base::Time::Now());
+ EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kStorageTypeTemporary));
+ EXPECT_TRUE(manager()->OriginHasData(kOrigin2, kStorageTypeTemporary));
+ EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kStorageTypePersistent));
+ EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kStorageTypePersistent));
}
TEST_F(MockQuotaManagerTest, OriginDeletion) {
- GetManager()->AddOrigin(kOrigin1, kStorageTypeTemporary, base::Time::Now());
- GetManager()->AddOrigin(kOrigin2, kStorageTypeTemporary, base::Time::Now());
+ manager()->AddOrigin(kOrigin1, kStorageTypeTemporary, base::Time::Now());
+ manager()->AddOrigin(kOrigin2, kStorageTypeTemporary, base::Time::Now());
DeleteOriginData(kOrigin2, kStorageTypeTemporary);
MessageLoop::current()->RunAllPending();
- EXPECT_EQ(1, GetDeletionCallbackCount());
- EXPECT_TRUE(GetManager()->OriginHasData(kOrigin1, kStorageTypeTemporary));
- EXPECT_FALSE(GetManager()->OriginHasData(kOrigin2, kStorageTypeTemporary));
+ EXPECT_EQ(1, deletion_callback_count());
+ EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kStorageTypeTemporary));
+ EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kStorageTypeTemporary));
}
TEST_F(MockQuotaManagerTest, ModifiedOrigins) {
@@ -141,31 +147,34 @@ TEST_F(MockQuotaManagerTest, ModifiedOrigins) {
GetModifiedOrigins(kStorageTypeTemporary, then);
MessageLoop::current()->RunAllPending();
- EXPECT_TRUE(GetOrigins().empty());
+ EXPECT_TRUE(origins().empty());
- GetManager()->AddOrigin(kOrigin1, kStorageTypeTemporary, now - an_hour);
+ manager()->AddOrigin(kOrigin1, kStorageTypeTemporary, now - an_hour);
GetModifiedOrigins(kStorageTypeTemporary, then);
MessageLoop::current()->RunAllPending();
- EXPECT_EQ(1UL, GetOrigins().size());
- EXPECT_EQ(1UL, GetOrigins().count(kOrigin1));
- EXPECT_EQ(0UL, GetOrigins().count(kOrigin2));
+ EXPECT_EQ(kStorageTypeTemporary, type());
+ EXPECT_EQ(1UL, origins().size());
+ EXPECT_EQ(1UL, origins().count(kOrigin1));
+ EXPECT_EQ(0UL, origins().count(kOrigin2));
- GetManager()->AddOrigin(kOrigin2, kStorageTypeTemporary, now);
+ manager()->AddOrigin(kOrigin2, kStorageTypeTemporary, now);
GetModifiedOrigins(kStorageTypeTemporary, then);
MessageLoop::current()->RunAllPending();
- EXPECT_EQ(2UL, GetOrigins().size());
- EXPECT_EQ(1UL, GetOrigins().count(kOrigin1));
- EXPECT_EQ(1UL, GetOrigins().count(kOrigin2));
+ EXPECT_EQ(kStorageTypeTemporary, type());
+ EXPECT_EQ(2UL, origins().size());
+ EXPECT_EQ(1UL, origins().count(kOrigin1));
+ EXPECT_EQ(1UL, origins().count(kOrigin2));
GetModifiedOrigins(kStorageTypeTemporary, now - a_minute);
MessageLoop::current()->RunAllPending();
- EXPECT_EQ(1UL, GetOrigins().size());
- EXPECT_EQ(0UL, GetOrigins().count(kOrigin1));
- EXPECT_EQ(1UL, GetOrigins().count(kOrigin2));
+ EXPECT_EQ(kStorageTypeTemporary, type());
+ EXPECT_EQ(1UL, origins().size());
+ EXPECT_EQ(0UL, origins().count(kOrigin1));
+ EXPECT_EQ(1UL, origins().count(kOrigin2));
}
} // Namespace quota
diff --git a/webkit/quota/mock_storage_client.cc b/webkit/quota/mock_storage_client.cc
index 0ba4468..897f100 100644
--- a/webkit/quota/mock_storage_client.cc
+++ b/webkit/quota/mock_storage_client.cc
@@ -163,7 +163,7 @@ void MockStorageClient::RunGetOriginsForType(
if (type == iter->first.second)
origins.insert(iter->first.first);
}
- callback->Run(origins);
+ callback->Run(origins, type);
}
void MockStorageClient::RunGetOriginsForHost(
@@ -178,7 +178,7 @@ void MockStorageClient::RunGetOriginsForHost(
if (type == iter->first.second && host == host_or_spec)
origins.insert(iter->first.first);
}
- callback->Run(origins);
+ callback->Run(origins, type);
}
void MockStorageClient::RunDeleteOriginData(
diff --git a/webkit/quota/quota_client.h b/webkit/quota/quota_client.h
index f3ebbad..312e5d0 100644
--- a/webkit/quota/quota_client.h
+++ b/webkit/quota/quota_client.h
@@ -23,7 +23,8 @@ namespace quota {
class QuotaClient {
public:
typedef Callback1<int64>::Type GetUsageCallback;
- typedef Callback1<const std::set<GURL>&>::Type GetOriginsCallback;
+ typedef Callback2<const std::set<GURL>&, StorageType>::Type
+ GetOriginsCallback;
typedef Callback1<QuotaStatusCode>::Type DeletionCallback;
virtual ~QuotaClient() {}
diff --git a/webkit/quota/quota_manager.cc b/webkit/quota/quota_manager.cc
index d75daa5..b94a352 100644
--- a/webkit/quota/quota_manager.cc
+++ b/webkit/quota/quota_manager.cc
@@ -835,11 +835,11 @@ class QuotaManager::GetModifiedSinceTask
}
virtual void DatabaseTaskCompleted() OVERRIDE {
- callback_->Run(origins_);
+ callback_->Run(origins_, type_);
}
virtual void Aborted() OVERRIDE {
- callback_->Run(std::set<GURL>());
+ callback_->Run(std::set<GURL>(), type_);
}
private:
diff --git a/webkit/quota/quota_manager_unittest.cc b/webkit/quota/quota_manager_unittest.cc
index df1aba7..f43bd64 100644
--- a/webkit/quota/quota_manager_unittest.cc
+++ b/webkit/quota/quota_manager_unittest.cc
@@ -225,6 +225,7 @@ class QuotaManagerTest : public testing::Test {
void GetOriginsModifiedSince(StorageType type, base::Time modified_since) {
modified_origins_.clear();
+ modified_origins_type_ = kStorageTypeUnknown;
quota_manager_->GetOriginsModifiedSince(type, modified_since,
callback_factory_.NewCallback(
&QuotaManagerTest::DidGetModifiedOrigins));
@@ -306,8 +307,9 @@ class QuotaManagerTest : public testing::Test {
lru_origin_ = origin;
}
- void DidGetModifiedOrigins(const std::set<GURL>& origins) {
+ void DidGetModifiedOrigins(const std::set<GURL>& origins, StorageType type) {
modified_origins_ = origins;
+ modified_origins_type_ = type;
}
void DidDumpQuotaTable(const QuotaTableEntries& entries) {
@@ -345,6 +347,7 @@ class QuotaManagerTest : public testing::Test {
int64 available_space() const { return available_space_; }
const GURL& lru_origin() const { return lru_origin_; }
const std::set<GURL>& modified_origins() const { return modified_origins_; }
+ StorageType modified_origins_type() const { return modified_origins_type_; }
const QuotaTableEntries& quota_entries() const { return quota_entries_; }
const OriginInfoTableEntries& origin_info_entries() const {
return origin_info_entries_;
@@ -374,6 +377,7 @@ class QuotaManagerTest : public testing::Test {
int64 available_space_;
GURL lru_origin_;
std::set<GURL> modified_origins_;
+ StorageType modified_origins_type_;
QuotaTableEntries quota_entries_;
OriginInfoTableEntries origin_info_entries_;
int status_callback_count_;
@@ -1435,6 +1439,7 @@ TEST_F(QuotaManagerTest, GetOriginsModifiedSince) {
GetOriginsModifiedSince(kTemp, base::Time());
MessageLoop::current()->RunAllPending();
EXPECT_TRUE(modified_origins().empty());
+ EXPECT_EQ(modified_origins_type(), kTemp);
base::Time time1 = client->IncrementMockTime();
client->ModifyOriginAndNotify(GURL("http://a.com/"), kTemp, 10);
@@ -1448,6 +1453,7 @@ TEST_F(QuotaManagerTest, GetOriginsModifiedSince) {
GetOriginsModifiedSince(kTemp, time1);
MessageLoop::current()->RunAllPending();
EXPECT_EQ(4U, modified_origins().size());
+ EXPECT_EQ(modified_origins_type(), kTemp);
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData); ++i) {
if (kData[i].type == kTemp)
EXPECT_EQ(1U, modified_origins().count(GURL(kData[i].origin)));
@@ -1460,6 +1466,7 @@ TEST_F(QuotaManagerTest, GetOriginsModifiedSince) {
GetOriginsModifiedSince(kTemp, time3);
MessageLoop::current()->RunAllPending();
EXPECT_TRUE(modified_origins().empty());
+ EXPECT_EQ(modified_origins_type(), kTemp);
client->ModifyOriginAndNotify(GURL("http://a.com/"), kTemp, 10);
@@ -1467,6 +1474,7 @@ TEST_F(QuotaManagerTest, GetOriginsModifiedSince) {
MessageLoop::current()->RunAllPending();
EXPECT_EQ(1U, modified_origins().size());
EXPECT_EQ(1U, modified_origins().count(GURL("http://a.com/")));
+ EXPECT_EQ(modified_origins_type(), kTemp);
}
TEST_F(QuotaManagerTest, DumpQuotaTable) {
diff --git a/webkit/quota/quota_types.h b/webkit/quota/quota_types.h
index d8aeb88..455925d 100644
--- a/webkit/quota/quota_types.h
+++ b/webkit/quota/quota_types.h
@@ -52,7 +52,7 @@ typedef Callback4<QuotaStatusCode,
typedef Callback2<QuotaStatusCode,
int64>::Type AvailableSpaceCallback;
typedef Callback1<QuotaStatusCode>::Type StatusCallback;
-typedef Callback1<const std::set<GURL>&>::Type GetOriginsCallback;
+typedef Callback2<const std::set<GURL>&, StorageType>::Type GetOriginsCallback;
// Simple template wrapper for a callback queue.
template <typename CallbackType>
diff --git a/webkit/quota/usage_tracker.cc b/webkit/quota/usage_tracker.cc
index 0c4a050..3f99df7 100644
--- a/webkit/quota/usage_tracker.cc
+++ b/webkit/quota/usage_tracker.cc
@@ -34,7 +34,7 @@ class ClientUsageTracker::GatherUsageTaskBase : public QuotaTask {
virtual ~GatherUsageTaskBase() {}
// Get total usage for the given |origins|.
- void GetUsageForOrigins(const std::set<GURL>& origins) {
+ void GetUsageForOrigins(const std::set<GURL>& origins, StorageType type) {
DCHECK(original_message_loop()->BelongsToCurrentThread());
std::set<GURL> origins_to_process;
// We do not get usage for origins for which we have valid usage cache.