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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 ServiceWorkerProviderHost(int render_process_id, | 50 ServiceWorkerProviderHost(int render_process_id, |
51 int render_frame_id, | 51 int render_frame_id, |
52 int provider_id, | 52 int provider_id, |
53 base::WeakPtr<ServiceWorkerContextCore> context, | 53 base::WeakPtr<ServiceWorkerContextCore> context, |
54 ServiceWorkerDispatcherHost* dispatcher_host); | 54 ServiceWorkerDispatcherHost* dispatcher_host); |
55 virtual ~ServiceWorkerProviderHost(); | 55 virtual ~ServiceWorkerProviderHost(); |
56 | 56 |
57 int process_id() const { return render_process_id_; } | 57 int process_id() const { return render_process_id_; } |
58 int provider_id() const { return provider_id_; } | 58 int provider_id() const { return provider_id_; } |
| 59 int frame_id() const { return render_frame_id_; } |
59 | 60 |
60 bool IsHostToRunningServiceWorker() { | 61 bool IsHostToRunningServiceWorker() { |
61 return running_hosted_version_.get() != NULL; | 62 return running_hosted_version_.get() != NULL; |
62 } | 63 } |
63 | 64 |
64 ServiceWorkerVersion* controlling_version() const { | 65 ServiceWorkerVersion* controlling_version() const { |
65 return controlling_version_.get(); | 66 return controlling_version_.get(); |
66 } | 67 } |
67 ServiceWorkerVersion* active_version() const { | 68 ServiceWorkerVersion* active_version() const { |
68 return associated_registration_.get() ? | 69 return associated_registration_.get() ? |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Activates the WebContents associated with | 134 // Activates the WebContents associated with |
134 // { render_process_id_, render_frame_id_ }. | 135 // { render_process_id_, render_frame_id_ }. |
135 // Runs the |callback| with the result in parameter describing whether the | 136 // Runs the |callback| with the result in parameter describing whether the |
136 // focusing action was successful. | 137 // focusing action was successful. |
137 void Focus(const FocusCallback& callback); | 138 void Focus(const FocusCallback& callback); |
138 | 139 |
139 // Adds reference of this host's process to the |pattern|, the reference will | 140 // Adds reference of this host's process to the |pattern|, the reference will |
140 // be removed in destructor. | 141 // be removed in destructor. |
141 void AddScopedProcessReferenceToPattern(const GURL& pattern); | 142 void AddScopedProcessReferenceToPattern(const GURL& pattern); |
142 | 143 |
| 144 // Methods to support cross site navigations. |
| 145 void PrepareForCrossSiteTransfer(); |
| 146 void CompleteCrossSiteTransfer( |
| 147 int new_process_id, |
| 148 int new_frame_id, |
| 149 int new_provider_id, |
| 150 ServiceWorkerDispatcherHost* dispatcher_host); |
| 151 ServiceWorkerDispatcherHost* dispatcher_host() const { |
| 152 return dispatcher_host_; |
| 153 } |
| 154 |
143 private: | 155 private: |
144 friend class ServiceWorkerProviderHostTest; | 156 friend class ServiceWorkerProviderHostTest; |
145 friend class ServiceWorkerWriteToCacheJobTest; | 157 friend class ServiceWorkerWriteToCacheJobTest; |
146 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, | 158 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, |
147 UpdateBefore24Hours); | 159 UpdateBefore24Hours); |
148 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, | 160 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, |
149 UpdateAfter24Hours); | 161 UpdateAfter24Hours); |
150 | 162 |
151 // ServiceWorkerRegistration::Listener overrides. | 163 // ServiceWorkerRegistration::Listener overrides. |
152 void OnRegistrationFailed(ServiceWorkerRegistration* registration) override; | 164 void OnRegistrationFailed(ServiceWorkerRegistration* registration) override; |
153 | 165 |
154 // Sets the controller version field to |version| or if |version| is NULL, | 166 // Sets the controller version field to |version| or if |version| is NULL, |
155 // clears the field. | 167 // clears the field. |
156 void SetControllerVersionAttribute(ServiceWorkerVersion* version); | 168 void SetControllerVersionAttribute(ServiceWorkerVersion* version); |
157 | 169 |
| 170 void SendAssociateRegistrationMessage(); |
| 171 |
158 // Creates a ServiceWorkerHandle to retain |version| and returns a | 172 // Creates a ServiceWorkerHandle to retain |version| and returns a |
159 // ServiceWorkerInfo with the handle ID to pass to the provider. The | 173 // ServiceWorkerInfo with the handle ID to pass to the provider. The |
160 // provider is responsible for releasing the handle. | 174 // provider is responsible for releasing the handle. |
161 ServiceWorkerObjectInfo CreateHandleAndPass(ServiceWorkerVersion* version); | 175 ServiceWorkerObjectInfo CreateHandleAndPass(ServiceWorkerVersion* version); |
162 | 176 |
163 // Increase/decrease this host's process reference for |pattern|. | 177 // Increase/decrease this host's process reference for |pattern|. |
164 void IncreaseProcessReference(const GURL& pattern); | 178 void IncreaseProcessReference(const GURL& pattern); |
165 void DecreaseProcessReference(const GURL& pattern); | 179 void DecreaseProcessReference(const GURL& pattern); |
166 | 180 |
167 const int render_process_id_; | 181 int render_process_id_; |
168 const int render_frame_id_; | 182 int render_frame_id_; |
169 const int provider_id_; | 183 int provider_id_; |
170 GURL document_url_; | 184 GURL document_url_; |
171 GURL topmost_frame_url_; | 185 GURL topmost_frame_url_; |
172 | 186 |
173 std::vector<GURL> associated_patterns_; | 187 std::vector<GURL> associated_patterns_; |
174 scoped_refptr<ServiceWorkerRegistration> associated_registration_; | 188 scoped_refptr<ServiceWorkerRegistration> associated_registration_; |
175 | 189 |
176 scoped_refptr<ServiceWorkerVersion> controlling_version_; | 190 scoped_refptr<ServiceWorkerVersion> controlling_version_; |
177 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; | 191 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; |
178 base::WeakPtr<ServiceWorkerContextCore> context_; | 192 base::WeakPtr<ServiceWorkerContextCore> context_; |
179 ServiceWorkerDispatcherHost* dispatcher_host_; | 193 ServiceWorkerDispatcherHost* dispatcher_host_; |
180 bool allow_association_; | 194 bool allow_association_; |
181 | 195 |
182 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 196 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); |
183 }; | 197 }; |
184 | 198 |
185 } // namespace content | 199 } // namespace content |
186 | 200 |
187 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 201 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
OLD | NEW |