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 | 287 // Dispatches an event. If dispatching the event fails, all of the error |
285 // callbacks that were associated with |request_ids| via StartRequest are | 288 // callbacks that were associated with |request_ids| via StartRequest are |
286 // called. | 289 // called. |
287 // Use RegisterRequestCallback to register a callback to receive messages sent | 290 // Use RegisterRequestCallback to register a callback to receive messages sent |
288 // back in response to this event before calling this method. This must be | 291 // back in response to this event before calling this method. This must be |
289 // called when the worker is running. | 292 // called when the worker is running. |
290 void DispatchEvent(const std::vector<int>& request_ids, | 293 void DispatchEvent(const std::vector<int>& request_ids, |
leonhsl(Using Gerrit)
2017/04/25 06:53:27
Remove this declaration.
xiaofengzhang
2017/04/25 07:18:15
sorry, I remembered it was already deleted. :-(
xiaofengzhang
2017/04/25 09:13:32
Done.
| |
291 const IPC::Message& message); | 294 const IPC::Message& message); |
292 | 295 |
293 // This method registers a callback to receive messages sent back from the | 296 // This method registers a callback to receive messages sent back from the |
294 // service worker in response to |request_id|. | 297 // service worker in response to |request_id|. |
295 // ResponseMessage is the type of the IPC message that is used for the | 298 // ResponseMessage is the type of the IPC message that is used for the |
296 // response, and its first argument MUST be the request_id. | 299 // response, and its first argument MUST be the request_id. |
297 // Callback registration should be done once for one request_id. | 300 // Callback registration should be done once for one request_id. |
298 template <typename ResponseMessage, typename ResponseCallbackType> | 301 template <typename ResponseMessage, typename ResponseCallbackType> |
299 void RegisterRequestCallback(int request_id, | 302 void RegisterRequestCallback(int request_id, |
300 const ResponseCallbackType& callback); | 303 const ResponseCallbackType& callback); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 void OnNavigateClientFinished(int request_id, | 612 void OnNavigateClientFinished(int request_id, |
610 ServiceWorkerStatusCode status, | 613 ServiceWorkerStatusCode status, |
611 const ServiceWorkerClientInfo& client_info); | 614 const ServiceWorkerClientInfo& client_info); |
612 void OnSkipWaiting(int request_id); | 615 void OnSkipWaiting(int request_id); |
613 void OnClaimClients(int request_id); | 616 void OnClaimClients(int request_id); |
614 void OnPongFromWorker(); | 617 void OnPongFromWorker(); |
615 | 618 |
616 void OnFocusClientFinished(int request_id, | 619 void OnFocusClientFinished(int request_id, |
617 const ServiceWorkerClientInfo& client_info); | 620 const ServiceWorkerClientInfo& client_info); |
618 | 621 |
619 void OnRegisterForeignFetchScopes(const std::vector<GURL>& sub_scopes, | |
620 const std::vector<url::Origin>& origins); | |
621 | |
622 void DidEnsureLiveRegistrationForStartWorker( | 622 void DidEnsureLiveRegistrationForStartWorker( |
623 ServiceWorkerMetrics::EventType purpose, | 623 ServiceWorkerMetrics::EventType purpose, |
624 Status prestart_status, | 624 Status prestart_status, |
625 bool is_browser_startup_complete, | 625 bool is_browser_startup_complete, |
626 const StatusCallback& callback, | 626 const StatusCallback& callback, |
627 ServiceWorkerStatusCode status, | 627 ServiceWorkerStatusCode status, |
628 scoped_refptr<ServiceWorkerRegistration> registration); | 628 scoped_refptr<ServiceWorkerRegistration> registration); |
629 void StartWorkerInternal(); | 629 void StartWorkerInternal(); |
630 | 630 |
631 void DidSkipWaiting(int request_id); | 631 void DidSkipWaiting(int request_id); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 | 835 |
836 // At this point |this| can have been deleted, so don't do anything other | 836 // At this point |this| can have been deleted, so don't do anything other |
837 // than returning. | 837 // than returning. |
838 | 838 |
839 return true; | 839 return true; |
840 } | 840 } |
841 | 841 |
842 } // namespace content | 842 } // namespace content |
843 | 843 |
844 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 844 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |