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