| 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 <map> | 10 #include <map> |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // asynchronously calls |callback| when it errors out or it gets a response | 265 // asynchronously calls |callback| when it errors out or it gets a response |
| 266 // from the worker to notify completion. | 266 // from the worker to notify completion. |
| 267 // | 267 // |
| 268 // This must be called when the status() is ACTIVATED. | 268 // This must be called when the status() is ACTIVATED. |
| 269 void DispatchNotificationClickEvent( | 269 void DispatchNotificationClickEvent( |
| 270 const StatusCallback& callback, | 270 const StatusCallback& callback, |
| 271 int64_t persistent_notification_id, | 271 int64_t persistent_notification_id, |
| 272 const PlatformNotificationData& notification_data, | 272 const PlatformNotificationData& notification_data, |
| 273 int action_index); | 273 int action_index); |
| 274 | 274 |
| 275 // Sends push event to the associated embedded worker and asynchronously calls | |
| 276 // |callback| when it errors out or it gets a response from the worker to | |
| 277 // notify completion. | |
| 278 // | |
| 279 // This must be called when the status() is ACTIVATED. | |
| 280 void DispatchPushEvent(const StatusCallback& callback, | |
| 281 const std::string& data); | |
| 282 | |
| 283 // Sends a cross origin message event to the associated embedded worker and | 275 // Sends a cross origin message event to the associated embedded worker and |
| 284 // asynchronously calls |callback| when the message was sent (or failed to | 276 // asynchronously calls |callback| when the message was sent (or failed to |
| 285 // sent). | 277 // sent). |
| 286 // It is the responsibility of the code calling this method to make sure that | 278 // It is the responsibility of the code calling this method to make sure that |
| 287 // any transferred message ports are put on hold while potentially a process | 279 // any transferred message ports are put on hold while potentially a process |
| 288 // for the service worker is spun up. | 280 // for the service worker is spun up. |
| 289 // | 281 // |
| 290 // This must be called when the status() is ACTIVATED. | 282 // This must be called when the status() is ACTIVATED. |
| 291 void DispatchCrossOriginMessageEvent( | 283 void DispatchCrossOriginMessageEvent( |
| 292 const NavigatorConnectClient& client, | 284 const NavigatorConnectClient& client, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 MixedRequestTimeouts); | 391 MixedRequestTimeouts); |
| 400 | 392 |
| 401 class Metrics; | 393 class Metrics; |
| 402 class PingController; | 394 class PingController; |
| 403 | 395 |
| 404 enum RequestType { | 396 enum RequestType { |
| 405 REQUEST_ACTIVATE, | 397 REQUEST_ACTIVATE, |
| 406 REQUEST_INSTALL, | 398 REQUEST_INSTALL, |
| 407 REQUEST_FETCH, | 399 REQUEST_FETCH, |
| 408 REQUEST_NOTIFICATION_CLICK, | 400 REQUEST_NOTIFICATION_CLICK, |
| 409 REQUEST_PUSH, | |
| 410 REQUEST_CUSTOM, | 401 REQUEST_CUSTOM, |
| 411 NUM_REQUEST_TYPES | 402 NUM_REQUEST_TYPES |
| 412 }; | 403 }; |
| 413 | 404 |
| 414 struct RequestInfo { | 405 struct RequestInfo { |
| 415 RequestInfo(int id, | 406 RequestInfo(int id, |
| 416 RequestType type, | 407 RequestType type, |
| 417 ServiceWorkerMetrics::EventType event_type, | 408 ServiceWorkerMetrics::EventType event_type, |
| 418 const base::TimeTicks& expiration, | 409 const base::TimeTicks& expiration, |
| 419 TimeoutBehavior timeout_behavior); | 410 TimeoutBehavior timeout_behavior); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 const ServiceWorkerClientQueryOptions& options); | 552 const ServiceWorkerClientQueryOptions& options); |
| 562 | 553 |
| 563 void OnActivateEventFinished(int request_id, | 554 void OnActivateEventFinished(int request_id, |
| 564 blink::WebServiceWorkerEventResult result); | 555 blink::WebServiceWorkerEventResult result); |
| 565 void OnInstallEventFinished(int request_id, | 556 void OnInstallEventFinished(int request_id, |
| 566 blink::WebServiceWorkerEventResult result); | 557 blink::WebServiceWorkerEventResult result); |
| 567 void OnFetchEventFinished(int request_id, | 558 void OnFetchEventFinished(int request_id, |
| 568 ServiceWorkerFetchEventResult result, | 559 ServiceWorkerFetchEventResult result, |
| 569 const ServiceWorkerResponse& response); | 560 const ServiceWorkerResponse& response); |
| 570 void OnNotificationClickEventFinished(int request_id); | 561 void OnNotificationClickEventFinished(int request_id); |
| 571 void OnPushEventFinished(int request_id, | |
| 572 blink::WebServiceWorkerEventResult result); | |
| 573 void OnOpenWindow(int request_id, GURL url); | 562 void OnOpenWindow(int request_id, GURL url); |
| 574 void OnOpenWindowFinished(int request_id, | 563 void OnOpenWindowFinished(int request_id, |
| 575 ServiceWorkerStatusCode status, | 564 ServiceWorkerStatusCode status, |
| 576 const std::string& client_uuid, | 565 const std::string& client_uuid, |
| 577 const ServiceWorkerClientInfo& client_info); | 566 const ServiceWorkerClientInfo& client_info); |
| 578 | 567 |
| 579 void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data); | 568 void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data); |
| 580 void OnSetCachedMetadataFinished(int64_t callback_id, int result); | 569 void OnSetCachedMetadataFinished(int64_t callback_id, int result); |
| 581 void OnClearCachedMetadata(const GURL& url); | 570 void OnClearCachedMetadata(const GURL& url); |
| 582 void OnClearCachedMetadataFinished(int64_t callback_id, int result); | 571 void OnClearCachedMetadataFinished(int64_t callback_id, int result); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 std::vector<StatusCallback> stop_callbacks_; | 680 std::vector<StatusCallback> stop_callbacks_; |
| 692 std::vector<base::Closure> status_change_callbacks_; | 681 std::vector<base::Closure> status_change_callbacks_; |
| 693 | 682 |
| 694 // Message callbacks. (Update HasInflightRequests() too when you update this | 683 // Message callbacks. (Update HasInflightRequests() too when you update this |
| 695 // list.) | 684 // list.) |
| 696 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> activate_requests_; | 685 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> activate_requests_; |
| 697 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> install_requests_; | 686 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> install_requests_; |
| 698 IDMap<PendingRequest<FetchCallback>, IDMapOwnPointer> fetch_requests_; | 687 IDMap<PendingRequest<FetchCallback>, IDMapOwnPointer> fetch_requests_; |
| 699 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> | 688 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> |
| 700 notification_click_requests_; | 689 notification_click_requests_; |
| 701 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> push_requests_; | |
| 702 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> custom_requests_; | 690 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> custom_requests_; |
| 703 | 691 |
| 704 // Stores all open connections to mojo services. Maps the service name to | 692 // Stores all open connections to mojo services. Maps the service name to |
| 705 // the actual interface pointer. When a connection is closed it is removed | 693 // the actual interface pointer. When a connection is closed it is removed |
| 706 // from this map. | 694 // from this map. |
| 707 // mojo_services_[Interface::Name_] is assumed to always contain a | 695 // mojo_services_[Interface::Name_] is assumed to always contain a |
| 708 // MojoServiceWrapper<Interface> instance. | 696 // MojoServiceWrapper<Interface> instance. |
| 709 base::ScopedPtrHashMap<const char*, scoped_ptr<BaseMojoServiceWrapper>> | 697 base::ScopedPtrHashMap<const char*, scoped_ptr<BaseMojoServiceWrapper>> |
| 710 mojo_services_; | 698 mojo_services_; |
| 711 | 699 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 template <typename ResponseMessage, typename CallbackType> | 801 template <typename ResponseMessage, typename CallbackType> |
| 814 bool ServiceWorkerVersion::EventResponseHandler<ResponseMessage, CallbackType>:: | 802 bool ServiceWorkerVersion::EventResponseHandler<ResponseMessage, CallbackType>:: |
| 815 OnMessageReceived(const IPC::Message& message) { | 803 OnMessageReceived(const IPC::Message& message) { |
| 816 if (message.type() != ResponseMessage::ID) | 804 if (message.type() != ResponseMessage::ID) |
| 817 return false; | 805 return false; |
| 818 int received_request_id; | 806 int received_request_id; |
| 819 bool result = base::PickleIterator(message).ReadInt(&received_request_id); | 807 bool result = base::PickleIterator(message).ReadInt(&received_request_id); |
| 820 if (!result || received_request_id != request_id_) | 808 if (!result || received_request_id != request_id_) |
| 821 return false; | 809 return false; |
| 822 | 810 |
| 811 CallbackType protect(callback_); |
| 823 // Essentially same code as what IPC_MESSAGE_FORWARD expands to. | 812 // Essentially same code as what IPC_MESSAGE_FORWARD expands to. |
| 824 void* param = nullptr; | 813 void* param = nullptr; |
| 825 if (!ResponseMessage::Dispatch(&message, &callback_, this, param, | 814 if (!ResponseMessage::Dispatch(&message, &callback_, this, param, |
| 826 &CallbackType::Run)) | 815 &CallbackType::Run)) |
| 827 message.set_dispatch_error(); | 816 message.set_dispatch_error(); |
| 828 | 817 |
| 829 return true; | 818 return true; |
| 830 } | 819 } |
| 831 | 820 |
| 832 } // namespace content | 821 } // namespace content |
| 833 | 822 |
| 834 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 823 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
| OLD | NEW |