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

Unified Diff: content/browser/service_worker/service_worker_storage.h

Issue 374873002: Service Worker: Delay stale resource cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 6 years, 5 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: content/browser/service_worker/service_worker_storage.h
diff --git a/content/browser/service_worker/service_worker_storage.h b/content/browser/service_worker/service_worker_storage.h
index b25f26b2692ab5602fc477d09e0082217132ce97..5033d27a268a84521aa969c10d1b5f031f7c4597 100644
--- a/content/browser/service_worker/service_worker_storage.h
+++ b/content/browser/service_worker/service_worker_storage.h
@@ -118,7 +118,7 @@ class CONTENT_EXPORT ServiceWorkerStorage
// Adds |id| to the set of resources ids that are in the disk
// cache but not yet stored with a registration.
- void StoreUncommittedReponseId(int64 id);
+ void StoreUncommittedResponseId(int64 id);
// Removes |id| from uncommitted list, adds it to the
// purgeable list and purges it.
@@ -159,7 +159,6 @@ class CONTENT_EXPORT ServiceWorkerStorage
int64 next_version_id;
int64 next_resource_id;
std::set<GURL> origins;
- std::set<int64> purgeable_resource_ids;
InitialData();
~InitialData();
@@ -185,6 +184,9 @@ class CONTENT_EXPORT ServiceWorkerStorage
const ServiceWorkerDatabase::RegistrationData& data,
const ResourceList& resources,
ServiceWorkerDatabase::Status status)> FindInDBCallback;
+ typedef base::Callback<void(const std::vector<int64>& resource_ids,
+ ServiceWorkerDatabase::Status status)>
+ GetResourcesCallback;
ServiceWorkerStorage(const base::FilePath& path,
base::WeakPtr<ServiceWorkerContextCore> context,
@@ -262,7 +264,18 @@ class CONTENT_EXPORT ServiceWorkerStorage
void PurgeResource(int64 id);
void OnResourcePurged(int64 id, int rv);
+ // Deletes purgeable and uncommitted resources left over from the previous
+ // browser session. This must be called once per session before any database
+ // operation that may mutate the purgeable or uncommitted resource lists.
+ void DeleteStaleResources();
+ void DidCollectStaleResources(const std::vector<int64>& stale_resource_ids,
+ ServiceWorkerDatabase::Status status);
+
// Static cross-thread helpers.
+ static void CollectStaleResourcesFromDB(
+ ServiceWorkerDatabase* database,
+ scoped_refptr<base::SequencedTaskRunner> original_task_runner,
+ const GetResourcesCallback& callback);
static void ReadInitialDataFromDB(
ServiceWorkerDatabase* database,
scoped_refptr<base::SequencedTaskRunner> original_task_runner,
@@ -337,6 +350,7 @@ class CONTENT_EXPORT ServiceWorkerStorage
scoped_ptr<ServiceWorkerDiskCache> disk_cache_;
std::deque<int64> purgeable_resource_ids_;
bool is_purge_pending_;
+ bool has_checked_for_stale_resources_;
std::map<int64, std::vector<int64> > deleted_version_resource_ids_;
base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_;

Powered by Google App Engine
This is Rietveld 408576698