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

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: '' 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
Index: webkit/quota/quota_database.cc
diff --git a/webkit/quota/quota_database.cc b/webkit/quota/quota_database.cc
index 52caf2ed4b43d132d4f2e2c5250b5694f6a0bf21..6ba506feedccec40ce6f1033e9c49655b67fa5ba 100644
--- a/webkit/quota/quota_database.cc
+++ b/webkit/quota/quota_database.cc
@@ -215,12 +215,6 @@ bool QuotaDatabase::RegisterOrigins(const std::set<GURL>& origins,
if (!LazyOpen(true))
return false;
- sql::Transaction transaction(db_.get());
- 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 +222,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;
@@ -239,7 +234,8 @@ bool QuotaDatabase::RegisterOrigins(const std::set<GURL>& origins,
return false;
}
- return transaction.Commit();
+ ScheduleCommit();
+ return true;
}
bool QuotaDatabase::DeleteHostQuota(
@@ -515,4 +511,74 @@ bool QuotaDatabase::ResetSchema() {
return LazyOpen(true);
}
+bool QuotaDatabase::DumpQuotaTable(QuotaTableCallback* callback) {
+ scoped_ptr<QuotaTableCallback> callback_deleter(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))
+ return true;
+ }
+
+ return statement.Succeeded();
+}
+
+bool QuotaDatabase::DumpLastAccessTimeTable(
+ LastAccessTimeTableCallback* callback) {
+ scoped_ptr<LastAccessTimeTableCallback> callback_deleter(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))
+ 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

Powered by Google App Engine
This is Rietveld 408576698