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