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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "content/child/webmessageportchannel_impl.h" | 17 #include "content/child/webmessageportchannel_impl.h" |
18 #include "content/common/service_worker/service_worker_types.h" | 18 #include "content/common/service_worker/service_worker_types.h" |
19 #include "content/renderer/service_worker/service_worker_cache_storage_dispatche
r.h" | 19 #include "content/renderer/service_worker/service_worker_cache_storage_dispatche
r.h" |
20 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h" | 20 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h" |
21 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 21 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
22 #include "third_party/WebKit/public/platform/WebServiceWorkerClientFocusCallback
.h" | |
23 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsClaimCallbac
ks.h" | 22 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsClaimCallbac
ks.h" |
24 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h" | 23 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h" |
25 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h" | 24 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h" |
26 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" | 25 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" |
27 #include "third_party/WebKit/public/platform/WebServiceWorkerSkipWaitingCallback
s.h" | 26 #include "third_party/WebKit/public/platform/WebServiceWorkerSkipWaitingCallback
s.h" |
28 | 27 |
29 namespace blink { | 28 namespace blink { |
30 struct WebCircularGeofencingRegion; | 29 struct WebCircularGeofencingRegion; |
31 struct WebCrossOriginServiceWorkerClient; | 30 struct WebCrossOriginServiceWorkerClient; |
32 class WebServiceWorkerContextProxy; | 31 class WebServiceWorkerContextProxy; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 blink::WebServiceWorkerClientCallbacks* callbacks); | 78 blink::WebServiceWorkerClientCallbacks* callbacks); |
80 void PostMessageToDocument( | 79 void PostMessageToDocument( |
81 int client_id, | 80 int client_id, |
82 const base::string16& message, | 81 const base::string16& message, |
83 scoped_ptr<blink::WebMessagePortChannelArray> channels); | 82 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
84 void PostCrossOriginMessageToClient( | 83 void PostCrossOriginMessageToClient( |
85 const blink::WebCrossOriginServiceWorkerClient& client, | 84 const blink::WebCrossOriginServiceWorkerClient& client, |
86 const base::string16& message, | 85 const base::string16& message, |
87 scoped_ptr<blink::WebMessagePortChannelArray> channels); | 86 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
88 void FocusClient(int client_id, | 87 void FocusClient(int client_id, |
89 blink::WebServiceWorkerClientFocusCallback* callback); | 88 blink::WebServiceWorkerClientCallbacks* callback); |
90 void SkipWaiting(blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); | 89 void SkipWaiting(blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); |
91 void ClaimClients(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); | 90 void ClaimClients(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); |
92 | 91 |
93 // Send a message to the browser. Takes ownership of |message|. | 92 // Send a message to the browser. Takes ownership of |message|. |
94 void Send(IPC::Message* message); | 93 void Send(IPC::Message* message); |
95 | 94 |
96 // Get routing_id for sending message to the ServiceWorkerVersion | 95 // Get routing_id for sending message to the ServiceWorkerVersion |
97 // in the browser process. | 96 // in the browser process. |
98 int GetRoutingID() const; | 97 int GetRoutingID() const; |
99 | 98 |
100 blink::WebServiceWorkerCacheStorage* cache_storage() { | 99 blink::WebServiceWorkerCacheStorage* cache_storage() { |
101 return cache_storage_dispatcher_.get(); | 100 return cache_storage_dispatcher_.get(); |
102 } | 101 } |
103 | 102 |
104 private: | 103 private: |
105 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> | 104 typedef IDMap<blink::WebServiceWorkerClientsCallbacks, IDMapOwnPointer> |
106 ClientsCallbacksMap; | 105 ClientsCallbacksMap; |
107 typedef IDMap<blink::WebServiceWorkerClientsClaimCallbacks, IDMapOwnPointer> | 106 typedef IDMap<blink::WebServiceWorkerClientsClaimCallbacks, IDMapOwnPointer> |
108 ClaimClientsCallbacksMap; | 107 ClaimClientsCallbacksMap; |
109 typedef IDMap<blink::WebServiceWorkerClientCallbacks, IDMapOwnPointer> | 108 typedef IDMap<blink::WebServiceWorkerClientCallbacks, IDMapOwnPointer> |
110 ClientCallbacksMap; | 109 ClientCallbacksMap; |
111 typedef IDMap<blink::WebServiceWorkerClientFocusCallback, IDMapOwnPointer> | |
112 FocusClientCallbacksMap; | |
113 typedef IDMap<blink::WebServiceWorkerSkipWaitingCallbacks, IDMapOwnPointer> | 110 typedef IDMap<blink::WebServiceWorkerSkipWaitingCallbacks, IDMapOwnPointer> |
114 SkipWaitingCallbacksMap; | 111 SkipWaitingCallbacksMap; |
115 | 112 |
116 void OnActivateEvent(int request_id); | 113 void OnActivateEvent(int request_id); |
117 void OnInstallEvent(int request_id, int active_version_id); | 114 void OnInstallEvent(int request_id, int active_version_id); |
118 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); | 115 void OnFetchEvent(int request_id, const ServiceWorkerFetchRequest& request); |
119 void OnSyncEvent(int request_id); | 116 void OnSyncEvent(int request_id); |
120 void OnNotificationClickEvent( | 117 void OnNotificationClickEvent( |
121 int request_id, | 118 int request_id, |
122 const std::string& notification_id, | 119 const std::string& notification_id, |
(...skipping 11 matching lines...) Expand all Loading... |
134 void OnCrossOriginMessageToWorker( | 131 void OnCrossOriginMessageToWorker( |
135 const NavigatorConnectClient& client, | 132 const NavigatorConnectClient& client, |
136 const base::string16& message, | 133 const base::string16& message, |
137 const std::vector<int>& sent_message_port_ids, | 134 const std::vector<int>& sent_message_port_ids, |
138 const std::vector<int>& new_routing_ids); | 135 const std::vector<int>& new_routing_ids); |
139 void OnDidGetClientDocuments( | 136 void OnDidGetClientDocuments( |
140 int request_id, const std::vector<ServiceWorkerClientInfo>& clients); | 137 int request_id, const std::vector<ServiceWorkerClientInfo>& clients); |
141 void OnOpenWindowResponse(int request_id, | 138 void OnOpenWindowResponse(int request_id, |
142 const ServiceWorkerClientInfo& client); | 139 const ServiceWorkerClientInfo& client); |
143 void OnOpenWindowError(int request_id); | 140 void OnOpenWindowError(int request_id); |
144 void OnFocusClientResponse(int request_id, bool result); | 141 void OnFocusClientResponse(int request_id, |
| 142 const ServiceWorkerClientInfo& client); |
145 void OnDidSkipWaiting(int request_id); | 143 void OnDidSkipWaiting(int request_id); |
146 void OnDidClaimClients(int request_id); | 144 void OnDidClaimClients(int request_id); |
147 void OnClaimClientsError(int request_id, | 145 void OnClaimClientsError(int request_id, |
148 blink::WebServiceWorkerError::ErrorType error_type, | 146 blink::WebServiceWorkerError::ErrorType error_type, |
149 const base::string16& message); | 147 const base::string16& message); |
150 | 148 |
151 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; | 149 scoped_ptr<ServiceWorkerCacheStorageDispatcher> cache_storage_dispatcher_; |
152 | 150 |
153 // Not owned; embedded_context_ owns this. | 151 // Not owned; embedded_context_ owns this. |
154 EmbeddedWorkerContextClient* embedded_context_; | 152 EmbeddedWorkerContextClient* embedded_context_; |
155 | 153 |
156 // Not owned; this object is destroyed when proxy_ becomes invalid. | 154 // Not owned; this object is destroyed when proxy_ becomes invalid. |
157 blink::WebServiceWorkerContextProxy* proxy_; | 155 blink::WebServiceWorkerContextProxy* proxy_; |
158 | 156 |
159 // Used for incoming messages from the browser for which an outgoing response | 157 // Used for incoming messages from the browser for which an outgoing response |
160 // back to the browser is expected, the id must be sent back with the | 158 // back to the browser is expected, the id must be sent back with the |
161 // response. | 159 // response. |
162 int current_request_id_; | 160 int current_request_id_; |
163 | 161 |
164 // Pending callbacks for GetClientDocuments(). | 162 // Pending callbacks for GetClientDocuments(). |
165 ClientsCallbacksMap pending_clients_callbacks_; | 163 ClientsCallbacksMap pending_clients_callbacks_; |
166 | 164 |
167 // Pending callbacks for OpenWindow(). | 165 // Pending callbacks for OpenWindow() and FocusClient(). |
168 ClientCallbacksMap pending_client_callbacks_; | 166 ClientCallbacksMap pending_client_callbacks_; |
169 | 167 |
170 // Pending callbacks for FocusClient(). | |
171 FocusClientCallbacksMap pending_focus_client_callbacks_; | |
172 | |
173 // Pending callbacks for SkipWaiting(). | 168 // Pending callbacks for SkipWaiting(). |
174 SkipWaitingCallbacksMap pending_skip_waiting_callbacks_; | 169 SkipWaitingCallbacksMap pending_skip_waiting_callbacks_; |
175 | 170 |
176 // Pending callbacks for ClaimClients(). | 171 // Pending callbacks for ClaimClients(). |
177 ClaimClientsCallbacksMap pending_claim_clients_callbacks_; | 172 ClaimClientsCallbacksMap pending_claim_clients_callbacks_; |
178 | 173 |
179 // Capture timestamps for UMA | 174 // Capture timestamps for UMA |
180 std::map<int, base::TimeTicks> activate_start_timings_; | 175 std::map<int, base::TimeTicks> activate_start_timings_; |
181 std::map<int, base::TimeTicks> fetch_start_timings_; | 176 std::map<int, base::TimeTicks> fetch_start_timings_; |
182 std::map<int, base::TimeTicks> install_start_timings_; | 177 std::map<int, base::TimeTicks> install_start_timings_; |
183 std::map<int, base::TimeTicks> notification_click_start_timings_; | 178 std::map<int, base::TimeTicks> notification_click_start_timings_; |
184 std::map<int, base::TimeTicks> push_start_timings_; | 179 std::map<int, base::TimeTicks> push_start_timings_; |
185 | 180 |
186 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); | 181 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext); |
187 }; | 182 }; |
188 | 183 |
189 } // namespace content | 184 } // namespace content |
190 | 185 |
191 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ | 186 #endif // CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_ |
OLD | NEW |