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

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

Issue 2164113003: [M53] service worker: Wait for inflight requests before activating (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 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_version.h
diff --git a/content/browser/service_worker/service_worker_version.h b/content/browser/service_worker/service_worker_version.h
index 71b3dcd639c753482f27cb43e65ff442bea93f97..240e838a2fce737b18c7c998fa47f3eced57b599 100644
--- a/content/browser/service_worker/service_worker_version.h
+++ b/content/browser/service_worker/service_worker_version.h
@@ -109,8 +109,8 @@ class CONTENT_EXPORT ServiceWorkerVersion
virtual void OnControlleeRemoved(ServiceWorkerVersion* version,
ServiceWorkerProviderHost* provider_host) {
}
- // Fires when a version transitions from having a controllee to not.
virtual void OnNoControllees(ServiceWorkerVersion* version) {}
+ virtual void OnNoWork(ServiceWorkerVersion* version) {}
virtual void OnCachedMetadataUpdated(ServiceWorkerVersion* version) {}
protected:
@@ -274,8 +274,6 @@ class CONTENT_EXPORT ServiceWorkerVersion
void DispatchSimpleEvent(int request_id, const IPC::Message& message);
// Adds and removes |provider_host| as a controllee of this ServiceWorker.
- // A potential controllee is a host having the version as its .installing
- // or .waiting version.
void AddControllee(ServiceWorkerProviderHost* provider_host);
void RemoveControllee(ServiceWorkerProviderHost* provider_host);
@@ -344,6 +342,10 @@ class CONTENT_EXPORT ServiceWorkerVersion
// Simulate ping timeout. Should be used for tests-only.
void SimulatePingTimeoutForTesting();
+ // Returns true if the service worker has work to do: it has pending
+ // requests, in-progress streaming URLRequestJobs, or pending start callbacks.
+ bool HasWork() const;
+
private:
friend class base::RefCounted<ServiceWorkerVersion>;
friend class ServiceWorkerMetrics;
@@ -380,6 +382,9 @@ class CONTENT_EXPORT ServiceWorkerVersion
FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, MixedRequestTimeouts);
FRIEND_TEST_ALL_PREFIXES(ServiceWorkerURLRequestJobTest, EarlyResponse);
FRIEND_TEST_ALL_PREFIXES(ServiceWorkerURLRequestJobTest, CancelRequest);
+ FRIEND_TEST_ALL_PREFIXES(ServiceWorkerActivationTest, SkipWaiting);
+ FRIEND_TEST_ALL_PREFIXES(ServiceWorkerActivationTest,
+ SkipWaitingWithInflightRequest);
class Metrics;
class PingController;
@@ -594,7 +599,6 @@ class CONTENT_EXPORT ServiceWorkerVersion
// Stops the worker if it is idle (has no in-flight requests) or timed out
// ping.
void StopWorkerIfIdle();
- bool HasInflightRequests() const;
// RecordStartWorkerResult is added as a start callback by StartTimeoutTimer
// and records metrics about startup.

Powered by Google App Engine
This is Rietveld 408576698