| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
| 6 #define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 6 #define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 const ServiceWorkerResponse& response); | 68 const ServiceWorkerResponse& response); |
| 69 void DidHandleNotificationClickEvent( | 69 void DidHandleNotificationClickEvent( |
| 70 int request_id, | 70 int request_id, |
| 71 blink::WebServiceWorkerEventResult result); | 71 blink::WebServiceWorkerEventResult result); |
| 72 void DidHandlePushEvent(int request_id, | 72 void DidHandlePushEvent(int request_id, |
| 73 blink::WebServiceWorkerEventResult result); | 73 blink::WebServiceWorkerEventResult result); |
| 74 void DidHandleSyncEvent(int request_id); | 74 void DidHandleSyncEvent(int request_id); |
| 75 void DidHandleCrossOriginConnectEvent(int request_id, bool accept_connection); | 75 void DidHandleCrossOriginConnectEvent(int request_id, bool accept_connection); |
| 76 void GetClientDocuments( | 76 void GetClientDocuments( |
| 77 blink::WebServiceWorkerClientsCallbacks* callbacks); | 77 blink::WebServiceWorkerClientsCallbacks* callbacks); |
| 78 void OpenWindow(const GURL& url, |
| 79 blink::WebServiceWorkerClientCallbacks* callbacks); |
| 78 void PostMessageToDocument( | 80 void PostMessageToDocument( |
| 79 int client_id, | 81 int client_id, |
| 80 const base::string16& message, | 82 const base::string16& message, |
| 81 scoped_ptr<blink::WebMessagePortChannelArray> channels); | 83 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
| 82 void PostCrossOriginMessageToClient( | 84 void PostCrossOriginMessageToClient( |
| 83 const blink::WebCrossOriginServiceWorkerClient& client, | 85 const blink::WebCrossOriginServiceWorkerClient& client, |
| 84 const base::string16& message, | 86 const base::string16& message, |
| 85 scoped_ptr<blink::WebMessagePortChannelArray> channels); | 87 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
| 86 void FocusClient(int client_id, | 88 void FocusClient(int client_id, |
| 87 blink::WebServiceWorkerClientFocusCallback* callback); | 89 blink::WebServiceWorkerClientFocusCallback* callback); |
| 88 void SkipWaiting(blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); | 90 void SkipWaiting(blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); |
| 89 void ClaimClients(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); | 91 void ClaimClients(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); |
| 90 | 92 |
| 91 // Send a message to the browser. Takes ownership of |message|. | 93 // Send a message to the browser. Takes ownership of |message|. |
| 92 void Send(IPC::Message* message); | 94 void Send(IPC::Message* message); |
| 93 | 95 |
| 94 // Get routing_id for sending message to the ServiceWorkerVersion | 96 // Get routing_id for sending message to the ServiceWorkerVersion |
| 95 // in the browser process. | 97 // in the browser process. |
| 96 int GetRoutingID() const; | 98 int GetRoutingID() const; |
| 97 | 99 |
| 98 blink::WebServiceWorkerCacheStorage* cache_storage() { | 100 blink::WebServiceWorkerCacheStorage* cache_storage() { |
| 99 return cache_storage_dispatcher_.get(); | 101 return cache_storage_dispatcher_.get(); |
| 100 } | 102 } |
| 101 | 103 |
| 102 private: | 104 private: |
| 103 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> | 105 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> |
| 104 ClientsCallbacksMap; | 106 ClientsCallbacksMap; |
| 105 typedef IDMap<blink::WebServiceWorkerClientsClaimCallbacks, IDMapOwnPointer> | 107 typedef IDMap<blink::WebServiceWorkerClientsClaimCallbacks, IDMapOwnPointer> |
| 106 ClaimClientsCallbacksMap; | 108 ClaimClientsCallbacksMap; |
| 109 typedef IDMap<blink::WebServiceWorkerClientCallbacks, IDMapOwnPointer> |
| 110 ClientCallbacksMap; |
| 107 typedef IDMap<blink::WebServiceWorkerClientFocusCallback, IDMapOwnPointer> | 111 typedef IDMap<blink::WebServiceWorkerClientFocusCallback, IDMapOwnPointer> |
| 108 FocusClientCallbacksMap; | 112 FocusClientCallbacksMap; |
| 109 typedef IDMap<blink::WebServiceWorkerSkipWaitingCallbacks, IDMapOwnPointer> | 113 typedef IDMap<blink::WebServiceWorkerSkipWaitingCallbacks, IDMapOwnPointer> |
| 110 SkipWaitingCallbacksMap; | 114 SkipWaitingCallbacksMap; |
| 111 | 115 |
| 112 void OnActivateEvent(int request_id); | 116 void OnActivateEvent(int request_id); |
| 113 void OnInstallEvent(int request_id, int active_version_id); | 117 void OnInstallEvent(int request_id, int active_version_id); |
| 114 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); | 118 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); |
| 115 void OnSyncEvent(int request_id); | 119 void OnSyncEvent(int request_id); |
| 116 void OnNotificationClickEvent( | 120 void OnNotificationClickEvent( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 127 void OnPostMessage(const base::string16& message, | 131 void OnPostMessage(const base::string16& message, |
| 128 const std::vector<int>& sent_message_port_ids, | 132 const std::vector<int>& sent_message_port_ids, |
| 129 const std::vector<int>& new_routing_ids); | 133 const std::vector<int>& new_routing_ids); |
| 130 void OnCrossOriginMessageToWorker( | 134 void OnCrossOriginMessageToWorker( |
| 131 const NavigatorConnectClient& client, | 135 const NavigatorConnectClient& client, |
| 132 const base::string16& message, | 136 const base::string16& message, |
| 133 const std::vector<int>& sent_message_port_ids, | 137 const std::vector<int>& sent_message_port_ids, |
| 134 const std::vector<int>& new_routing_ids); | 138 const std::vector<int>& new_routing_ids); |
| 135 void OnDidGetClientDocuments( | 139 void OnDidGetClientDocuments( |
| 136 int request_id, const std::vector<ServiceWorkerClientInfo>& clients); | 140 int request_id, const std::vector<ServiceWorkerClientInfo>& clients); |
| 141 void OnOpenWindowResponse(int request_id, |
| 142 const ServiceWorkerClientInfo& client); |
| 143 void OnOpenWindowError(int request_id); |
| 137 void OnFocusClientResponse(int request_id, bool result); | 144 void OnFocusClientResponse(int request_id, bool result); |
| 138 void OnDidSkipWaiting(int request_id); | 145 void OnDidSkipWaiting(int request_id); |
| 139 void OnDidClaimClients(int request_id); | 146 void OnDidClaimClients(int request_id); |
| 140 void OnClaimClientsError(int request_id, | 147 void OnClaimClientsError(int request_id, |
| 141 blink::WebServiceWorkerError::ErrorType error_type, | 148 blink::WebServiceWorkerError::ErrorType error_type, |
| 142 const base::string16& message); | 149 const base::string16& message); |
| 143 | 150 |
| 144 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; | 151 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; |
| 145 | 152 |
| 146 // Not owned; embedded_context_ owns this. | 153 // Not owned; embedded_context_ owns this. |
| 147 EmbeddedWorkerContextClient* embedded_context_; | 154 EmbeddedWorkerContextClient* embedded_context_; |
| 148 | 155 |
| 149 // Not owned; this object is destroyed when proxy_ becomes invalid. | 156 // Not owned; this object is destroyed when proxy_ becomes invalid. |
| 150 blink::WebServiceWorkerContextProxy* proxy_; | 157 blink::WebServiceWorkerContextProxy* proxy_; |
| 151 | 158 |
| 152 // Used for incoming messages from the browser for which an outgoing response | 159 // Used for incoming messages from the browser for which an outgoing response |
| 153 // back to the browser is expected, the id must be sent back with the | 160 // back to the browser is expected, the id must be sent back with the |
| 154 // response. | 161 // response. |
| 155 int current_request_id_; | 162 int current_request_id_; |
| 156 | 163 |
| 157 // Pending callbacks for GetClientDocuments(). | 164 // Pending callbacks for GetClientDocuments(). |
| 158 ClientsCallbacksMap pending_clients_callbacks_; | 165 ClientsCallbacksMap pending_clients_callbacks_; |
| 159 | 166 |
| 167 // Pending callbacks for OpenWindow(). |
| 168 ClientCallbacksMap pending_client_callbacks_; |
| 169 |
| 160 // Pending callbacks for FocusClient(). | 170 // Pending callbacks for FocusClient(). |
| 161 FocusClientCallbacksMap pending_focus_client_callbacks_; | 171 FocusClientCallbacksMap pending_focus_client_callbacks_; |
| 162 | 172 |
| 163 // Pending callbacks for SkipWaiting(). | 173 // Pending callbacks for SkipWaiting(). |
| 164 SkipWaitingCallbacksMap pending_skip_waiting_callbacks_; | 174 SkipWaitingCallbacksMap pending_skip_waiting_callbacks_; |
| 165 | 175 |
| 166 // Pending callbacks for ClaimClients(). | 176 // Pending callbacks for ClaimClients(). |
| 167 ClaimClientsCallbacksMap pending_claim_clients_callbacks_; | 177 ClaimClientsCallbacksMap pending_claim_clients_callbacks_; |
| 168 | 178 |
| 169 // Capture timestamps for UMA | 179 // Capture timestamps for UMA |
| 170 std::map<int, base::TimeTicks> activate_start_timings_; | 180 std::map<int, base::TimeTicks> activate_start_timings_; |
| 171 std::map<int, base::TimeTicks> fetch_start_timings_; | 181 std::map<int, base::TimeTicks> fetch_start_timings_; |
| 172 std::map<int, base::TimeTicks> install_start_timings_; | 182 std::map<int, base::TimeTicks> install_start_timings_; |
| 173 std::map<int, base::TimeTicks> notification_click_start_timings_; | 183 std::map<int, base::TimeTicks> notification_click_start_timings_; |
| 174 std::map<int, base::TimeTicks> push_start_timings_; | 184 std::map<int, base::TimeTicks> push_start_timings_; |
| 175 | 185 |
| 176 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); | 186 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); |
| 177 }; | 187 }; |
| 178 | 188 |
| 179 } // namespace content | 189 } // namespace content |
| 180 | 190 |
| 181 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 191 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
| OLD | NEW |