| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 bool IsContextAlive(); | 124 bool IsContextAlive(); |
| 125 | 125 |
| 126 // Dispatches message event to the document. | 126 // Dispatches message event to the document. |
| 127 void PostMessage(const base::string16& message, | 127 void PostMessage(const base::string16& message, |
| 128 const std::vector<int>& sent_message_port_ids); | 128 const std::vector<int>& sent_message_port_ids); |
| 129 | 129 |
| 130 // Adds reference of this host's process to the |pattern|, the reference will | 130 // Adds reference of this host's process to the |pattern|, the reference will |
| 131 // be removed in destructor. | 131 // be removed in destructor. |
| 132 void AddScopedProcessReferenceToPattern(const GURL& pattern); | 132 void AddScopedProcessReferenceToPattern(const GURL& pattern); |
| 133 | 133 |
| 134 // Methods to support cross site navigations. |
| 135 void PrepareForCrossSiteTransfer(); |
| 136 void CompleteCrossSiteTransfer( |
| 137 int new_process_id, |
| 138 int new_provider_id, |
| 139 ServiceWorkerDispatcherHost* dispatcher_host); |
| 140 ServiceWorkerDispatcherHost* dispatcher_host() const { |
| 141 return dispatcher_host_; |
| 142 } |
| 143 |
| 134 private: | 144 private: |
| 135 friend class ServiceWorkerProviderHostTest; | 145 friend class ServiceWorkerProviderHostTest; |
| 136 friend class ServiceWorkerWriteToCacheJobTest; | 146 friend class ServiceWorkerWriteToCacheJobTest; |
| 137 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, | 147 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, |
| 138 UpdateBefore24Hours); | 148 UpdateBefore24Hours); |
| 139 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, | 149 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, |
| 140 UpdateAfter24Hours); | 150 UpdateAfter24Hours); |
| 141 | 151 |
| 142 // ServiceWorkerRegistration::Listener overrides. | 152 // ServiceWorkerRegistration::Listener overrides. |
| 143 void OnRegistrationFailed(ServiceWorkerRegistration* registration) override; | 153 void OnRegistrationFailed(ServiceWorkerRegistration* registration) override; |
| 144 | 154 |
| 145 // Sets the controller version field to |version| or if |version| is NULL, | 155 // Sets the controller version field to |version| or if |version| is NULL, |
| 146 // clears the field. | 156 // clears the field. |
| 147 void SetControllerVersionAttribute(ServiceWorkerVersion* version); | 157 void SetControllerVersionAttribute(ServiceWorkerVersion* version); |
| 148 | 158 |
| 159 void SendAssociateRegistrationMessage(); |
| 160 |
| 149 // Creates a ServiceWorkerHandle to retain |version| and returns a | 161 // Creates a ServiceWorkerHandle to retain |version| and returns a |
| 150 // ServiceWorkerInfo with the handle ID to pass to the provider. The | 162 // ServiceWorkerInfo with the handle ID to pass to the provider. The |
| 151 // provider is responsible for releasing the handle. | 163 // provider is responsible for releasing the handle. |
| 152 ServiceWorkerObjectInfo CreateHandleAndPass(ServiceWorkerVersion* version); | 164 ServiceWorkerObjectInfo CreateHandleAndPass(ServiceWorkerVersion* version); |
| 153 | 165 |
| 154 // Increase/decrease this host's process reference for |pattern|. | 166 // Increase/decrease this host's process reference for |pattern|. |
| 155 void IncreaseProcessReference(const GURL& pattern); | 167 void IncreaseProcessReference(const GURL& pattern); |
| 156 void DecreaseProcessReference(const GURL& pattern); | 168 void DecreaseProcessReference(const GURL& pattern); |
| 157 | 169 |
| 158 const int process_id_; | 170 int process_id_; |
| 159 const int provider_id_; | 171 int provider_id_; |
| 160 GURL document_url_; | 172 GURL document_url_; |
| 161 GURL topmost_frame_url_; | 173 GURL topmost_frame_url_; |
| 162 | 174 |
| 163 std::vector<GURL> associated_patterns_; | 175 std::vector<GURL> associated_patterns_; |
| 164 scoped_refptr<ServiceWorkerRegistration> associated_registration_; | 176 scoped_refptr<ServiceWorkerRegistration> associated_registration_; |
| 165 | 177 |
| 166 scoped_refptr<ServiceWorkerVersion> controlling_version_; | 178 scoped_refptr<ServiceWorkerVersion> controlling_version_; |
| 167 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; | 179 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; |
| 168 base::WeakPtr<ServiceWorkerContextCore> context_; | 180 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 169 ServiceWorkerDispatcherHost* dispatcher_host_; | 181 ServiceWorkerDispatcherHost* dispatcher_host_; |
| 170 bool allow_association_; | 182 bool allow_association_; |
| 171 | 183 |
| 172 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 184 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); |
| 173 }; | 185 }; |
| 174 | 186 |
| 175 } // namespace content | 187 } // namespace content |
| 176 | 188 |
| 177 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 189 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| OLD | NEW |