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

Unified Diff: webkit/quota/quota_manager.cc

Issue 7168019: Implement QM::GetOriginsModifiedSince for browser data deleter support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 6 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_manager.cc
diff --git a/webkit/quota/quota_manager.cc b/webkit/quota/quota_manager.cc
index 52cd4eb9ad59402515837214ec6a411e769b09db..ee20536ce5c82be3662fd047b5cfd206f8ff7073 100644
--- a/webkit/quota/quota_manager.cc
+++ b/webkit/quota/quota_manager.cc
@@ -347,7 +347,7 @@ QuotaManager::UsageAndQuotaDispatcherTask::Create(
class QuotaManager::DatabaseTaskBase : public QuotaThreadTask {
public:
- DatabaseTaskBase(QuotaManager* manager)
+ explicit DatabaseTaskBase(QuotaManager* manager)
: QuotaThreadTask(manager, manager->db_thread_),
manager_(manager),
database_(manager->database_.get()),
@@ -582,7 +582,7 @@ class QuotaManager::OriginDeletionDatabaseTask
protected:
virtual void RunOnTargetThread() OVERRIDE {
- if (!database()->DeleteOriginLastAccessTime(origin_, type_)) {
+ if (!database()->DeleteOriginInfo(origin_, type_)) {
set_db_disabled(true);
}
}
@@ -688,6 +688,70 @@ class QuotaManager::OriginAccessRecordDatabaseTask
base::Time accessed_time_;
};
+class QuotaManager::OriginModifyRecordDatabaseTask
+ : public QuotaManager::DatabaseTaskBase {
+ public:
+ OriginModifyRecordDatabaseTask(
+ QuotaManager* manager,
+ const GURL& origin,
+ StorageType type,
+ base::Time modified_time)
+ : DatabaseTaskBase(manager),
+ origin_(origin),
+ type_(type),
+ modified_time_(modified_time) {}
+
+ protected:
+ virtual void RunOnTargetThread() OVERRIDE {
+ if (!database()->SetOriginLastModifiedTime(
+ origin_, type_, modified_time_)) {
+ set_db_disabled(true);
+ }
+ }
+ virtual void DatabaseTaskCompleted() OVERRIDE {}
+
+ private:
+ GURL origin_;
+ StorageType type_;
+ base::Time modified_time_;
+};
+
+class QuotaManager::OriginsModifiedSinceRetrieveTask
+ : public QuotaManager::DatabaseTaskBase {
+ public:
+ OriginsModifiedSinceRetrieveTask(
+ QuotaManager* manager,
+ StorageType type,
+ base::Time modified_since,
+ GetOriginsCallback* callback)
+ : DatabaseTaskBase(manager),
+ type_(type),
+ modified_since_(modified_since),
+ callback_(callback) {}
+
+ protected:
+ virtual void RunOnTargetThread() OVERRIDE {
+ if (!database()->GetOriginsModifiedSince(
+ type_, &origins_, modified_since_)) {
+ set_db_disabled(true);
+ }
+ }
+
+ virtual void DatabaseTaskCompleted() OVERRIDE {
+ callback_->Run(origins_);
+ }
+
+ virtual void Aborted() OVERRIDE {
+ callback_->Run(origins_);
+ }
+
+ private:
+ StorageType type_;
+ base::Time modified_since_;
+ std::set<GURL> origins_;
+ scoped_ptr<GetOriginsCallback> callback_;
+};
+
class QuotaManager::DumpQuotaTableTask
: public QuotaManager::DatabaseTaskBase {
private:
@@ -730,17 +794,17 @@ class QuotaManager::DumpQuotaTableTask
TableEntries entries_;
};
-class QuotaManager::DumpLastAccessTimeTableTask
+class QuotaManager::DumpOriginInfoTableTask
: public QuotaManager::DatabaseTaskBase {
private:
- typedef QuotaManager::DumpLastAccessTimeTableTask self_type;
- typedef QuotaManager::DumpLastAccessTimeTableCallback Callback;
- typedef QuotaManager::LastAccessTimeTableEntry TableEntry;
- typedef QuotaManager::LastAccessTimeTableEntries TableEntries;
- typedef QuotaDatabase::LastAccessTimeTableCallback TableCallback;
+ typedef QuotaManager::DumpOriginInfoTableTask self_type;
+ typedef QuotaManager::DumpOriginInfoTableCallback Callback;
+ typedef QuotaManager::OriginInfoTableEntry TableEntry;
+ typedef QuotaManager::OriginInfoTableEntries TableEntries;
+ typedef QuotaDatabase::OriginInfoTableCallback TableCallback;
public:
- DumpLastAccessTimeTableTask(
+ DumpOriginInfoTableTask(
QuotaManager* manager,
Callback* callback)
: DatabaseTaskBase(manager),
@@ -748,7 +812,7 @@ class QuotaManager::DumpLastAccessTimeTableTask
}
protected:
virtual void RunOnTargetThread() OVERRIDE {
- if (!database()->DumpLastAccessTimeTable(
+ if (!database()->DumpOriginInfoTable(
new TableCallback(
base::Bind(&self_type::AppendEntry, this))))
set_db_disabled(true);
@@ -977,8 +1041,8 @@ void QuotaManager::NotifyStorageAccessed(
void QuotaManager::NotifyStorageModified(
QuotaClient::ID client_id,
const GURL& origin, StorageType type, int64 delta) {
- LazyInitialize();
- GetUsageTracker(type)->UpdateUsageCache(client_id, origin, delta);
+ NotifyStorageModifiedInternal(client_id, origin, type, delta,
+ base::Time::Now());
}
void QuotaManager::NotifyOriginInUse(const GURL& origin) {
@@ -1037,18 +1101,38 @@ void QuotaManager::NotifyStorageAccessedInternal(
if (db_disabled_)
return;
- scoped_refptr<OriginAccessRecordDatabaseTask> task(
- new OriginAccessRecordDatabaseTask(this, origin, type, accessed_time));
- task->Start();
+ make_scoped_refptr(new OriginAccessRecordDatabaseTask(
+ this, origin, type, accessed_time))->Start();
+}
+
+void QuotaManager::NotifyStorageModifiedInternal(
+ QuotaClient::ID client_id,
+ const GURL& origin,
+ StorageType type,
+ int64 delta,
+ base::Time modified_time) {
+ LazyInitialize();
+ GetUsageTracker(type)->UpdateUsageCache(client_id, origin, delta);
+ make_scoped_refptr(new OriginModifyRecordDatabaseTask(
+ this, origin, type, modified_time))->Start();
+}
+
+void QuotaManager::GetOriginsModifiedSince(
+ StorageType type,
+ base::Time modified_since,
+ GetOriginsCallback* callback) {
+ LazyInitialize();
+ make_scoped_refptr(new OriginsModifiedSinceRetrieveTask(
+ this, type, modified_since, callback))->Start();
}
void QuotaManager::DumpQuotaTable(DumpQuotaTableCallback* callback) {
make_scoped_refptr(new DumpQuotaTableTask(this, callback))->Start();
}
-void QuotaManager::DumpLastAccessTimeTable(
- DumpLastAccessTimeTableCallback* callback) {
- make_scoped_refptr(new DumpLastAccessTimeTableTask(this, callback))->Start();
+void QuotaManager::DumpOriginInfoTable(
+ DumpOriginInfoTableCallback* callback) {
+ make_scoped_refptr(new DumpOriginInfoTableTask(this, callback))->Start();
}

Powered by Google App Engine
This is Rietveld 408576698