OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
7 | 7 |
| 8 #include <string> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
11 #include "base/callback.h" | 12 #include "base/callback.h" |
12 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
13 #include "base/id_map.h" | 14 #include "base/id_map.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
17 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 void DispatchFetchEvent(const ServiceWorkerFetchRequest& request, | 169 void DispatchFetchEvent(const ServiceWorkerFetchRequest& request, |
169 const FetchCallback& callback); | 170 const FetchCallback& callback); |
170 | 171 |
171 // Sends sync event to the associated embedded worker and asynchronously calls | 172 // Sends sync event to the associated embedded worker and asynchronously calls |
172 // |callback| when it errors out or it gets response from the worker to notify | 173 // |callback| when it errors out or it gets response from the worker to notify |
173 // completion. | 174 // completion. |
174 // | 175 // |
175 // This must be called when the status() is ACTIVE. | 176 // This must be called when the status() is ACTIVE. |
176 void DispatchSyncEvent(const StatusCallback& callback); | 177 void DispatchSyncEvent(const StatusCallback& callback); |
177 | 178 |
| 179 // Sends push event to the associated embedded worker and asynchronously calls |
| 180 // |callback| when it errors out or it gets response from the worker to notify |
| 181 // completion. |
| 182 // |
| 183 // This must be called when the status() is ACTIVE. |
| 184 void DispatchPushEvent(const StatusCallback& callback, |
| 185 const std::string& data); |
| 186 |
178 // These are expected to be called when a renderer process host for the | 187 // These are expected to be called when a renderer process host for the |
179 // same-origin as for this ServiceWorkerVersion is created. The added | 188 // same-origin as for this ServiceWorkerVersion is created. The added |
180 // processes are used to run an in-renderer embedded worker. | 189 // processes are used to run an in-renderer embedded worker. |
181 void AddProcessToWorker(int process_id); | 190 void AddProcessToWorker(int process_id); |
182 void RemoveProcessFromWorker(int process_id); | 191 void RemoveProcessFromWorker(int process_id); |
183 | 192 |
184 // Returns true if this has at least one process to run. | 193 // Returns true if this has at least one process to run. |
185 bool HasProcessToRun() const; | 194 bool HasProcessToRun() const; |
186 | 195 |
187 // Adds and removes |provider_host| as a controllee of this ServiceWorker. | 196 // Adds and removes |provider_host| as a controllee of this ServiceWorker. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // Message handlers. | 240 // Message handlers. |
232 void OnGetClientDocuments(int request_id); | 241 void OnGetClientDocuments(int request_id); |
233 void OnActivateEventFinished(int request_id, | 242 void OnActivateEventFinished(int request_id, |
234 blink::WebServiceWorkerEventResult result); | 243 blink::WebServiceWorkerEventResult result); |
235 void OnInstallEventFinished(int request_id, | 244 void OnInstallEventFinished(int request_id, |
236 blink::WebServiceWorkerEventResult result); | 245 blink::WebServiceWorkerEventResult result); |
237 void OnFetchEventFinished(int request_id, | 246 void OnFetchEventFinished(int request_id, |
238 ServiceWorkerFetchEventResult result, | 247 ServiceWorkerFetchEventResult result, |
239 const ServiceWorkerResponse& response); | 248 const ServiceWorkerResponse& response); |
240 void OnSyncEventFinished(int request_id); | 249 void OnSyncEventFinished(int request_id); |
| 250 void OnPushEventFinished(int request_id); |
241 void OnPostMessageToDocument(int client_id, | 251 void OnPostMessageToDocument(int client_id, |
242 const base::string16& message, | 252 const base::string16& message, |
243 const std::vector<int>& sent_message_port_ids); | 253 const std::vector<int>& sent_message_port_ids); |
244 | 254 |
245 void ScheduleStopWorker(); | 255 void ScheduleStopWorker(); |
246 | 256 |
247 const int64 version_id_; | 257 const int64 version_id_; |
248 int64 registration_id_; | 258 int64 registration_id_; |
249 GURL script_url_; | 259 GURL script_url_; |
250 GURL scope_; | 260 GURL scope_; |
251 Status status_; | 261 Status status_; |
252 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; | 262 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; |
253 std::vector<StatusCallback> start_callbacks_; | 263 std::vector<StatusCallback> start_callbacks_; |
254 std::vector<StatusCallback> stop_callbacks_; | 264 std::vector<StatusCallback> stop_callbacks_; |
255 std::vector<base::Closure> status_change_callbacks_; | 265 std::vector<base::Closure> status_change_callbacks_; |
256 | 266 |
257 // Message callbacks. | 267 // Message callbacks. |
258 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; | 268 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; |
259 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; | 269 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; |
260 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; | 270 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; |
261 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; | 271 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; |
| 272 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; |
262 | 273 |
263 ControlleeMap controllee_map_; | 274 ControlleeMap controllee_map_; |
264 ControlleeByIDMap controllee_by_id_; | 275 ControlleeByIDMap controllee_by_id_; |
265 base::WeakPtr<ServiceWorkerContextCore> context_; | 276 base::WeakPtr<ServiceWorkerContextCore> context_; |
266 ObserverList<Listener> listeners_; | 277 ObserverList<Listener> listeners_; |
267 ServiceWorkerScriptCacheMap script_cache_map_; | 278 ServiceWorkerScriptCacheMap script_cache_map_; |
268 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; | 279 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; |
269 | 280 |
270 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 281 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
271 | 282 |
272 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 283 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
273 }; | 284 }; |
274 | 285 |
275 } // namespace content | 286 } // namespace content |
276 | 287 |
277 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 288 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |