OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <functional> | 10 #include <functional> |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 // if there're any (see RegisterStatusChangeCallback). | 157 // if there're any (see RegisterStatusChangeCallback). |
158 void SetStatus(Status status); | 158 void SetStatus(Status status); |
159 | 159 |
160 // Registers status change callback. (This is for one-off observation, | 160 // Registers status change callback. (This is for one-off observation, |
161 // the consumer needs to re-register if it wants to continue observing | 161 // the consumer needs to re-register if it wants to continue observing |
162 // status changes) | 162 // status changes) |
163 void RegisterStatusChangeCallback(const base::Closure& callback); | 163 void RegisterStatusChangeCallback(const base::Closure& callback); |
164 | 164 |
165 // Starts an embedded worker for this version. | 165 // Starts an embedded worker for this version. |
166 // This returns OK (success) if the worker is already running. | 166 // This returns OK (success) if the worker is already running. |
167 void StartWorker(const StatusCallback& callback); | 167 void StartWorker(const StatusCallback& callback, |
168 ServiceWorkerMetrics::EventType purpose = | |
169 ServiceWorkerMetrics::EventType::UNKNOWN); | |
nhiroki
2016/03/15 02:18:14
When is this argument omitted? Is it only in unitt
nhiroki
2016/03/15 02:27:48
IMHO, if there are no strong needs of the default
falken
2016/03/15 05:15:53
Yes good point. Actually I was just too lazy to ch
| |
168 | 170 |
169 // Stops an embedded worker for this version. | 171 // Stops an embedded worker for this version. |
170 // This returns OK (success) if the worker is already stopped. | 172 // This returns OK (success) if the worker is already stopped. |
171 void StopWorker(const StatusCallback& callback); | 173 void StopWorker(const StatusCallback& callback); |
172 | 174 |
173 // Schedules an update to be run 'soon'. | 175 // Schedules an update to be run 'soon'. |
174 void ScheduleUpdate(); | 176 void ScheduleUpdate(); |
175 | 177 |
176 // If an update is scheduled but not yet started, this resets the timer | 178 // If an update is scheduled but not yet started, this resets the timer |
177 // delaying the start time by a 'small' amount. | 179 // delaying the start time by a 'small' amount. |
178 void DeferScheduledUpdate(); | 180 void DeferScheduledUpdate(); |
179 | 181 |
180 // Starts an update now. | 182 // Starts an update now. |
181 void StartUpdate(); | 183 void StartUpdate(); |
182 | 184 |
183 // Starts the worker if it isn't already running, and calls |task| when the | 185 // Starts the worker if it isn't already running, and calls |task| when the |
184 // worker is running, or |error_callback| if starting the worker failed. | 186 // worker is running, or |error_callback| if starting the worker failed. |
185 // If the worker is already running, |task| is executed synchronously (before | 187 // If the worker is already running, |task| is executed synchronously (before |
186 // this method returns). | 188 // this method returns). |
187 void RunAfterStartWorker(const base::Closure& task, | 189 void RunAfterStartWorker(const base::Closure& task, |
188 const StatusCallback& error_callback); | 190 const StatusCallback& error_callback, |
191 ServiceWorkerMetrics::EventType purpose); | |
nhiroki
2016/03/15 02:18:14
This argument order is different from StartRequest
falken
2016/03/15 05:15:53
Done.
| |
189 | 192 |
190 // Call this while the worker is running before dispatching an event to the | 193 // Call this while the worker is running before dispatching an event to the |
191 // worker. This informs ServiceWorkerVersion about the event in progress. | 194 // worker. This informs ServiceWorkerVersion about the event in progress. |
192 // Returns a request id, which should later be passed to FinishRequest when | 195 // Returns a request id, which should later be passed to FinishRequest when |
193 // the event finished. | 196 // the event finished. |
194 // The |error_callback| is called if either ServiceWorkerVersion decides the | 197 // The |error_callback| is called if either ServiceWorkerVersion decides the |
195 // event is taking too long, or if for some reason the worker stops or is | 198 // event is taking too long, or if for some reason the worker stops or is |
196 // killed before the request finishes. | 199 // killed before the request finishes. |
197 int StartRequest(ServiceWorkerMetrics::EventType event_type, | 200 int StartRequest(ServiceWorkerMetrics::EventType event_type, |
198 const StatusCallback& error_callback); | 201 const StatusCallback& error_callback); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 void OnClaimClients(int request_id); | 576 void OnClaimClients(int request_id); |
574 void OnPongFromWorker(); | 577 void OnPongFromWorker(); |
575 | 578 |
576 void OnFocusClientFinished(int request_id, | 579 void OnFocusClientFinished(int request_id, |
577 const ServiceWorkerClientInfo& client_info); | 580 const ServiceWorkerClientInfo& client_info); |
578 | 581 |
579 void OnRegisterForeignFetchScopes(const std::vector<GURL>& sub_scopes, | 582 void OnRegisterForeignFetchScopes(const std::vector<GURL>& sub_scopes, |
580 const std::vector<url::Origin>& origins); | 583 const std::vector<url::Origin>& origins); |
581 | 584 |
582 void DidEnsureLiveRegistrationForStartWorker( | 585 void DidEnsureLiveRegistrationForStartWorker( |
586 ServiceWorkerMetrics::EventType purpose, | |
583 const StatusCallback& callback, | 587 const StatusCallback& callback, |
584 ServiceWorkerStatusCode status, | 588 ServiceWorkerStatusCode status, |
585 const scoped_refptr<ServiceWorkerRegistration>& registration); | 589 const scoped_refptr<ServiceWorkerRegistration>& registration); |
586 void StartWorkerInternal(); | 590 void StartWorkerInternal(); |
587 | 591 |
588 void DidSkipWaiting(int request_id); | 592 void DidSkipWaiting(int request_id); |
589 | 593 |
590 void OnGetClientFinished(int request_id, | 594 void OnGetClientFinished(int request_id, |
591 const ServiceWorkerClientInfo& client_info); | 595 const ServiceWorkerClientInfo& client_info); |
592 | 596 |
(...skipping 10 matching lines...) Expand all Loading... | |
603 ServiceWorkerStatusCode PingWorker(); | 607 ServiceWorkerStatusCode PingWorker(); |
604 void OnPingTimeout(); | 608 void OnPingTimeout(); |
605 | 609 |
606 // Stops the worker if it is idle (has no in-flight requests) or timed out | 610 // Stops the worker if it is idle (has no in-flight requests) or timed out |
607 // ping. | 611 // ping. |
608 void StopWorkerIfIdle(); | 612 void StopWorkerIfIdle(); |
609 bool HasInflightRequests() const; | 613 bool HasInflightRequests() const; |
610 | 614 |
611 // RecordStartWorkerResult is added as a start callback by StartTimeoutTimer | 615 // RecordStartWorkerResult is added as a start callback by StartTimeoutTimer |
612 // and records metrics about startup. | 616 // and records metrics about startup. |
613 void RecordStartWorkerResult(ServiceWorkerStatusCode status); | 617 void RecordStartWorkerResult(ServiceWorkerMetrics::EventType purpose, |
618 ServiceWorkerStatusCode status); | |
614 | 619 |
615 bool MaybeTimeOutRequest(const RequestInfo& info); | 620 bool MaybeTimeOutRequest(const RequestInfo& info); |
616 void SetAllRequestExpirations(const base::TimeTicks& expiration); | 621 void SetAllRequestExpirations(const base::TimeTicks& expiration); |
617 | 622 |
618 // Returns the reason the embedded worker failed to start, using information | 623 // Returns the reason the embedded worker failed to start, using information |
619 // inaccessible to EmbeddedWorkerInstance. Returns |default_code| if it can't | 624 // inaccessible to EmbeddedWorkerInstance. Returns |default_code| if it can't |
620 // deduce a reason. | 625 // deduce a reason. |
621 ServiceWorkerStatusCode DeduceStartWorkerFailureReason( | 626 ServiceWorkerStatusCode DeduceStartWorkerFailureReason( |
622 ServiceWorkerStatusCode default_code); | 627 ServiceWorkerStatusCode default_code); |
623 | 628 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
792 | 797 |
793 // At this point |this| can have been deleted, so don't do anything other | 798 // At this point |this| can have been deleted, so don't do anything other |
794 // than returning. | 799 // than returning. |
795 | 800 |
796 return true; | 801 return true; |
797 } | 802 } |
798 | 803 |
799 } // namespace content | 804 } // namespace content |
800 | 805 |
801 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 806 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |