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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } | 46 } |
47 | 47 |
48 namespace content { | 48 namespace content { |
49 | 49 |
50 class EmbeddedWorkerRegistry; | 50 class EmbeddedWorkerRegistry; |
51 class ServiceWorkerContextCore; | 51 class ServiceWorkerContextCore; |
52 class ServiceWorkerProviderHost; | 52 class ServiceWorkerProviderHost; |
53 class ServiceWorkerRegistration; | 53 class ServiceWorkerRegistration; |
54 class ServiceWorkerURLRequestJob; | 54 class ServiceWorkerURLRequestJob; |
55 struct NavigatorConnectClient; | 55 struct NavigatorConnectClient; |
56 struct PlatformNotificationData; | |
57 struct ServiceWorkerClientInfo; | 56 struct ServiceWorkerClientInfo; |
58 struct ServiceWorkerVersionInfo; | 57 struct ServiceWorkerVersionInfo; |
59 struct TransferredMessagePort; | 58 struct TransferredMessagePort; |
60 | 59 |
61 // This class corresponds to a specific version of a ServiceWorker | 60 // This class corresponds to a specific version of a ServiceWorker |
62 // script for a given pattern. When a script is upgraded, there may be | 61 // script for a given pattern. When a script is upgraded, there may be |
63 // more than one ServiceWorkerVersion "running" at a time, but only | 62 // more than one ServiceWorkerVersion "running" at a time, but only |
64 // one of them is activated. This class connects the actual script with a | 63 // one of them is activated. This class connects the actual script with a |
65 // running worker. | 64 // running worker. |
66 class CONTENT_EXPORT ServiceWorkerVersion | 65 class CONTENT_EXPORT ServiceWorkerVersion |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 263 |
265 // Sends fetch event to the associated embedded worker and calls | 264 // Sends fetch event to the associated embedded worker and calls |
266 // |callback| with the response from the worker. | 265 // |callback| with the response from the worker. |
267 // | 266 // |
268 // This must be called when the status() is ACTIVATED. Calling this in other | 267 // This must be called when the status() is ACTIVATED. Calling this in other |
269 // statuses will result in an error SERVICE_WORKER_ERROR_FAILED. | 268 // statuses will result in an error SERVICE_WORKER_ERROR_FAILED. |
270 void DispatchFetchEvent(const ServiceWorkerFetchRequest& request, | 269 void DispatchFetchEvent(const ServiceWorkerFetchRequest& request, |
271 const base::Closure& prepare_callback, | 270 const base::Closure& prepare_callback, |
272 const FetchCallback& fetch_callback); | 271 const FetchCallback& fetch_callback); |
273 | 272 |
274 // Sends notificationclick event to the associated embedded worker and | |
275 // asynchronously calls |callback| when it errors out or it gets a response | |
276 // from the worker to notify completion. | |
277 // | |
278 // This must be called when the status() is ACTIVATED. | |
279 void DispatchNotificationClickEvent( | |
280 const StatusCallback& callback, | |
281 int64_t persistent_notification_id, | |
282 const PlatformNotificationData& notification_data, | |
283 int action_index); | |
284 | |
285 // Sends a cross origin message event to the associated embedded worker and | 273 // Sends a cross origin message event to the associated embedded worker and |
286 // asynchronously calls |callback| when the message was sent (or failed to | 274 // asynchronously calls |callback| when the message was sent (or failed to |
287 // sent). | 275 // sent). |
288 // It is the responsibility of the code calling this method to make sure that | 276 // It is the responsibility of the code calling this method to make sure that |
289 // any transferred message ports are put on hold while potentially a process | 277 // any transferred message ports are put on hold while potentially a process |
290 // for the service worker is spun up. | 278 // for the service worker is spun up. |
291 // | 279 // |
292 // This must be called when the status() is ACTIVATED. | 280 // This must be called when the status() is ACTIVATED. |
293 void DispatchCrossOriginMessageEvent( | 281 void DispatchCrossOriginMessageEvent( |
294 const NavigatorConnectClient& client, | 282 const NavigatorConnectClient& client, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerWaitForeverInFetchTest, | 390 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerWaitForeverInFetchTest, |
403 MixedRequestTimeouts); | 391 MixedRequestTimeouts); |
404 | 392 |
405 class Metrics; | 393 class Metrics; |
406 class PingController; | 394 class PingController; |
407 | 395 |
408 enum RequestType { | 396 enum RequestType { |
409 REQUEST_ACTIVATE, | 397 REQUEST_ACTIVATE, |
410 REQUEST_INSTALL, | 398 REQUEST_INSTALL, |
411 REQUEST_FETCH, | 399 REQUEST_FETCH, |
412 REQUEST_NOTIFICATION_CLICK, | |
413 REQUEST_CUSTOM, | 400 REQUEST_CUSTOM, |
414 NUM_REQUEST_TYPES | 401 NUM_REQUEST_TYPES |
415 }; | 402 }; |
416 | 403 |
417 struct RequestInfo { | 404 struct RequestInfo { |
418 RequestInfo(int id, | 405 RequestInfo(int id, |
419 RequestType type, | 406 RequestType type, |
420 ServiceWorkerMetrics::EventType event_type, | 407 ServiceWorkerMetrics::EventType event_type, |
421 const base::TimeTicks& expiration, | 408 const base::TimeTicks& expiration, |
422 TimeoutBehavior timeout_behavior); | 409 TimeoutBehavior timeout_behavior); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 void OnGetClients(int request_id, | 550 void OnGetClients(int request_id, |
564 const ServiceWorkerClientQueryOptions& options); | 551 const ServiceWorkerClientQueryOptions& options); |
565 | 552 |
566 void OnActivateEventFinished(int request_id, | 553 void OnActivateEventFinished(int request_id, |
567 blink::WebServiceWorkerEventResult result); | 554 blink::WebServiceWorkerEventResult result); |
568 void OnInstallEventFinished(int request_id, | 555 void OnInstallEventFinished(int request_id, |
569 blink::WebServiceWorkerEventResult result); | 556 blink::WebServiceWorkerEventResult result); |
570 void OnFetchEventFinished(int request_id, | 557 void OnFetchEventFinished(int request_id, |
571 ServiceWorkerFetchEventResult result, | 558 ServiceWorkerFetchEventResult result, |
572 const ServiceWorkerResponse& response); | 559 const ServiceWorkerResponse& response); |
573 void OnNotificationClickEventFinished(int request_id); | |
574 void OnSimpleEventResponse(int request_id, | 560 void OnSimpleEventResponse(int request_id, |
575 blink::WebServiceWorkerEventResult result); | 561 blink::WebServiceWorkerEventResult result); |
576 void OnOpenWindow(int request_id, GURL url); | 562 void OnOpenWindow(int request_id, GURL url); |
577 void OnOpenWindowFinished(int request_id, | 563 void OnOpenWindowFinished(int request_id, |
578 ServiceWorkerStatusCode status, | 564 ServiceWorkerStatusCode status, |
579 const std::string& client_uuid, | 565 const std::string& client_uuid, |
580 const ServiceWorkerClientInfo& client_info); | 566 const ServiceWorkerClientInfo& client_info); |
581 | 567 |
582 void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data); | 568 void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data); |
583 void OnSetCachedMetadataFinished(int64_t callback_id, int result); | 569 void OnSetCachedMetadataFinished(int64_t callback_id, int result); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; | 678 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; |
693 std::vector<StatusCallback> start_callbacks_; | 679 std::vector<StatusCallback> start_callbacks_; |
694 std::vector<StatusCallback> stop_callbacks_; | 680 std::vector<StatusCallback> stop_callbacks_; |
695 std::vector<base::Closure> status_change_callbacks_; | 681 std::vector<base::Closure> status_change_callbacks_; |
696 | 682 |
697 // Message callbacks. (Update HasInflightRequests() too when you update this | 683 // Message callbacks. (Update HasInflightRequests() too when you update this |
698 // list.) | 684 // list.) |
699 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> activate_requests_; | 685 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> activate_requests_; |
700 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> install_requests_; | 686 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> install_requests_; |
701 IDMap<PendingRequest<FetchCallback>, IDMapOwnPointer> fetch_requests_; | 687 IDMap<PendingRequest<FetchCallback>, IDMapOwnPointer> fetch_requests_; |
702 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> | |
703 notification_click_requests_; | |
704 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> custom_requests_; | 688 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> custom_requests_; |
705 | 689 |
706 // Stores all open connections to mojo services. Maps the service name to | 690 // Stores all open connections to mojo services. Maps the service name to |
707 // the actual interface pointer. When a connection is closed it is removed | 691 // the actual interface pointer. When a connection is closed it is removed |
708 // from this map. | 692 // from this map. |
709 // mojo_services_[Interface::Name_] is assumed to always contain a | 693 // mojo_services_[Interface::Name_] is assumed to always contain a |
710 // MojoServiceWrapper<Interface> instance. | 694 // MojoServiceWrapper<Interface> instance. |
711 base::ScopedPtrHashMap<const char*, scoped_ptr<BaseMojoServiceWrapper>> | 695 base::ScopedPtrHashMap<const char*, scoped_ptr<BaseMojoServiceWrapper>> |
712 mojo_services_; | 696 mojo_services_; |
713 | 697 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 if (!result || received_request_id != request_id_) | 814 if (!result || received_request_id != request_id_) |
831 return false; | 815 return false; |
832 | 816 |
833 CallbackType protect(callback_); | 817 CallbackType protect(callback_); |
834 // Essentially same code as what IPC_MESSAGE_FORWARD expands to. | 818 // Essentially same code as what IPC_MESSAGE_FORWARD expands to. |
835 void* param = nullptr; | 819 void* param = nullptr; |
836 if (!ResponseMessage::Dispatch(&message, &callback_, this, param, | 820 if (!ResponseMessage::Dispatch(&message, &callback_, this, param, |
837 &CallbackType::Run)) | 821 &CallbackType::Run)) |
838 message.set_dispatch_error(); | 822 message.set_dispatch_error(); |
839 | 823 |
| 824 // At this point |this| can have been deleted, so don't do anything other |
| 825 // than returning. |
| 826 |
840 return true; | 827 return true; |
841 } | 828 } |
842 | 829 |
843 } // namespace content | 830 } // namespace content |
844 | 831 |
845 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 832 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |