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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // Informs ServiceWorkerVersion that an event has finished being dispatched. | 257 // Informs ServiceWorkerVersion that an event has finished being dispatched. |
258 // Returns false if no pending requests with the provided id exist, for | 258 // Returns false if no pending requests with the provided id exist, for |
259 // example if the request has already timed out. | 259 // example if the request has already timed out. |
260 // Pass the result of the event to |was_handled|, which is used to record | 260 // Pass the result of the event to |was_handled|, which is used to record |
261 // statistics based on the event status. | 261 // statistics based on the event status. |
262 // TODO(mek): Use something other than a bool for event status. | 262 // TODO(mek): Use something other than a bool for event status. |
263 bool FinishRequest(int request_id, | 263 bool FinishRequest(int request_id, |
264 bool was_handled, | 264 bool was_handled, |
265 base::Time dispatch_event_time); | 265 base::Time dispatch_event_time); |
266 | 266 |
| 267 void RegisterForeignFetchScopes(const std::vector<GURL>& sub_scopes, |
| 268 const std::vector<url::Origin>& origins); |
| 269 |
267 // Finishes an external request that was started by StartExternalRequest(). | 270 // Finishes an external request that was started by StartExternalRequest(). |
268 // Returns false if there was an error finishing the request: e.g. the request | 271 // Returns false if there was an error finishing the request: e.g. the request |
269 // was not found or the worker already terminated. | 272 // was not found or the worker already terminated. |
270 bool FinishExternalRequest(const std::string& request_uuid); | 273 bool FinishExternalRequest(const std::string& request_uuid); |
271 | 274 |
272 // Creates a callback that is to be used for marking simple events dispatched | 275 // Creates a callback that is to be used for marking simple events dispatched |
273 // through the ServiceWorkerEventDispatcher as finished for the |request_id|. | 276 // through the ServiceWorkerEventDispatcher as finished for the |request_id|. |
274 // Simple event means those events expecting a response with only a status | 277 // Simple event means those events expecting a response with only a status |
275 // code and the dispatch time. See service_worker_event_dispatcher.mojom. | 278 // code and the dispatch time. See service_worker_event_dispatcher.mojom. |
276 SimpleEventCallback CreateSimpleEventCallback(int request_id); | 279 SimpleEventCallback CreateSimpleEventCallback(int request_id); |
277 | 280 |
278 // This must be called when the worker is running. | 281 // This must be called when the worker is running. |
279 mojom::ServiceWorkerEventDispatcher* event_dispatcher() { | 282 mojom::ServiceWorkerEventDispatcher* event_dispatcher() { |
280 DCHECK(event_dispatcher_.is_bound()); | 283 DCHECK(event_dispatcher_.is_bound()); |
281 return event_dispatcher_.get(); | 284 return event_dispatcher_.get(); |
282 } | 285 } |
283 | 286 |
284 // Dispatches an event. If dispatching the event fails, all of the error | |
285 // callbacks that were associated with |request_ids| via StartRequest are | |
286 // called. | |
287 // Use RegisterRequestCallback to register a callback to receive messages sent | |
288 // back in response to this event before calling this method. This must be | |
289 // called when the worker is running. | |
290 void DispatchEvent(const std::vector<int>& request_ids, | |
291 const IPC::Message& message); | |
292 | |
293 // This method registers a callback to receive messages sent back from the | 287 // This method registers a callback to receive messages sent back from the |
294 // service worker in response to |request_id|. | 288 // service worker in response to |request_id|. |
295 // ResponseMessage is the type of the IPC message that is used for the | 289 // ResponseMessage is the type of the IPC message that is used for the |
296 // response, and its first argument MUST be the request_id. | 290 // response, and its first argument MUST be the request_id. |
297 // Callback registration should be done once for one request_id. | 291 // Callback registration should be done once for one request_id. |
298 template <typename ResponseMessage, typename ResponseCallbackType> | 292 template <typename ResponseMessage, typename ResponseCallbackType> |
299 void RegisterRequestCallback(int request_id, | 293 void RegisterRequestCallback(int request_id, |
300 const ResponseCallbackType& callback); | 294 const ResponseCallbackType& callback); |
301 | 295 |
302 // Adds and removes |provider_host| as a controllee of this ServiceWorker. | 296 // Adds and removes |provider_host| as a controllee of this ServiceWorker. |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 void OnNavigateClientFinished(int request_id, | 603 void OnNavigateClientFinished(int request_id, |
610 ServiceWorkerStatusCode status, | 604 ServiceWorkerStatusCode status, |
611 const ServiceWorkerClientInfo& client_info); | 605 const ServiceWorkerClientInfo& client_info); |
612 void OnSkipWaiting(int request_id); | 606 void OnSkipWaiting(int request_id); |
613 void OnClaimClients(int request_id); | 607 void OnClaimClients(int request_id); |
614 void OnPongFromWorker(); | 608 void OnPongFromWorker(); |
615 | 609 |
616 void OnFocusClientFinished(int request_id, | 610 void OnFocusClientFinished(int request_id, |
617 const ServiceWorkerClientInfo& client_info); | 611 const ServiceWorkerClientInfo& client_info); |
618 | 612 |
619 void OnRegisterForeignFetchScopes(const std::vector<GURL>& sub_scopes, | |
620 const std::vector<url::Origin>& origins); | |
621 | |
622 void DidEnsureLiveRegistrationForStartWorker( | 613 void DidEnsureLiveRegistrationForStartWorker( |
623 ServiceWorkerMetrics::EventType purpose, | 614 ServiceWorkerMetrics::EventType purpose, |
624 Status prestart_status, | 615 Status prestart_status, |
625 bool is_browser_startup_complete, | 616 bool is_browser_startup_complete, |
626 const StatusCallback& callback, | 617 const StatusCallback& callback, |
627 ServiceWorkerStatusCode status, | 618 ServiceWorkerStatusCode status, |
628 scoped_refptr<ServiceWorkerRegistration> registration); | 619 scoped_refptr<ServiceWorkerRegistration> registration); |
629 void StartWorkerInternal(); | 620 void StartWorkerInternal(); |
630 | 621 |
631 void DidSkipWaiting(int request_id); | 622 void DidSkipWaiting(int request_id); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 | 826 |
836 // At this point |this| can have been deleted, so don't do anything other | 827 // At this point |this| can have been deleted, so don't do anything other |
837 // than returning. | 828 // than returning. |
838 | 829 |
839 return true; | 830 return true; |
840 } | 831 } |
841 | 832 |
842 } // namespace content | 833 } // namespace content |
843 | 834 |
844 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 835 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |