Chromium Code Reviews| 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 798b7d4d6297aba88529799da5749f3efc881618..2c9fa751093c0d55df62d94c076ab2fcd7a74ffa 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. |
| @@ -161,6 +163,10 @@ 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. |
| + // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#navigator-service-worker-ready |
|
falken
2015/03/02 02:09:40
Can you add a comment about the return value?
xiang
2015/03/03 08:56:04
Done.
|
| + bool GetRegistrationForReady(const GetRegistrationForReadyCallback& callback); |
| + |
| // Methods to support cross site navigations. |
| void PrepareForCrossSiteTransfer(); |
| void CompleteCrossSiteTransfer( |
| @@ -190,6 +196,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; |
| @@ -198,8 +211,22 @@ class CONTENT_EXPORT ServiceWorkerProviderHost |
| FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, |
| UpdateAfter24Hours); |
| + struct OneShotGetReadyCallback { |
| + GetRegistrationForReadyCallback callback; |
| + bool called; |
| + |
| + OneShotGetReadyCallback(const GetRegistrationForReadyCallback& callback); |
| + ~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, |
| @@ -212,6 +239,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; |
| @@ -226,6 +255,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_; |