Index: webkit/quota/quota_database.cc |
diff --git a/webkit/quota/quota_database.cc b/webkit/quota/quota_database.cc |
index 52caf2ed4b43d132d4f2e2c5250b5694f6a0bf21..fb8c03841999471ad8ba5227396079e08b87a996 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,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)) |
kinuko
2011/05/23 08:16:52
does this mean 'the callback may return false when
tzik
2011/05/24 04:32:41
Done.
|
+ 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 |