summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_database.cc
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-06 03:26:41 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-06 03:26:41 +0000
commitfd4882e6faab19e1de6d791acebfa3b34faf5701 (patch)
tree2fa95bddd8b6189d0dd7b850d24da0b7ab382e28 /webkit/appcache/appcache_database.cc
parent12e8fecd3923d3ace7fe3f505ba3fa490b5417c1 (diff)
downloadchromium_src-fd4882e6faab19e1de6d791acebfa3b34faf5701.zip
chromium_src-fd4882e6faab19e1de6d791acebfa3b34faf5701.tar.gz
chromium_src-fd4882e6faab19e1de6d791acebfa3b34faf5701.tar.bz2
AppCache quota tracking groundwork, store response sizes in the SQL database.
TEST=updated existing unittests BUG=none Review URL: http://codereview.chromium.org/523046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_database.cc')
-rw-r--r--webkit/appcache/appcache_database.cc30
1 files changed, 19 insertions, 11 deletions
diff --git a/webkit/appcache/appcache_database.cc b/webkit/appcache/appcache_database.cc
index fd2a9e9..606d6c1 100644
--- a/webkit/appcache/appcache_database.cc
+++ b/webkit/appcache/appcache_database.cc
@@ -38,13 +38,15 @@ const struct {
"(cache_id INTEGER PRIMARY KEY,"
" group_id INTEGER,"
" online_wildcard INTEGER CHECK(online_wildcard IN (0, 1)),"
- " update_time INTEGER)" },
+ " update_time INTEGER,"
+ " cache_size INTEGER)" }, // intentionally not normalized
{ kEntriesTable,
"(cache_id INTEGER,"
" url TEXT,"
" flags INTEGER,"
- " response_id INTEGER)" },
+ " response_id INTEGER,"
+ " response_size INTEGER)" },
{ kFallbackNameSpacesTable,
"(cache_id INTEGER,"
@@ -315,7 +317,7 @@ bool AppCacheDatabase::FindCache(int64 cache_id, CacheRecord* record) {
return false;
const char* kSql =
- "SELECT cache_id, group_id, online_wildcard, update_time"
+ "SELECT cache_id, group_id, online_wildcard, update_time, cache_size"
" FROM Caches WHERE cache_id = ?";
sql::Statement statement;
@@ -336,7 +338,7 @@ bool AppCacheDatabase::FindCacheForGroup(int64 group_id, CacheRecord* record) {
return false;
const char* kSql =
- "SELECT cache_id, group_id, online_wildcard, update_time"
+ "SELECT cache_id, group_id, online_wildcard, update_time, cache_size"
" FROM Caches WHERE group_id = ?";
sql::Statement statement;
@@ -357,8 +359,8 @@ bool AppCacheDatabase::InsertCache(const CacheRecord* record) {
const char* kSql =
"INSERT INTO Caches (cache_id, group_id, online_wildcard,"
- " update_time)"
- " VALUES(?, ?, ?, ?)";
+ " update_time, cache_size)"
+ " VALUES(?, ?, ?, ?, ?)";
sql::Statement statement;
if (!PrepareCachedStatement(SQL_FROM_HERE, kSql, &statement))
@@ -374,6 +376,8 @@ bool AppCacheDatabase::InsertCache(const CacheRecord* record) {
statement.BindInt64(3,
(record->update_time - base::TimeTicks()).InMicroseconds());
+ statement.BindInt64(4, record->cache_size);
+
return statement.Run();
}
@@ -399,7 +403,7 @@ bool AppCacheDatabase::FindEntriesForCache(
return false;
const char* kSql =
- "SELECT cache_id, url, flags, response_id FROM Entries"
+ "SELECT cache_id, url, flags, response_id, response_size FROM Entries"
" WHERE cache_id = ?";
sql::Statement statement;
@@ -423,7 +427,7 @@ bool AppCacheDatabase::FindEntriesForUrl(
return false;
const char* kSql =
- "SELECT cache_id, url, flags, response_id FROM Entries"
+ "SELECT cache_id, url, flags, response_id, response_size FROM Entries"
" WHERE url = ?";
sql::Statement statement;
@@ -448,7 +452,7 @@ bool AppCacheDatabase::FindEntry(
return false;
const char* kSql =
- "SELECT cache_id, url, flags, response_id FROM Entries"
+ "SELECT cache_id, url, flags, response_id, response_size FROM Entries"
" WHERE cache_id = ? AND url = ?";
sql::Statement statement;
@@ -471,8 +475,8 @@ bool AppCacheDatabase::InsertEntry(const EntryRecord* record) {
return false;
const char* kSql =
- "INSERT INTO Entries (cache_id, url, flags, response_id)"
- " VALUES(?, ?, ?, ?)";
+ "INSERT INTO Entries (cache_id, url, flags, response_id, response_size)"
+ " VALUES(?, ?, ?, ?, ?)";
sql::Statement statement;
if (!PrepareCachedStatement(SQL_FROM_HERE, kSql, &statement))
@@ -482,6 +486,7 @@ bool AppCacheDatabase::InsertEntry(const EntryRecord* record) {
statement.BindString(1, record->url.spec());
statement.BindInt(2, record->flags);
statement.BindInt64(3, record->response_id);
+ statement.BindInt64(4, record->response_size);
return statement.Run();
}
@@ -728,6 +733,8 @@ void AppCacheDatabase::ReadCacheRecord(
// as an intermediary step.
record->update_time = base::TimeTicks() +
base::TimeDelta::FromMicroseconds(statement.ColumnInt64(3));
+
+ record->cache_size = statement.ColumnInt64(4);
}
void AppCacheDatabase::ReadEntryRecord(
@@ -736,6 +743,7 @@ void AppCacheDatabase::ReadEntryRecord(
record->url = GURL(statement.ColumnString(1));
record->flags = statement.ColumnInt(2);
record->response_id = statement.ColumnInt64(3);
+ record->response_size = statement.ColumnInt64(4);
}
void AppCacheDatabase::ReadFallbackNameSpaceRecord(