diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-10 23:29:09 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-10 23:29:09 +0000 |
commit | e0184cbde1634faa300d63c7880b5acf312f45d6 (patch) | |
tree | 69ef5ba562bbc68276fddd3279c6ca7e8e27d025 /webkit/appcache/appcache_database.cc | |
parent | b7d94558973c6c6f2776f68a4d34d20cd5303ac5 (diff) | |
download | chromium_src-e0184cbde1634faa300d63c7880b5acf312f45d6.zip chromium_src-e0184cbde1634faa300d63c7880b5acf312f45d6.tar.gz chromium_src-e0184cbde1634faa300d63c7880b5acf312f45d6.tar.bz2 |
AppCache + Quota integration
* Notify the QuotaManager of accesses and modifications to the amount of storage utlized.
* Implement the QuotaClient interface so the manager can query the appcache for usage and delete data.
* When storing appcaches, use QuotaManager GetUsageAndQuota and respect the limit.
* Remove the old and unsed support for storing per-origin quota values in the appcache DB.
BUG=61676
TEST=unittests
Review URL: http://codereview.chromium.org/7031065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88746 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_database.cc')
-rw-r--r-- | webkit/appcache/appcache_database.cc | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/webkit/appcache/appcache_database.cc b/webkit/appcache/appcache_database.cc index 0c7f1686..d754beb 100644 --- a/webkit/appcache/appcache_database.cc +++ b/webkit/appcache/appcache_database.cc @@ -15,7 +15,6 @@ #include "base/utf_string_conversions.h" #include "webkit/appcache/appcache_entry.h" #include "webkit/appcache/appcache_histograms.h" -#include "webkit/database/quota_table.h" // Schema ------------------------------------------------------------------- namespace { @@ -196,12 +195,15 @@ int64 AppCacheDatabase::GetOriginUsage(const GURL& origin) { return origin_usage; } -int64 AppCacheDatabase::GetOriginQuota(const GURL& origin) { - if (!LazyOpen(false)) - return GetDefaultOriginQuota(); - int64 quota = quota_table_->GetOriginQuota( - UTF8ToUTF16(origin.spec().c_str())); - return (quota >= 0) ? quota : GetDefaultOriginQuota(); +bool AppCacheDatabase::GetAllOriginUsage(std::map<GURL, int64>* usage_map) { + std::set<GURL> origins; + if (!FindOriginsWithGroups(&origins)) + return false; + for (std::set<GURL>::const_iterator origin = origins.begin(); + origin != origins.end(); ++origin) { + (*usage_map)[*origin] = GetOriginUsage(*origin); + } + return true; } bool AppCacheDatabase::FindOriginsWithGroups(std::set<GURL>* origins) { @@ -1004,7 +1006,6 @@ bool AppCacheDatabase::LazyOpen(bool create_if_needed) { db_.reset(new sql::Connection); meta_table_.reset(new sql::MetaTable); - quota_table_.reset(new webkit_database::QuotaTable(db_.get())); db_->set_error_delegate(GetErrorHandlerForAppCacheDb()); @@ -1069,10 +1070,8 @@ bool AppCacheDatabase::CreateSchema() { if (!transaction.Begin()) return false; - if (!meta_table_->Init(db_.get(), kCurrentVersion, kCompatibleVersion) || - !quota_table_->Init()) { + if (!meta_table_->Init(db_.get(), kCurrentVersion, kCompatibleVersion)) return false; - } for (int i = 0; i < kTableCount; ++i) { std::string sql("CREATE TABLE "); @@ -1108,7 +1107,6 @@ bool AppCacheDatabase::UpgradeSchema() { } void AppCacheDatabase::ResetConnectionAndTables() { - quota_table_.reset(); meta_table_.reset(); db_.reset(); } |