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

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

Issue 2779763004: Create ServiceWorkerProviderHost before starting worker (Closed)
Patch Set: Addressed 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() { return provider_host_.get(); }
310
307 base::WeakPtr<ServiceWorkerContextCore> context() const { return context_; } 311 base::WeakPtr<ServiceWorkerContextCore> context() const { return context_; }
308 312
309 // Adds and removes |request_job| as a dependent job not to stop the 313 // 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 314 // ServiceWorker while |request_job| is reading the stream of the fetch event
311 // response from the ServiceWorker. 315 // response from the ServiceWorker.
312 void AddStreamingURLRequestJob(const ServiceWorkerURLRequestJob* request_job); 316 void AddStreamingURLRequestJob(const ServiceWorkerURLRequestJob* request_job);
313 void RemoveStreamingURLRequestJob( 317 void RemoveStreamingURLRequestJob(
314 const ServiceWorkerURLRequestJob* request_job); 318 const ServiceWorkerURLRequestJob* request_job);
315 319
316 // Adds and removes Listeners. 320 // Adds and removes Listeners.
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 553
550 // The following methods all rely on the internal |tick_clock_| for the 554 // The following methods all rely on the internal |tick_clock_| for the
551 // current time. 555 // current time.
552 void RestartTick(base::TimeTicks* time) const; 556 void RestartTick(base::TimeTicks* time) const;
553 bool RequestExpired(const base::TimeTicks& expiration) const; 557 bool RequestExpired(const base::TimeTicks& expiration) const;
554 base::TimeDelta GetTickDuration(const base::TimeTicks& time) const; 558 base::TimeDelta GetTickDuration(const base::TimeTicks& time) const;
555 559
556 // EmbeddedWorkerInstance::Listener overrides: 560 // EmbeddedWorkerInstance::Listener overrides:
557 void OnThreadStarted() override; 561 void OnThreadStarted() override;
558 void OnStarting() override; 562 void OnStarting() override;
563 void OnStartWorkerMessageSent() override;
559 void OnStarted() override; 564 void OnStarted() override;
560 void OnStopping() override; 565 void OnStopping() override;
561 void OnStopped(EmbeddedWorkerStatus old_status) override; 566 void OnStopped(EmbeddedWorkerStatus old_status) override;
562 void OnDetached(EmbeddedWorkerStatus old_status) override; 567 void OnDetached(EmbeddedWorkerStatus old_status) override;
563 void OnScriptLoaded() override; 568 void OnScriptLoaded() override;
564 void OnScriptLoadFailed() override; 569 void OnScriptLoadFailed() override;
565 void OnRegisteredToDevToolsManager() override; 570 void OnRegisteredToDevToolsManager() override;
566 void OnReportException(const base::string16& error_message, 571 void OnReportException(const base::string16& error_message,
567 int line_number, 572 int line_number,
568 int column_number, 573 int column_number,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 // Container for pending external requests for this service worker. 731 // Container for pending external requests for this service worker.
727 // (key, value): (request uuid, request id). 732 // (key, value): (request uuid, request id).
728 using RequestUUIDToRequestIDMap = std::map<std::string, int>; 733 using RequestUUIDToRequestIDMap = std::map<std::string, int>;
729 RequestUUIDToRequestIDMap external_request_uuid_to_request_id_; 734 RequestUUIDToRequestIDMap external_request_uuid_to_request_id_;
730 735
731 // Connected to ServiceWorkerContextClient while the worker is running. 736 // Connected to ServiceWorkerContextClient while the worker is running.
732 mojom::ServiceWorkerEventDispatcherPtr event_dispatcher_; 737 mojom::ServiceWorkerEventDispatcherPtr event_dispatcher_;
733 738
734 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; 739 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_;
735 740
741 // Keeps track of the provider hosting worker's context for this version.
falken 2017/06/14 08:10:35 "hosting this running service worker"
shimazu 2017/06/16 04:18:44 Done.
742 // |pending_provider_host_| is valid from StartWorkerInternal to
743 // OnStartWorkerMessageSent. On OnStartWorkerMessageSent, the ownership will
744 // be passed to ServiceWorkerContextCore.
745 // |provider_host_| is always valid as long as this version has
746 // the running context.
747 std::unique_ptr<ServiceWorkerProviderHost> pending_provider_host_;
748 base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
749
736 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; 750 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_;
737 // Will be null while shutting down. 751 // Will be null while shutting down.
738 base::WeakPtr<ServiceWorkerContextCore> context_; 752 base::WeakPtr<ServiceWorkerContextCore> context_;
739 base::ObserverList<Listener> listeners_; 753 base::ObserverList<Listener> listeners_;
740 ServiceWorkerScriptCacheMap script_cache_map_; 754 ServiceWorkerScriptCacheMap script_cache_map_;
741 base::OneShotTimer update_timer_; 755 base::OneShotTimer update_timer_;
742 756
743 // Starts running in StartWorker and continues until the worker is stopped. 757 // Starts running in StartWorker and continues until the worker is stopped.
744 base::RepeatingTimer timeout_timer_; 758 base::RepeatingTimer timeout_timer_;
745 // Holds the time the worker last started being considered idle. 759 // Holds the time the worker last started being considered idle.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 852
839 // At this point |this| can have been deleted, so don't do anything other 853 // At this point |this| can have been deleted, so don't do anything other
840 // than returning. 854 // than returning.
841 855
842 return true; 856 return true;
843 } 857 }
844 858
845 } // namespace content 859 } // namespace content
846 860
847 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 861 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698