OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/browser/service_worker/service_worker_controllee_request_handl er.h" | 5 #include "content/browser/service_worker/service_worker_controllee_request_handl er.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "content/browser/service_worker/service_worker_context_core.h" | 8 #include "content/browser/service_worker/service_worker_context_core.h" |
9 #include "content/browser/service_worker/service_worker_metrics.h" | 9 #include "content/browser/service_worker/service_worker_metrics.h" |
10 #include "content/browser/service_worker/service_worker_provider_host.h" | 10 #include "content/browser/service_worker/service_worker_provider_host.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 if (status != SERVICE_WORKER_OK) { | 132 if (status != SERVICE_WORKER_OK) { |
133 job_->FallbackToNetwork(); | 133 job_->FallbackToNetwork(); |
134 TRACE_EVENT_ASYNC_END1( | 134 TRACE_EVENT_ASYNC_END1( |
135 "ServiceWorker", | 135 "ServiceWorker", |
136 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", | 136 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", |
137 job_.get(), | 137 job_.get(), |
138 "Status", status); | 138 "Status", status); |
139 return; | 139 return; |
140 } | 140 } |
141 DCHECK(registration.get()); | 141 DCHECK(registration.get()); |
142 provider_host_->AssociateRegistration(registration.get()); | |
nhiroki
2014/09/08 15:55:52
To associate a potential controllee (ie. |provider
michaeln
2014/09/09 02:22:01
Does this have to happen prior to the pre-existing
nhiroki
2014/09/09 08:49:08
Hmmm... I think the condition would have already e
nhiroki
2014/09/09 11:48:35
As per the spec discussion (https://github.com/sli
michaeln
2014/09/09 23:30:33
Ah, I think your right and it definitely will have
| |
142 | 143 |
143 ServiceWorkerMetrics::CountControlledPageLoad(); | 144 ServiceWorkerMetrics::CountControlledPageLoad(); |
144 | 145 |
145 // Initiate activation of a waiting version. | 146 // Initiate activation of a waiting version. |
146 // Usually a register job initiates activation but that | 147 // Usually a register job initiates activation but that |
147 // doesn't happen if the browser exits prior to activation | 148 // doesn't happen if the browser exits prior to activation |
148 // having occurred. This check handles that case. | 149 // having occurred. This check handles that case. |
149 if (registration->waiting_version()) | 150 if (registration->waiting_version()) |
150 registration->ActivateWaitingVersionWhenReady(); | 151 registration->ActivateWaitingVersionWhenReady(); |
151 | 152 |
(...skipping 23 matching lines...) Expand all Loading... | |
175 TRACE_EVENT_ASYNC_END2( | 176 TRACE_EVENT_ASYNC_END2( |
176 "ServiceWorker", | 177 "ServiceWorker", |
177 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", | 178 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", |
178 job_.get(), | 179 job_.get(), |
179 "Status", status, | 180 "Status", status, |
180 "Info", | 181 "Info", |
181 "ServiceWorkerVersion is not available, so falling back to network"); | 182 "ServiceWorkerVersion is not available, so falling back to network"); |
182 return; | 183 return; |
183 } | 184 } |
184 | 185 |
185 provider_host_->AssociateRegistration(registration.get()); | 186 provider_host_->SetControllerVersionAttribute(active_version.get()); |
186 job_->ForwardToServiceWorker(); | 187 job_->ForwardToServiceWorker(); |
187 TRACE_EVENT_ASYNC_END2( | 188 TRACE_EVENT_ASYNC_END2( |
188 "ServiceWorker", | 189 "ServiceWorker", |
189 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", | 190 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", |
190 job_.get(), | 191 job_.get(), |
191 "Status", status, | 192 "Status", status, |
192 "Info", | 193 "Info", |
193 "Forwarded to the ServiceWorker"); | 194 "Forwarded to the ServiceWorker"); |
194 } | 195 } |
195 | 196 |
196 void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged( | 197 void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged( |
197 ServiceWorkerRegistration* registration, | 198 ServiceWorkerRegistration* registration, |
198 ServiceWorkerVersion* version) { | 199 ServiceWorkerVersion* version) { |
199 if (version != registration->active_version() || | 200 if (version != registration->active_version() || |
200 version->status() != ServiceWorkerVersion::ACTIVATED) { | 201 version->status() != ServiceWorkerVersion::ACTIVATED) { |
201 job_->FallbackToNetwork(); | 202 job_->FallbackToNetwork(); |
202 return; | 203 return; |
203 } | 204 } |
204 | 205 |
205 provider_host_->AssociateRegistration(registration); | 206 provider_host_->SetControllerVersionAttribute(registration->active_version()); |
206 job_->ForwardToServiceWorker(); | 207 job_->ForwardToServiceWorker(); |
207 } | 208 } |
208 | 209 |
209 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { | 210 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { |
210 DCHECK(job_.get()); | 211 DCHECK(job_.get()); |
211 DCHECK(context_); | 212 DCHECK(context_); |
212 DCHECK(provider_host_->active_version()); | 213 DCHECK(provider_host_->active_version()); |
213 job_->ForwardToServiceWorker(); | 214 job_->ForwardToServiceWorker(); |
214 } | 215 } |
215 | 216 |
216 } // namespace content | 217 } // namespace content |
OLD | NEW |