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

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: style 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..67c4e4e32ce56bb336ca2485e95cbf1d168f8874 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,
@@ -195,6 +197,8 @@ class CONTENT_EXPORT ServiceWorkerStorage
base::FilePath GetDatabasePath();
base::FilePath GetDiskCachePath();
+ bool IsReady();
+
bool LazyInitialize(
const base::Closure& callback);
void DidReadInitialData(
@@ -262,7 +266,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,
@@ -320,6 +335,7 @@ class CONTENT_EXPORT ServiceWorkerStorage
enum State {
UNINITIALIZED,
INITIALIZING,
+ HAS_STALE_RESOURCES,
michaeln 2014/07/09 02:36:11 bikesheddy... This one is a little different then
falken 2014/07/09 04:31:14 I was a bit torn when writing this. I liked State
INITIALIZED,
DISABLED,
};

Powered by Google App Engine
This is Rietveld 408576698