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

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

Issue 991743002: Service Worker: Coalesce the start worker timer into the timeout timer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 5 years, 9 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
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_version.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4d327701ae5524bb74d48b12facdf75969eb16a7..89b0b3dac4fc7b95c5e625d3dc651121fd8961cf 100644
--- a/content/browser/service_worker/service_worker_version.h
+++ b/content/browser/service_worker/service_worker_version.h
@@ -316,6 +316,11 @@ class CONTENT_EXPORT ServiceWorkerVersion
typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap;
typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap;
+ enum PingState { NOT_PINGING, PINGING, PING_TIMED_OUT };
+
+ // Timeout for the worker to start.
+ static const int kStartWorkerTimeoutMinutes;
+
~ServiceWorkerVersion() override;
// EmbeddedWorkerInstance::Listener overrides:
@@ -400,7 +405,7 @@ class CONTENT_EXPORT ServiceWorkerVersion
// The ping protocol is for terminating workers that are taking excessively
// long executing JavaScript (e.g., stuck in while(true) {}). Periodically a
// ping IPC is sent to the worker context and if we timeout waiting for a
- // pong, the worker is terminated.
+ // pong, the worker is terminated. Pinging starts after the script is loaded.
void PingWorker();
void OnPingTimeout();
@@ -409,14 +414,9 @@ class CONTENT_EXPORT ServiceWorkerVersion
void StopWorkerIfIdle();
bool HasInflightRequests() const;
- // ScheduleStartWorkerTimeout is called when attempting to the start the
- // embedded worker. It sets a timer for calling OnStartWorkerTimeout, which
- // invokes start callbacks with ERROR_TIMEOUT. It also adds its own start
- // callback RecordStartWorkerResult which cancels the timer and records
- // metrics about startup.
- void ScheduleStartWorkerTimeout();
+ // RecordStartWorkerResult is added as a start callback by StartTimeoutTimer
+ // and records metrics about startup.
void RecordStartWorkerResult(ServiceWorkerStatusCode status);
- void OnStartWorkerTimeout();
void DoomInternal();
@@ -456,19 +456,16 @@ class CONTENT_EXPORT ServiceWorkerVersion
ServiceWorkerScriptCacheMap script_cache_map_;
base::OneShotTimer<ServiceWorkerVersion> update_timer_;
- // Starts running when the script is loaded (which means it is about to begin
- // evaluation) and continues until the worker is stopped or a stop request is
- // ignored because DevTools is attached.
+ // Starts running in StartWorker and continues until the worker is stopped.
base::RepeatingTimer<ServiceWorkerVersion> timeout_timer_;
// Holds the time the worker last started being considered idle.
base::TimeTicks idle_time_;
// Holds the time that an outstanding ping was sent to the worker.
base::TimeTicks ping_time_;
- // True if the worker was stopped because it did not respond to ping in time.
- bool ping_timed_out_;
-
- base::OneShotTimer<ServiceWorkerVersion> start_worker_timeout_timer_;
- base::TimeTicks start_timing_;
+ // The state of the ping protocol.
+ PingState ping_state_;
+ // Holds the time that the outstanding StartWorker() request started.
+ base::TimeTicks start_time_;
bool is_doomed_;
std::vector<int> pending_skip_waiting_requests_;
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698