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

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

Issue 2779763004: Create ServiceWorkerProviderHost before starting worker (Closed)
Patch Set: Rebased 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // Adds and removes |provider_host| as a controllee of this ServiceWorker. 296 // Adds and removes |provider_host| as a controllee of this ServiceWorker.
297 void AddControllee(ServiceWorkerProviderHost* provider_host); 297 void AddControllee(ServiceWorkerProviderHost* provider_host);
298 void RemoveControllee(ServiceWorkerProviderHost* provider_host); 298 void RemoveControllee(ServiceWorkerProviderHost* provider_host);
299 299
300 // Returns if it has controllee. 300 // Returns if it has controllee.
301 bool HasControllee() const { return !controllee_map_.empty(); } 301 bool HasControllee() const { return !controllee_map_.empty(); }
302 std::map<std::string, ServiceWorkerProviderHost*> controllee_map() { 302 std::map<std::string, ServiceWorkerProviderHost*> controllee_map() {
303 return controllee_map_; 303 return controllee_map_;
304 } 304 }
305 305
306 ServiceWorkerProviderHost* running_controller() {
falken 2017/06/01 08:12:35 // The provider host hosting this version. Only va
shimazu 2017/06/06 04:16:56 Done.
307 return running_controller_provider_.get();
308 }
309
306 base::WeakPtr<ServiceWorkerContextCore> context() const { return context_; } 310 base::WeakPtr<ServiceWorkerContextCore> context() const { return context_; }
307 311
308 // Adds and removes |request_job| as a dependent job not to stop the 312 // Adds and removes |request_job| as a dependent job not to stop the
309 // ServiceWorker while |request_job| is reading the stream of the fetch event 313 // ServiceWorker while |request_job| is reading the stream of the fetch event
310 // response from the ServiceWorker. 314 // response from the ServiceWorker.
311 void AddStreamingURLRequestJob(const ServiceWorkerURLRequestJob* request_job); 315 void AddStreamingURLRequestJob(const ServiceWorkerURLRequestJob* request_job);
312 void RemoveStreamingURLRequestJob( 316 void RemoveStreamingURLRequestJob(
313 const ServiceWorkerURLRequestJob* request_job); 317 const ServiceWorkerURLRequestJob* request_job);
314 318
315 // Adds and removes Listeners. 319 // Adds and removes Listeners.
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 552
549 // The following methods all rely on the internal |tick_clock_| for the 553 // The following methods all rely on the internal |tick_clock_| for the
550 // current time. 554 // current time.
551 void RestartTick(base::TimeTicks* time) const; 555 void RestartTick(base::TimeTicks* time) const;
552 bool RequestExpired(const base::TimeTicks& expiration) const; 556 bool RequestExpired(const base::TimeTicks& expiration) const;
553 base::TimeDelta GetTickDuration(const base::TimeTicks& time) const; 557 base::TimeDelta GetTickDuration(const base::TimeTicks& time) const;
554 558
555 // EmbeddedWorkerInstance::Listener overrides: 559 // EmbeddedWorkerInstance::Listener overrides:
556 void OnThreadStarted() override; 560 void OnThreadStarted() override;
557 void OnStarting() override; 561 void OnStarting() override;
562 void OnStartWorkerMessageSent() override;
558 void OnStarted() override; 563 void OnStarted() override;
559 void OnStopping() override; 564 void OnStopping() override;
560 void OnStopped(EmbeddedWorkerStatus old_status) override; 565 void OnStopped(EmbeddedWorkerStatus old_status) override;
561 void OnDetached(EmbeddedWorkerStatus old_status) override; 566 void OnDetached(EmbeddedWorkerStatus old_status) override;
562 void OnScriptLoaded() override; 567 void OnScriptLoaded() override;
563 void OnScriptLoadFailed() override; 568 void OnScriptLoadFailed() override;
564 void OnRegisteredToDevToolsManager() override; 569 void OnRegisteredToDevToolsManager() override;
565 void OnReportException(const base::string16& error_message, 570 void OnReportException(const base::string16& error_message,
566 int line_number, 571 int line_number,
567 int column_number, 572 int column_number,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 // Container for pending external requests for this service worker. 721 // Container for pending external requests for this service worker.
717 // (key, value): (request uuid, request id). 722 // (key, value): (request uuid, request id).
718 using RequestUUIDToRequestIDMap = std::map<std::string, int>; 723 using RequestUUIDToRequestIDMap = std::map<std::string, int>;
719 RequestUUIDToRequestIDMap external_request_uuid_to_request_id_; 724 RequestUUIDToRequestIDMap external_request_uuid_to_request_id_;
720 725
721 // Connected to ServiceWorkerContextClient while the worker is running. 726 // Connected to ServiceWorkerContextClient while the worker is running.
722 mojom::ServiceWorkerEventDispatcherPtr event_dispatcher_; 727 mojom::ServiceWorkerEventDispatcherPtr event_dispatcher_;
723 728
724 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; 729 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_;
725 730
731 // Keeps track of the provider hosting worker's context for this version.
732 // |pending_controller_provider_| is valid from StartWorkerInternal to
733 // OnStartWorkerMessageSent. On OnStartWorkerMessageSent, the ownership will
734 // be passed to the context.
falken 2017/06/01 08:12:34 does "context" here mean ServiceWorkerContextCore?
shimazu 2017/06/06 04:16:56 Done.
735 // |running_controller_provider_| is always valid as long as this version has
736 // the running context.
737 std::unique_ptr<ServiceWorkerProviderHost> pending_controller_provider_;
738 base::WeakPtr<ServiceWorkerProviderHost> running_controller_provider_;
falken 2017/06/01 08:12:35 How about just pending_provider_host_ and provider
shimazu 2017/06/06 04:16:56 Done.
739
726 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; 740 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_;
727 // Will be null while shutting down. 741 // Will be null while shutting down.
728 base::WeakPtr<ServiceWorkerContextCore> context_; 742 base::WeakPtr<ServiceWorkerContextCore> context_;
729 base::ObserverList<Listener> listeners_; 743 base::ObserverList<Listener> listeners_;
730 ServiceWorkerScriptCacheMap script_cache_map_; 744 ServiceWorkerScriptCacheMap script_cache_map_;
731 base::OneShotTimer update_timer_; 745 base::OneShotTimer update_timer_;
732 746
733 // Starts running in StartWorker and continues until the worker is stopped. 747 // Starts running in StartWorker and continues until the worker is stopped.
734 base::RepeatingTimer timeout_timer_; 748 base::RepeatingTimer timeout_timer_;
735 // Holds the time the worker last started being considered idle. 749 // Holds the time the worker last started being considered idle.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 842
829 // At this point |this| can have been deleted, so don't do anything other 843 // At this point |this| can have been deleted, so don't do anything other
830 // than returning. 844 // than returning.
831 845
832 return true; 846 return true;
833 } 847 }
834 848
835 } // namespace content 849 } // namespace content
836 850
837 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 851 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698