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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <functional> | 10 #include <functional> |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // Adds and removes |provider_host| as a controllee of this ServiceWorker. | 291 // Adds and removes |provider_host| as a controllee of this ServiceWorker. |
292 void AddControllee(ServiceWorkerProviderHost* provider_host); | 292 void AddControllee(ServiceWorkerProviderHost* provider_host); |
293 void RemoveControllee(ServiceWorkerProviderHost* provider_host); | 293 void RemoveControllee(ServiceWorkerProviderHost* provider_host); |
294 | 294 |
295 // Returns if it has controllee. | 295 // Returns if it has controllee. |
296 bool HasControllee() const { return !controllee_map_.empty(); } | 296 bool HasControllee() const { return !controllee_map_.empty(); } |
297 std::map<std::string, ServiceWorkerProviderHost*> controllee_map() { | 297 std::map<std::string, ServiceWorkerProviderHost*> controllee_map() { |
298 return controllee_map_; | 298 return controllee_map_; |
299 } | 299 } |
300 | 300 |
301 // The provider host hosting this version. Only valid while the version is | |
302 // running. | |
303 ServiceWorkerProviderHost* provider_host() { | |
304 DCHECK(provider_host_); | |
305 return provider_host_.get(); | |
306 } | |
307 | |
308 base::WeakPtr<ServiceWorkerContextCore> context() const { return context_; } | 301 base::WeakPtr<ServiceWorkerContextCore> context() const { return context_; } |
309 | 302 |
310 // Adds and removes |request_job| as a dependent job not to stop the | 303 // Adds and removes |request_job| as a dependent job not to stop the |
311 // ServiceWorker while |request_job| is reading the stream of the fetch event | 304 // ServiceWorker while |request_job| is reading the stream of the fetch event |
312 // response from the ServiceWorker. | 305 // response from the ServiceWorker. |
313 void AddStreamingURLRequestJob(const ServiceWorkerURLRequestJob* request_job); | 306 void AddStreamingURLRequestJob(const ServiceWorkerURLRequestJob* request_job); |
314 void RemoveStreamingURLRequestJob( | 307 void RemoveStreamingURLRequestJob( |
315 const ServiceWorkerURLRequestJob* request_job); | 308 const ServiceWorkerURLRequestJob* request_job); |
316 | 309 |
317 // Adds and removes Listeners. | 310 // Adds and removes Listeners. |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 // Container for pending external requests for this service worker. | 704 // Container for pending external requests for this service worker. |
712 // (key, value): (request uuid, request id). | 705 // (key, value): (request uuid, request id). |
713 using RequestUUIDToRequestIDMap = std::map<std::string, int>; | 706 using RequestUUIDToRequestIDMap = std::map<std::string, int>; |
714 RequestUUIDToRequestIDMap external_request_uuid_to_request_id_; | 707 RequestUUIDToRequestIDMap external_request_uuid_to_request_id_; |
715 | 708 |
716 // Connected to ServiceWorkerContextClient while the worker is running. | 709 // Connected to ServiceWorkerContextClient while the worker is running. |
717 mojom::ServiceWorkerEventDispatcherPtr event_dispatcher_; | 710 mojom::ServiceWorkerEventDispatcherPtr event_dispatcher_; |
718 | 711 |
719 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; | 712 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; |
720 | 713 |
721 // Keeps track of the provider hosting this running service worker for this | |
722 // version. |provider_host_| is always valid as long as this version is | |
723 // running. | |
724 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; | |
725 | |
726 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; | 714 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; |
727 // Will be null while shutting down. | 715 // Will be null while shutting down. |
728 base::WeakPtr<ServiceWorkerContextCore> context_; | 716 base::WeakPtr<ServiceWorkerContextCore> context_; |
729 base::ObserverList<Listener> listeners_; | 717 base::ObserverList<Listener> listeners_; |
730 ServiceWorkerScriptCacheMap script_cache_map_; | 718 ServiceWorkerScriptCacheMap script_cache_map_; |
731 base::OneShotTimer update_timer_; | 719 base::OneShotTimer update_timer_; |
732 | 720 |
733 // Starts running in StartWorker and continues until the worker is stopped. | 721 // Starts running in StartWorker and continues until the worker is stopped. |
734 base::RepeatingTimer timeout_timer_; | 722 base::RepeatingTimer timeout_timer_; |
735 // Holds the time the worker last started being considered idle. | 723 // Holds the time the worker last started being considered idle. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 | 816 |
829 // At this point |this| can have been deleted, so don't do anything other | 817 // At this point |this| can have been deleted, so don't do anything other |
830 // than returning. | 818 // than returning. |
831 | 819 |
832 return true; | 820 return true; |
833 } | 821 } |
834 | 822 |
835 } // namespace content | 823 } // namespace content |
836 | 824 |
837 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 825 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |