Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Side by Side Diff: content/browser/service_worker/service_worker_version.h

Issue 2779763004: Create ServiceWorkerProviderHost before starting worker (Closed)
Patch Set: More renaming and updated comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // Adds and removes |provider_host| as a controllee of this ServiceWorker. 297 // Adds and removes |provider_host| as a controllee of this ServiceWorker.
298 void AddControllee(ServiceWorkerProviderHost* provider_host); 298 void AddControllee(ServiceWorkerProviderHost* provider_host);
299 void RemoveControllee(ServiceWorkerProviderHost* provider_host); 299 void RemoveControllee(ServiceWorkerProviderHost* provider_host);
300 300
301 // Returns if it has controllee. 301 // Returns if it has controllee.
302 bool HasControllee() const { return !controllee_map_.empty(); } 302 bool HasControllee() const { return !controllee_map_.empty(); }
303 std::map<std::string, ServiceWorkerProviderHost*> controllee_map() { 303 std::map<std::string, ServiceWorkerProviderHost*> controllee_map() {
304 return controllee_map_; 304 return controllee_map_;
305 } 305 }
306 306
307 // The provider host hosting this version. Only valid while the version is
308 // running.
309 ServiceWorkerProviderHost* provider_host() {
310 DCHECK(provider_host_);
311 return provider_host_.get();
312 }
313
307 base::WeakPtr<ServiceWorkerContextCore> context() const { return context_; } 314 base::WeakPtr<ServiceWorkerContextCore> context() const { return context_; }
308 315
309 // Adds and removes |request_job| as a dependent job not to stop the 316 // Adds and removes |request_job| as a dependent job not to stop the
310 // ServiceWorker while |request_job| is reading the stream of the fetch event 317 // ServiceWorker while |request_job| is reading the stream of the fetch event
311 // response from the ServiceWorker. 318 // response from the ServiceWorker.
312 void AddStreamingURLRequestJob(const ServiceWorkerURLRequestJob* request_job); 319 void AddStreamingURLRequestJob(const ServiceWorkerURLRequestJob* request_job);
313 void RemoveStreamingURLRequestJob( 320 void RemoveStreamingURLRequestJob(
314 const ServiceWorkerURLRequestJob* request_job); 321 const ServiceWorkerURLRequestJob* request_job);
315 322
316 // Adds and removes Listeners. 323 // Adds and removes Listeners.
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 // Container for pending external requests for this service worker. 733 // Container for pending external requests for this service worker.
727 // (key, value): (request uuid, request id). 734 // (key, value): (request uuid, request id).
728 using RequestUUIDToRequestIDMap = std::map<std::string, int>; 735 using RequestUUIDToRequestIDMap = std::map<std::string, int>;
729 RequestUUIDToRequestIDMap external_request_uuid_to_request_id_; 736 RequestUUIDToRequestIDMap external_request_uuid_to_request_id_;
730 737
731 // Connected to ServiceWorkerContextClient while the worker is running. 738 // Connected to ServiceWorkerContextClient while the worker is running.
732 mojom::ServiceWorkerEventDispatcherPtr event_dispatcher_; 739 mojom::ServiceWorkerEventDispatcherPtr event_dispatcher_;
733 740
734 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; 741 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_;
735 742
743 // Keeps track of the provider hosting this running service worker for this
744 // version. |provider_host_| is always valid as long as this version has
745 // the running context.
falken 2017/06/20 04:59:35 s/has the running context/is running
shimazu 2017/06/21 03:11:27 Done.
746 base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
747
736 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; 748 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_;
737 // Will be null while shutting down. 749 // Will be null while shutting down.
738 base::WeakPtr<ServiceWorkerContextCore> context_; 750 base::WeakPtr<ServiceWorkerContextCore> context_;
739 base::ObserverList<Listener> listeners_; 751 base::ObserverList<Listener> listeners_;
740 ServiceWorkerScriptCacheMap script_cache_map_; 752 ServiceWorkerScriptCacheMap script_cache_map_;
741 base::OneShotTimer update_timer_; 753 base::OneShotTimer update_timer_;
742 754
743 // Starts running in StartWorker and continues until the worker is stopped. 755 // Starts running in StartWorker and continues until the worker is stopped.
744 base::RepeatingTimer timeout_timer_; 756 base::RepeatingTimer timeout_timer_;
745 // Holds the time the worker last started being considered idle. 757 // Holds the time the worker last started being considered idle.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 850
839 // At this point |this| can have been deleted, so don't do anything other 851 // At this point |this| can have been deleted, so don't do anything other
840 // than returning. 852 // than returning.
841 853
842 return true; 854 return true;
843 } 855 }
844 856
845 } // namespace content 857 } // namespace content
846 858
847 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 859 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698