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 <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
17 #include "base/id_map.h" | 17 #include "base/id_map.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
20 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
21 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
22 #include "content/browser/service_worker/embedded_worker_instance.h" | 22 #include "content/browser/service_worker/embedded_worker_instance.h" |
23 #include "content/browser/service_worker/service_worker_script_cache_map.h" | 23 #include "content/browser/service_worker/service_worker_script_cache_map.h" |
24 #include "content/common/background_sync_service.mojom.h" | |
24 #include "content/common/content_export.h" | 25 #include "content/common/content_export.h" |
25 #include "content/common/service_worker/service_worker_status_code.h" | 26 #include "content/common/service_worker/service_worker_status_code.h" |
26 #include "content/common/service_worker/service_worker_types.h" | 27 #include "content/common/service_worker/service_worker_types.h" |
27 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h" | 28 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h" |
28 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" | 29 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" |
29 | 30 |
30 // Windows headers will redefine SendMessage. | 31 // Windows headers will redefine SendMessage. |
31 #ifdef SendMessage | 32 #ifdef SendMessage |
32 #undef SendMessage | 33 #undef SendMessage |
33 #endif | 34 #endif |
34 | 35 |
35 class GURL; | 36 class GURL; |
36 | 37 |
37 namespace blink { | 38 namespace blink { |
38 struct WebCircularGeofencingRegion; | 39 struct WebCircularGeofencingRegion; |
39 } | 40 } |
40 | 41 |
41 namespace net { | 42 namespace net { |
42 class HttpResponseInfo; | 43 class HttpResponseInfo; |
43 } | 44 } |
44 | 45 |
45 namespace content { | 46 namespace content { |
46 | 47 |
47 class EmbeddedWorkerRegistry; | 48 class EmbeddedWorkerRegistry; |
48 class ServiceWorkerContextCore; | 49 class ServiceWorkerContextCore; |
50 class ServiceWorkerEventDispatcher; | |
49 class ServiceWorkerProviderHost; | 51 class ServiceWorkerProviderHost; |
50 class ServiceWorkerRegistration; | 52 class ServiceWorkerRegistration; |
51 class ServiceWorkerURLRequestJob; | 53 class ServiceWorkerURLRequestJob; |
52 struct NavigatorConnectClient; | 54 struct NavigatorConnectClient; |
53 struct PlatformNotificationData; | 55 struct PlatformNotificationData; |
54 struct ServiceWorkerClientInfo; | 56 struct ServiceWorkerClientInfo; |
55 struct ServiceWorkerVersionInfo; | 57 struct ServiceWorkerVersionInfo; |
56 struct TransferredMessagePort; | 58 struct TransferredMessagePort; |
57 | 59 |
58 // This class corresponds to a specific version of a ServiceWorker | 60 // This class corresponds to a specific version of a ServiceWorker |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 const base::Closure& prepare_callback, | 205 const base::Closure& prepare_callback, |
204 const FetchCallback& fetch_callback); | 206 const FetchCallback& fetch_callback); |
205 | 207 |
206 // Sends sync event to the associated embedded worker and asynchronously calls | 208 // Sends sync event to the associated embedded worker and asynchronously calls |
207 // |callback| when it errors out or it gets a response from the worker to | 209 // |callback| when it errors out or it gets a response from the worker to |
208 // notify completion. | 210 // notify completion. |
209 // | 211 // |
210 // This must be called when the status() is ACTIVATED. | 212 // This must be called when the status() is ACTIVATED. |
211 void DispatchSyncEvent(const StatusCallback& callback); | 213 void DispatchSyncEvent(const StatusCallback& callback); |
212 | 214 |
215 // Handle callbacks from background sync events | |
216 void OnSyncEventFinished(const StatusCallback& callback, | |
jkarlin
2015/06/12 21:08:14
Did this need to be made public?
iclelland
2015/06/16 15:59:16
No, it did not; (well, once upon a time, during re
| |
217 ServiceWorkerStatusCode status); | |
218 | |
213 // Sends notificationclick event to the associated embedded worker and | 219 // Sends notificationclick event to the associated embedded worker and |
214 // asynchronously calls |callback| when it errors out or it gets a response | 220 // asynchronously calls |callback| when it errors out or it gets a response |
215 // from the worker to notify completion. | 221 // from the worker to notify completion. |
216 // | 222 // |
217 // This must be called when the status() is ACTIVATED. | 223 // This must be called when the status() is ACTIVATED. |
218 void DispatchNotificationClickEvent( | 224 void DispatchNotificationClickEvent( |
219 const StatusCallback& callback, | 225 const StatusCallback& callback, |
220 int64_t persistent_notification_id, | 226 int64_t persistent_notification_id, |
221 const PlatformNotificationData& notification_data); | 227 const PlatformNotificationData& notification_data); |
222 | 228 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 class Metrics; | 353 class Metrics; |
348 class PingController; | 354 class PingController; |
349 | 355 |
350 typedef ServiceWorkerVersion self; | 356 typedef ServiceWorkerVersion self; |
351 using ServiceWorkerClients = std::vector<ServiceWorkerClientInfo>; | 357 using ServiceWorkerClients = std::vector<ServiceWorkerClientInfo>; |
352 | 358 |
353 enum RequestType { | 359 enum RequestType { |
354 REQUEST_ACTIVATE, | 360 REQUEST_ACTIVATE, |
355 REQUEST_INSTALL, | 361 REQUEST_INSTALL, |
356 REQUEST_FETCH, | 362 REQUEST_FETCH, |
357 REQUEST_SYNC, | |
358 REQUEST_NOTIFICATION_CLICK, | 363 REQUEST_NOTIFICATION_CLICK, |
359 REQUEST_PUSH, | 364 REQUEST_PUSH, |
360 REQUEST_GEOFENCING, | 365 REQUEST_GEOFENCING, |
361 REQUEST_CROSS_ORIGIN_CONNECT | 366 REQUEST_CROSS_ORIGIN_CONNECT |
362 }; | 367 }; |
363 | 368 |
364 struct RequestInfo { | 369 struct RequestInfo { |
365 RequestInfo(int id, RequestType type); | 370 RequestInfo(int id, RequestType type); |
366 ~RequestInfo(); | 371 ~RequestInfo(); |
367 int id; | 372 int id; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 void OnGetClients(int request_id, | 414 void OnGetClients(int request_id, |
410 const ServiceWorkerClientQueryOptions& options); | 415 const ServiceWorkerClientQueryOptions& options); |
411 | 416 |
412 void OnActivateEventFinished(int request_id, | 417 void OnActivateEventFinished(int request_id, |
413 blink::WebServiceWorkerEventResult result); | 418 blink::WebServiceWorkerEventResult result); |
414 void OnInstallEventFinished(int request_id, | 419 void OnInstallEventFinished(int request_id, |
415 blink::WebServiceWorkerEventResult result); | 420 blink::WebServiceWorkerEventResult result); |
416 void OnFetchEventFinished(int request_id, | 421 void OnFetchEventFinished(int request_id, |
417 ServiceWorkerFetchEventResult result, | 422 ServiceWorkerFetchEventResult result, |
418 const ServiceWorkerResponse& response); | 423 const ServiceWorkerResponse& response); |
419 void OnSyncEventFinished(int request_id, | |
420 blink::WebServiceWorkerEventResult result); | |
421 void OnNotificationClickEventFinished(int request_id); | 424 void OnNotificationClickEventFinished(int request_id); |
422 void OnPushEventFinished(int request_id, | 425 void OnPushEventFinished(int request_id, |
423 blink::WebServiceWorkerEventResult result); | 426 blink::WebServiceWorkerEventResult result); |
424 void OnGeofencingEventFinished(int request_id); | 427 void OnGeofencingEventFinished(int request_id); |
425 void OnCrossOriginConnectEventFinished(int request_id, | 428 void OnCrossOriginConnectEventFinished(int request_id, |
426 bool accept_connection); | 429 bool accept_connection); |
427 void OnOpenWindow(int request_id, GURL url); | 430 void OnOpenWindow(int request_id, GURL url); |
428 void DidOpenWindow(int request_id, | 431 void DidOpenWindow(int request_id, |
429 int render_process_id, | 432 int render_process_id, |
430 int render_frame_id); | 433 int render_frame_id); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; | 519 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; |
517 std::vector<StatusCallback> start_callbacks_; | 520 std::vector<StatusCallback> start_callbacks_; |
518 std::vector<StatusCallback> stop_callbacks_; | 521 std::vector<StatusCallback> stop_callbacks_; |
519 std::vector<base::Closure> status_change_callbacks_; | 522 std::vector<base::Closure> status_change_callbacks_; |
520 | 523 |
521 // Message callbacks. (Update HasInflightRequests() too when you update this | 524 // Message callbacks. (Update HasInflightRequests() too when you update this |
522 // list.) | 525 // list.) |
523 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; | 526 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; |
524 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; | 527 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; |
525 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; | 528 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; |
526 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; | |
527 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_; | 529 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_; |
528 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; | 530 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; |
529 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_; | 531 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_; |
530 IDMap<CrossOriginConnectCallback, IDMapOwnPointer> | 532 IDMap<CrossOriginConnectCallback, IDMapOwnPointer> |
531 cross_origin_connect_callbacks_; | 533 cross_origin_connect_callbacks_; |
532 | 534 |
533 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; | 535 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; |
534 | 536 |
535 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; | 537 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; |
536 // Will be null while shutting down. | 538 // Will be null while shutting down. |
(...skipping 24 matching lines...) Expand all Loading... | |
561 | 563 |
562 // The status when StartWorker was invoked. Used for UMA. | 564 // The status when StartWorker was invoked. Used for UMA. |
563 Status prestart_status_ = NEW; | 565 Status prestart_status_ = NEW; |
564 // If not OK, the reason that StartWorker failed. Used for | 566 // If not OK, the reason that StartWorker failed. Used for |
565 // running |start_callbacks_|. | 567 // running |start_callbacks_|. |
566 ServiceWorkerStatusCode start_worker_status_ = SERVICE_WORKER_OK; | 568 ServiceWorkerStatusCode start_worker_status_ = SERVICE_WORKER_OK; |
567 | 569 |
568 scoped_ptr<PingController> ping_controller_; | 570 scoped_ptr<PingController> ping_controller_; |
569 scoped_ptr<Metrics> metrics_; | 571 scoped_ptr<Metrics> metrics_; |
570 | 572 |
573 scoped_refptr<ServiceWorkerEventDispatcher> event_dispatcher_; | |
jkarlin
2015/06/12 21:08:14
suggest mojo_event_dispatcher_
iclelland
2015/06/16 15:59:16
Done.
| |
574 | |
571 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 575 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
572 | 576 |
573 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 577 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
574 }; | 578 }; |
575 | 579 |
576 } // namespace content | 580 } // namespace content |
577 | 581 |
578 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 582 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |