| OLD | NEW |
| 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_PROVIDER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 bool CanAssociateRegistration(ServiceWorkerRegistration* registration); | 100 bool CanAssociateRegistration(ServiceWorkerRegistration* registration); |
| 101 | 101 |
| 102 // Returns true if the context referred to by this host (i.e. |context_|) is | 102 // Returns true if the context referred to by this host (i.e. |context_|) is |
| 103 // still alive. | 103 // still alive. |
| 104 bool IsContextAlive(); | 104 bool IsContextAlive(); |
| 105 | 105 |
| 106 // Dispatches message event to the document. | 106 // Dispatches message event to the document. |
| 107 void PostMessage(const base::string16& message, | 107 void PostMessage(const base::string16& message, |
| 108 const std::vector<int>& sent_message_port_ids); | 108 const std::vector<int>& sent_message_port_ids); |
| 109 | 109 |
| 110 // Adds reference of this host's process to the |pattern|, the reference will |
| 111 // be removed in destructor. |
| 112 void AddScopedProcessReferenceToPattern(const GURL& pattern); |
| 113 |
| 110 private: | 114 private: |
| 111 friend class ServiceWorkerProviderHostTest; | 115 friend class ServiceWorkerProviderHostTest; |
| 112 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, | 116 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, |
| 113 UpdateBefore24Hours); | 117 UpdateBefore24Hours); |
| 114 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, | 118 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, |
| 115 UpdateAfter24Hours); | 119 UpdateAfter24Hours); |
| 116 | 120 |
| 117 // ServiceWorkerRegistration::Listener overrides. | 121 // ServiceWorkerRegistration::Listener overrides. |
| 118 virtual void OnVersionAttributesChanged( | 122 virtual void OnVersionAttributesChanged( |
| 119 ServiceWorkerRegistration* registration, | 123 ServiceWorkerRegistration* registration, |
| 120 ChangedVersionAttributesMask changed_mask, | 124 ChangedVersionAttributesMask changed_mask, |
| 121 const ServiceWorkerRegistrationInfo& info) OVERRIDE; | 125 const ServiceWorkerRegistrationInfo& info) OVERRIDE; |
| 122 virtual void OnRegistrationFailed( | 126 virtual void OnRegistrationFailed( |
| 123 ServiceWorkerRegistration* registration) OVERRIDE; | 127 ServiceWorkerRegistration* registration) OVERRIDE; |
| 124 | 128 |
| 125 // Adds this provider host to the potential controllee list of the given | |
| 126 // versions and removes it from the previous versions. | |
| 127 void UpdatePotentialControllees( | |
| 128 ServiceWorkerVersion* installing_version, | |
| 129 ServiceWorkerVersion* waiting_version, | |
| 130 ServiceWorkerVersion* active_version); | |
| 131 | |
| 132 // Sets the controller version field to |version| or if |version| is NULL, | 129 // Sets the controller version field to |version| or if |version| is NULL, |
| 133 // clears the field. | 130 // clears the field. |
| 134 void SetControllerVersionAttribute(ServiceWorkerVersion* version); | 131 void SetControllerVersionAttribute(ServiceWorkerVersion* version); |
| 135 | 132 |
| 136 // Creates a ServiceWorkerHandle to retain |version| and returns a | 133 // Creates a ServiceWorkerHandle to retain |version| and returns a |
| 137 // ServiceWorkerInfo with the handle ID to pass to the provider. The | 134 // ServiceWorkerInfo with the handle ID to pass to the provider. The |
| 138 // provider is responsible for releasing the handle. | 135 // provider is responsible for releasing the handle. |
| 139 ServiceWorkerObjectInfo CreateHandleAndPass(ServiceWorkerVersion* version); | 136 ServiceWorkerObjectInfo CreateHandleAndPass(ServiceWorkerVersion* version); |
| 140 | 137 |
| 138 // Increase/decrease this host's process reference for |pattern|. |
| 139 void IncreaseProcessReference(const GURL& pattern); |
| 140 void DecreaseProcessReference(const GURL& pattern); |
| 141 |
| 141 const int process_id_; | 142 const int process_id_; |
| 142 const int provider_id_; | 143 const int provider_id_; |
| 143 GURL document_url_; | 144 GURL document_url_; |
| 144 | 145 |
| 146 std::vector<GURL> associated_patterns_; |
| 145 scoped_refptr<ServiceWorkerRegistration> associated_registration_; | 147 scoped_refptr<ServiceWorkerRegistration> associated_registration_; |
| 146 | 148 |
| 147 scoped_refptr<ServiceWorkerVersion> controlling_version_; | 149 scoped_refptr<ServiceWorkerVersion> controlling_version_; |
| 148 scoped_refptr<ServiceWorkerVersion> active_version_; | 150 scoped_refptr<ServiceWorkerVersion> active_version_; |
| 149 scoped_refptr<ServiceWorkerVersion> waiting_version_; | 151 scoped_refptr<ServiceWorkerVersion> waiting_version_; |
| 150 scoped_refptr<ServiceWorkerVersion> installing_version_; | 152 scoped_refptr<ServiceWorkerVersion> installing_version_; |
| 151 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; | 153 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; |
| 152 base::WeakPtr<ServiceWorkerContextCore> context_; | 154 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 153 ServiceWorkerDispatcherHost* dispatcher_host_; | 155 ServiceWorkerDispatcherHost* dispatcher_host_; |
| 154 | 156 |
| 155 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 157 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); |
| 156 }; | 158 }; |
| 157 | 159 |
| 158 } // namespace content | 160 } // namespace content |
| 159 | 161 |
| 160 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 162 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| OLD | NEW |