Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Unified Diff: webkit/quota/quota_database.cc

Issue 7057006: Add Dump{Quota,LastAccessTime}Table (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 'Move Assign*** and Rename AccessTable' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/quota/quota_database.h ('k') | webkit/quota/quota_database_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/quota/quota_database.cc
diff --git a/webkit/quota/quota_database.cc b/webkit/quota/quota_database.cc
index 52caf2ed4b43d132d4f2e2c5250b5694f6a0bf21..ed97257f8727a88d22cdc9ccabaf3162a02f3197 100644
--- a/webkit/quota/quota_database.cc
+++ b/webkit/quota/quota_database.cc
@@ -219,8 +219,6 @@ bool QuotaDatabase::RegisterOrigins(const std::set<GURL>& origins,
if (!transaction.Begin())
return false;
- sql::Statement statement;
-
typedef std::set<GURL>::const_iterator itr_type;
for (itr_type itr = origins.begin(), end = origins.end();
itr != end; ++itr) {
@@ -228,6 +226,7 @@ bool QuotaDatabase::RegisterOrigins(const std::set<GURL>& origins,
"INSERT OR IGNORE INTO OriginLastAccessTable"
" (used_count, last_access_time, origin, type)"
" VALUES (?, ?, ?, ?)";
+ sql::Statement statement;
if (!PrepareCachedStatement(db_.get(), SQL_FROM_HERE, kSql, &statement))
return false;
@@ -515,4 +514,71 @@ bool QuotaDatabase::ResetSchema() {
return LazyOpen(true);
}
+bool QuotaDatabase::DumpQuotaTable(QuotaTableCallback* callback) {
+ if (!LazyOpen(true))
+ return false;
+
+ const char* kSql = "SELECT * FROM HostQuotaTable";
+ sql::Statement statement;
+ if (!PrepareCachedStatement(db_.get(), SQL_FROM_HERE, kSql, &statement))
+ return false;
+
+ while (statement.Step()) {
+ QuotaTableEntry entry = {
+ statement.ColumnString(0),
+ static_cast<StorageType>(statement.ColumnInt(1)),
+ statement.ColumnInt64(2)
+ };
+
+ if (!callback->Run(entry))
Dai Mikurube (NOT FULLTIME) 2011/05/23 06:16:42 Is the caller responsible for deleting the callbac
tzik 2011/05/23 06:57:12 Done. Now, ownership of the callback shall be pass
+ return true;
+ }
+
+ return statement.Succeeded();
+}
+
+bool QuotaDatabase::DumpLastAccessTimeTable(
+ LastAccessTimeTableCallback* callback) {
+ if (!LazyOpen(true))
+ return false;
+
+ const char* kSql = "SELECT * FROM OriginLastAccessTable";
+ sql::Statement statement;
+ if (!PrepareCachedStatement(db_.get(), SQL_FROM_HERE, kSql, &statement))
+ return false;
+
+ while (statement.Step()) {
+ LastAccessTimeTableEntry entry = {
+ GURL(statement.ColumnString(0)),
+ static_cast<StorageType>(statement.ColumnInt(1)),
+ statement.ColumnInt(2),
+ base::Time::FromInternalValue(statement.ColumnInt64(3))
+ };
+
+ if (!callback->Run(entry))
Dai Mikurube (NOT FULLTIME) 2011/05/23 06:16:42 ditto.
+ return true;
+ }
+
+ return statement.Succeeded();
+}
+
+bool operator<(const QuotaDatabase::QuotaTableEntry& lhs,
+ const QuotaDatabase::QuotaTableEntry& rhs) {
+ if (lhs.host < rhs.host) return true;
+ if (rhs.host < lhs.host) return false;
+ if (lhs.type < rhs.type) return true;
+ if (rhs.type < lhs.type) return false;
+ return lhs.quota < rhs.quota;
+}
+
+bool operator<(const QuotaDatabase::LastAccessTimeTableEntry& lhs,
+ const QuotaDatabase::LastAccessTimeTableEntry& rhs) {
+ if (lhs.origin < rhs.origin) return true;
+ if (rhs.origin < lhs.origin) return false;
+ if (lhs.type < rhs.type) return true;
+ if (rhs.type < lhs.type) return false;
+ if (lhs.used_count < rhs.used_count) return true;
+ if (rhs.used_count < lhs.used_count) return false;
+ return lhs.last_access_time < rhs.last_access_time;
+}
} // quota namespace
« no previous file with comments | « webkit/quota/quota_database.h ('k') | webkit/quota/quota_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698