Index: content/browser/service_worker/service_worker_provider_host.h |
diff --git a/content/browser/service_worker/service_worker_provider_host.h b/content/browser/service_worker/service_worker_provider_host.h |
index a4f370418c34ae6b2b80f995cb91a03e207cd650..b38ee6c9f0cd2de4942eeedc83f02c136781eb57 100644 |
--- a/content/browser/service_worker/service_worker_provider_host.h |
+++ b/content/browser/service_worker/service_worker_provider_host.h |
@@ -47,6 +47,8 @@ class CONTENT_EXPORT ServiceWorkerProviderHost |
public: |
using GetClientInfoCallback = |
base::Callback<void(const ServiceWorkerClientInfo&)>; |
+ using GetRegistrationForReadyCallback = |
+ base::Callback<void(ServiceWorkerRegistration* reigstration)>; |
// If |render_frame_id| is MSG_ROUTING_NONE, this provider host works for the |
// worker context, i.e. ServiceWorker or SharedWorker. |
@@ -162,6 +164,11 @@ class CONTENT_EXPORT ServiceWorkerProviderHost |
// |registration| claims the document to be controlled. |
void ClaimedByRegistration(ServiceWorkerRegistration* registration); |
+ // Called by dispatcher host to get the registration for the "ready" property. |
+ // Returns false if there's a completed or ongoing request for the document. |
+ // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#navigator-service-worker-ready |
+ bool GetRegistrationForReady(const GetRegistrationForReadyCallback& callback); |
+ |
// Methods to support cross site navigations. |
void PrepareForCrossSiteTransfer(); |
void CompleteCrossSiteTransfer( |
@@ -191,6 +198,13 @@ class CONTENT_EXPORT ServiceWorkerProviderHost |
// Sets the worker thread id and flushes queued events. |
void SetReadyToSendMessagesToWorker(int render_thread_id); |
+ void AddMatchingRegistration(ServiceWorkerRegistration* registration); |
+ void RemoveMatchingRegistration(ServiceWorkerRegistration* registration); |
+ |
+ // An optimized implementation of [[Match Service Worker Registration]] |
+ // for current document. |
+ ServiceWorkerRegistration* MatchRegistration() const; |
+ |
private: |
friend class ServiceWorkerProviderHostTest; |
friend class ServiceWorkerWriteToCacheJobTest; |
@@ -199,8 +213,22 @@ class CONTENT_EXPORT ServiceWorkerProviderHost |
FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, |
UpdateAfter24Hours); |
+ struct OneShotGetReadyCallback { |
+ GetRegistrationForReadyCallback callback; |
+ bool called; |
+ |
+ OneShotGetReadyCallback(const GetRegistrationForReadyCallback& callback); |
falken
2015/03/09 06:29:23
nit: explicit
xiang
2015/03/09 06:46:13
Done.
|
+ ~OneShotGetReadyCallback(); |
+ }; |
+ |
// ServiceWorkerRegistration::Listener overrides. |
+ void OnVersionAttributesChanged( |
+ ServiceWorkerRegistration* registration, |
+ ChangedVersionAttributesMask changed_mask, |
+ const ServiceWorkerRegistrationInfo& info) override; |
void OnRegistrationFailed(ServiceWorkerRegistration* registration) override; |
+ void OnRegistrationFinishedUninstalling( |
+ ServiceWorkerRegistration* registration) override; |
void OnSkippedWaiting(ServiceWorkerRegistration* registration) override; |
// Sets the controller version field to |version| or if |version| is NULL, |
@@ -213,6 +241,8 @@ class CONTENT_EXPORT ServiceWorkerProviderHost |
void IncreaseProcessReference(const GURL& pattern); |
void DecreaseProcessReference(const GURL& pattern); |
+ void ReturnRegistrationForReadyIfNeeded(); |
+ |
bool IsReadyToSendMessages() const; |
void Send(IPC::Message* message) const; |
@@ -227,6 +257,14 @@ class CONTENT_EXPORT ServiceWorkerProviderHost |
std::vector<GURL> associated_patterns_; |
scoped_refptr<ServiceWorkerRegistration> associated_registration_; |
+ // Keyed by registration scope URL length. |
+ typedef std::map<size_t, scoped_refptr<ServiceWorkerRegistration>> |
+ ServiceWorkerRegistrationMap; |
+ // Contains all living registrations which has pattern this document's |
+ // URL starts with. |
+ ServiceWorkerRegistrationMap matching_registrations_; |
+ |
+ scoped_ptr<OneShotGetReadyCallback> get_ready_callback_; |
scoped_refptr<ServiceWorkerVersion> controlling_version_; |
scoped_refptr<ServiceWorkerVersion> running_hosted_version_; |
base::WeakPtr<ServiceWorkerContextCore> context_; |