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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 int client_id, | 75 int client_id, |
74 const base::string16& message, | 76 const base::string16& message, |
75 scoped_ptr<blink::WebMessagePortChannelArray> channels); | 77 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
76 void PostCrossOriginMessageToClient( | 78 void PostCrossOriginMessageToClient( |
77 const blink::WebCrossOriginServiceWorkerClient& client, | 79 const blink::WebCrossOriginServiceWorkerClient& client, |
78 const base::string16& message, | 80 const base::string16& message, |
79 scoped_ptr<blink::WebMessagePortChannelArray> channels); | 81 scoped_ptr<blink::WebMessagePortChannelArray> channels); |
80 void FocusClient(int client_id, | 82 void FocusClient(int client_id, |
81 blink::WebServiceWorkerClientFocusCallback* callback); | 83 blink::WebServiceWorkerClientFocusCallback* callback); |
82 void SkipWaiting(blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); | 84 void SkipWaiting(blink::WebServiceWorkerSkipWaitingCallbacks* callbacks); |
| 85 void ClaimClients(blink::WebServiceWorkerClientsClaimCallbacks* 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::WebServiceWorkerClientsClaimCallbacks, IDMapOwnPointer> |
| 102 ClaimClientsCallbacksMap; |
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 12 matching lines...) Expand all Loading... |
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); |
128 void OnFocusClientResponse(int request_id, bool result); | 133 void OnFocusClientResponse(int request_id, bool result); |
129 void OnDidSkipWaiting(int request_id); | 134 void OnDidSkipWaiting(int request_id); |
| 135 void OnDidClaimClients(int request_id); |
| 136 void OnClaimClientsError(int request_id, |
| 137 blink::WebServiceWorkerError::ErrorType error_type, |
| 138 const base::string16& message); |
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 |
147 // Pending callbacks for FocusClient(). | 156 // Pending callbacks for FocusClient(). |
148 FocusClientCallbacksMap pending_focus_client_callbacks_; | 157 FocusClientCallbacksMap pending_focus_client_callbacks_; |
149 | 158 |
150 // Pending callbacks for SkipWaiting(). | 159 // Pending callbacks for SkipWaiting(). |
151 SkipWaitingCallbacksMap pending_skip_waiting_callbacks_; | 160 SkipWaitingCallbacksMap pending_skip_waiting_callbacks_; |
152 | 161 |
| 162 // Pending callbacks for ClaimClients(). |
| 163 ClaimClientsCallbacksMap pending_claim_clients_callbacks_; |
| 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 |