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

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

Issue 2936623002: Implement dumb URLLoader{Factory} for ServiceWorker script loading (for try)
Patch Set: . 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 // Container for pending external requests for this service worker. 726 // Container for pending external requests for this service worker.
722 // (key, value): (request uuid, request id). 727 // (key, value): (request uuid, request id).
723 using RequestUUIDToRequestIDMap = std::map<std::string, int>; 728 using RequestUUIDToRequestIDMap = std::map<std::string, int>;
724 RequestUUIDToRequestIDMap external_request_uuid_to_request_id_; 729 RequestUUIDToRequestIDMap external_request_uuid_to_request_id_;
725 730
726 // Connected to ServiceWorkerContextClient while the worker is running. 731 // Connected to ServiceWorkerContextClient while the worker is running.
727 mojom::ServiceWorkerEventDispatcherPtr event_dispatcher_; 732 mojom::ServiceWorkerEventDispatcherPtr event_dispatcher_;
728 733
729 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; 734 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_;
730 735
736 // Keeps track of the provider hosting this running service worker for this
737 // version. |pending_provider_host_| is valid from StartWorkerInternal to
738 // OnStartWorkerMessageSent. On OnStartWorkerMessageSent, the ownership will
739 // be passed to ServiceWorkerContextCore.
740 // |provider_host_| is always valid as long as this version has
741 // the running context.
742 std::unique_ptr<ServiceWorkerProviderHost> pending_provider_host_;
743 base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
744
731 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; 745 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_;
732 // Will be null while shutting down. 746 // Will be null while shutting down.
733 base::WeakPtr<ServiceWorkerContextCore> context_; 747 base::WeakPtr<ServiceWorkerContextCore> context_;
734 base::ObserverList<Listener> listeners_; 748 base::ObserverList<Listener> listeners_;
735 ServiceWorkerScriptCacheMap script_cache_map_; 749 ServiceWorkerScriptCacheMap script_cache_map_;
736 base::OneShotTimer update_timer_; 750 base::OneShotTimer update_timer_;
737 751
738 // Starts running in StartWorker and continues until the worker is stopped. 752 // Starts running in StartWorker and continues until the worker is stopped.
739 base::RepeatingTimer timeout_timer_; 753 base::RepeatingTimer timeout_timer_;
740 // Holds the time the worker last started being considered idle. 754 // Holds the time the worker last started being considered idle.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 847
834 // At this point |this| can have been deleted, so don't do anything other 848 // At this point |this| can have been deleted, so don't do anything other
835 // than returning. 849 // than returning.
836 850
837 return true; 851 return true;
838 } 852 }
839 853
840 } // namespace content 854 } // namespace content
841 855
842 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 856 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698