X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fcontent%2Fbrowser%2Fservice_worker%2Fservice_worker_provider_host.h;h=319b0d93a07c6701d66fc76bbc98d8f1f6c8259b;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=c417fc72439b3f3fc0a0c84962f8aae1eec8a165;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/content/browser/service_worker/service_worker_provider_host.h b/src/content/browser/service_worker/service_worker_provider_host.h index c417fc7..319b0d9 100644 --- a/src/content/browser/service_worker/service_worker_provider_host.h +++ b/src/content/browser/service_worker/service_worker_provider_host.h @@ -19,12 +19,13 @@ namespace IPC { class Sender; } -namespace webkit_blob { +namespace storage { class BlobStorageContext; } namespace content { +class ResourceRequestBody; class ServiceWorkerContextCore; class ServiceWorkerDispatcherHost; class ServiceWorkerRequestHandler; @@ -39,7 +40,7 @@ class ServiceWorkerVersion; // Note this class can also host a running service worker, in which // case it will observe resource loads made directly by the service worker. class CONTENT_EXPORT ServiceWorkerProviderHost - : public ServiceWorkerRegistration::Listener, + : public NON_EXPORTED_BASE(ServiceWorkerRegistration::Listener), public base::SupportsWeakPtr { public: ServiceWorkerProviderHost(int process_id, @@ -52,21 +53,23 @@ class CONTENT_EXPORT ServiceWorkerProviderHost int provider_id() const { return provider_id_; } bool IsHostToRunningServiceWorker() { - return running_hosted_version_ != NULL; + return running_hosted_version_.get() != NULL; } - // Getters for the navigator.serviceWorker attribute values. ServiceWorkerVersion* controlling_version() const { return controlling_version_.get(); } ServiceWorkerVersion* active_version() const { - return active_version_.get(); + return associated_registration_.get() ? + associated_registration_->active_version() : NULL; } ServiceWorkerVersion* waiting_version() const { - return waiting_version_.get(); + return associated_registration_.get() ? + associated_registration_->waiting_version() : NULL; } ServiceWorkerVersion* installing_version() const { - return installing_version_.get(); + return associated_registration_.get() ? + associated_registration_->installing_version() : NULL; } // The running version, if any, that this provider is providing resource @@ -82,7 +85,7 @@ class CONTENT_EXPORT ServiceWorkerProviderHost void AssociateRegistration(ServiceWorkerRegistration* registration); // Clears the associated registration and stop listening to it. - void UnassociateRegistration(); + void DisassociateRegistration(); // Returns false if the version is not in the expected STARTING in our // process state. That would be indicative of a bad IPC message. @@ -92,11 +95,17 @@ class CONTENT_EXPORT ServiceWorkerProviderHost // the request doesn't require special handling. scoped_ptr CreateRequestHandler( ResourceType resource_type, - base::WeakPtr blob_storage_context); + base::WeakPtr blob_storage_context, + scoped_refptr body); // Returns true if |registration| can be associated with this provider. bool CanAssociateRegistration(ServiceWorkerRegistration* registration); + // For use by the ServiceWorkerControlleeRequestHandler to disallow + // new registration association while a navigation is occurring and + // an existing registration is being looked for. + void SetAllowAssociation(bool allow) { allow_association_ = allow; } + // Returns true if the context referred to by this host (i.e. |context_|) is // still alive. bool IsContextAlive(); @@ -105,6 +114,10 @@ class CONTENT_EXPORT ServiceWorkerProviderHost void PostMessage(const base::string16& message, const std::vector& sent_message_port_ids); + // Adds reference of this host's process to the |pattern|, the reference will + // be removed in destructor. + void AddScopedProcessReferenceToPattern(const GURL& pattern); + private: friend class ServiceWorkerProviderHostTest; FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, @@ -113,48 +126,34 @@ class CONTENT_EXPORT ServiceWorkerProviderHost UpdateAfter24Hours); // ServiceWorkerRegistration::Listener overrides. - virtual void OnVersionAttributesChanged( - ServiceWorkerRegistration* registration, - ChangedVersionAttributesMask changed_mask, - const ServiceWorkerRegistrationInfo& info) OVERRIDE; virtual void OnRegistrationFailed( ServiceWorkerRegistration* registration) OVERRIDE; - // Sets the corresponding version field to the given version or if the given - // version is NULL, clears the field. - void SetVersionAttributes( - ServiceWorkerVersion* installing_version, - ServiceWorkerVersion* waiting_version, - ServiceWorkerVersion* active_version); - void SetVersionAttributesInternal( - ServiceWorkerVersion* version, - scoped_refptr* data_member); - // Sets the controller version field to |version| or if |version| is NULL, // clears the field. void SetControllerVersionAttribute(ServiceWorkerVersion* version); - // Clears all version fields. - void ClearVersionAttributes(); - // Creates a ServiceWorkerHandle to retain |version| and returns a // ServiceWorkerInfo with the handle ID to pass to the provider. The // provider is responsible for releasing the handle. ServiceWorkerObjectInfo CreateHandleAndPass(ServiceWorkerVersion* version); + // Increase/decrease this host's process reference for |pattern|. + void IncreaseProcessReference(const GURL& pattern); + void DecreaseProcessReference(const GURL& pattern); + const int process_id_; const int provider_id_; GURL document_url_; + std::vector associated_patterns_; scoped_refptr associated_registration_; scoped_refptr controlling_version_; - scoped_refptr active_version_; - scoped_refptr waiting_version_; - scoped_refptr installing_version_; scoped_refptr running_hosted_version_; base::WeakPtr context_; ServiceWorkerDispatcherHost* dispatcher_host_; + bool allow_association_; DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); };