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_port_service.mojom.h" | 26 #include "content/common/service_port_service.mojom.h" |
26 #include "content/common/service_worker/service_worker_status_code.h" | 27 #include "content/common/service_worker/service_worker_status_code.h" |
27 #include "content/common/service_worker/service_worker_types.h" | 28 #include "content/common/service_worker/service_worker_types.h" |
28 #include "content/public/common/service_registry.h" | 29 #include "content/public/common/service_registry.h" |
29 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h" | 30 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h" |
30 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" | 31 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" |
31 | 32 |
32 // Windows headers will redefine SendMessage. | 33 // Windows headers will redefine SendMessage. |
33 #ifdef SendMessage | 34 #ifdef SendMessage |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 void OnGetClients(int request_id, | 432 void OnGetClients(int request_id, |
432 const ServiceWorkerClientQueryOptions& options); | 433 const ServiceWorkerClientQueryOptions& options); |
433 | 434 |
434 void OnActivateEventFinished(int request_id, | 435 void OnActivateEventFinished(int request_id, |
435 blink::WebServiceWorkerEventResult result); | 436 blink::WebServiceWorkerEventResult result); |
436 void OnInstallEventFinished(int request_id, | 437 void OnInstallEventFinished(int request_id, |
437 blink::WebServiceWorkerEventResult result); | 438 blink::WebServiceWorkerEventResult result); |
438 void OnFetchEventFinished(int request_id, | 439 void OnFetchEventFinished(int request_id, |
439 ServiceWorkerFetchEventResult result, | 440 ServiceWorkerFetchEventResult result, |
440 const ServiceWorkerResponse& response); | 441 const ServiceWorkerResponse& response); |
441 void OnSyncEventFinished(int request_id, | 442 void OnSyncEventFinished(int request_id, ServiceWorkerEventStatus status); |
442 blink::WebServiceWorkerEventResult result); | |
443 void OnNotificationClickEventFinished(int request_id); | 443 void OnNotificationClickEventFinished(int request_id); |
444 void OnPushEventFinished(int request_id, | 444 void OnPushEventFinished(int request_id, |
445 blink::WebServiceWorkerEventResult result); | 445 blink::WebServiceWorkerEventResult result); |
446 void OnGeofencingEventFinished(int request_id); | 446 void OnGeofencingEventFinished(int request_id); |
447 void OnServicePortConnectEventFinished(int request_id, | 447 void OnServicePortConnectEventFinished(int request_id, |
448 ServicePortConnectResult result, | 448 ServicePortConnectResult result, |
449 const mojo::String& name, | 449 const mojo::String& name, |
450 const mojo::String& data); | 450 const mojo::String& data); |
451 void OnOpenWindow(int request_id, GURL url); | 451 void OnOpenWindow(int request_id, GURL url); |
452 void DidOpenWindow(int request_id, | 452 void DidOpenWindow(int request_id, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 // Sets |stale_time_| if this worker is stale, causing an update to eventually | 534 // Sets |stale_time_| if this worker is stale, causing an update to eventually |
535 // occur once the worker stops or is running too long. | 535 // occur once the worker stops or is running too long. |
536 void MarkIfStale(); | 536 void MarkIfStale(); |
537 | 537 |
538 void FoundRegistrationForUpdate( | 538 void FoundRegistrationForUpdate( |
539 ServiceWorkerStatusCode status, | 539 ServiceWorkerStatusCode status, |
540 const scoped_refptr<ServiceWorkerRegistration>& registration); | 540 const scoped_refptr<ServiceWorkerRegistration>& registration); |
541 | 541 |
542 void OnStoppedInternal(EmbeddedWorkerInstance::Status old_status); | 542 void OnStoppedInternal(EmbeddedWorkerInstance::Status old_status); |
543 | 543 |
544 // Called when the connection to a ServicePortDispatcher drops or fails. | 544 // Called when a connection to a mojo event Dispatcher drops or fails. |
545 // Calls callbacks for any outstanding requests to the dispatcher as well | 545 // Calls callbacks for any outstanding requests to the dispatcher as well |
546 // as cleans up the dispatcher. | 546 // as cleans up the dispatcher. |
547 void OnServicePortDispatcherConnectionError(); | 547 void OnServicePortDispatcherConnectionError(); |
| 548 void OnBackgroundSyncDispatcherConnectionError(); |
548 | 549 |
549 const int64 version_id_; | 550 const int64 version_id_; |
550 const int64 registration_id_; | 551 const int64 registration_id_; |
551 const GURL script_url_; | 552 const GURL script_url_; |
552 const GURL scope_; | 553 const GURL scope_; |
553 | 554 |
554 Status status_ = NEW; | 555 Status status_ = NEW; |
555 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; | 556 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; |
556 std::vector<StatusCallback> start_callbacks_; | 557 std::vector<StatusCallback> start_callbacks_; |
557 std::vector<StatusCallback> stop_callbacks_; | 558 std::vector<StatusCallback> stop_callbacks_; |
558 std::vector<base::Closure> status_change_callbacks_; | 559 std::vector<base::Closure> status_change_callbacks_; |
559 | 560 |
560 // Message callbacks. (Update HasInflightRequests() too when you update this | 561 // Message callbacks. (Update HasInflightRequests() too when you update this |
561 // list.) | 562 // list.) |
562 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> activate_requests_; | 563 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> activate_requests_; |
563 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> install_requests_; | 564 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> install_requests_; |
564 IDMap<PendingRequest<FetchCallback>, IDMapOwnPointer> fetch_requests_; | 565 IDMap<PendingRequest<FetchCallback>, IDMapOwnPointer> fetch_requests_; |
565 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> sync_requests_; | 566 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> sync_requests_; |
566 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> | 567 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> |
567 notification_click_requests_; | 568 notification_click_requests_; |
568 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> push_requests_; | 569 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> push_requests_; |
569 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> geofencing_requests_; | 570 IDMap<PendingRequest<StatusCallback>, IDMapOwnPointer> geofencing_requests_; |
570 IDMap<PendingRequest<ServicePortConnectCallback>, IDMapOwnPointer> | 571 IDMap<PendingRequest<ServicePortConnectCallback>, IDMapOwnPointer> |
571 service_port_connect_requests_; | 572 service_port_connect_requests_; |
572 | 573 |
573 ServicePortDispatcherPtr service_port_dispatcher_; | 574 ServicePortDispatcherPtr service_port_dispatcher_; |
| 575 BackgroundSyncServiceClientPtr background_sync_dispatcher_; |
574 | 576 |
575 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; | 577 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; |
576 | 578 |
577 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; | 579 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; |
578 // Will be null while shutting down. | 580 // Will be null while shutting down. |
579 base::WeakPtr<ServiceWorkerContextCore> context_; | 581 base::WeakPtr<ServiceWorkerContextCore> context_; |
580 base::ObserverList<Listener> listeners_; | 582 base::ObserverList<Listener> listeners_; |
581 ServiceWorkerScriptCacheMap script_cache_map_; | 583 ServiceWorkerScriptCacheMap script_cache_map_; |
582 base::OneShotTimer<ServiceWorkerVersion> update_timer_; | 584 base::OneShotTimer<ServiceWorkerVersion> update_timer_; |
583 | 585 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 scoped_ptr<Metrics> metrics_; | 620 scoped_ptr<Metrics> metrics_; |
619 | 621 |
620 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 622 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
621 | 623 |
622 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 624 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
623 }; | 625 }; |
624 | 626 |
625 } // namespace content | 627 } // namespace content |
626 | 628 |
627 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 629 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |