| 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 <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 TRACE_EVENT_ASYNC_END2( | 243 TRACE_EVENT_ASYNC_END2( |
| 244 "ServiceWorker", | 244 "ServiceWorker", |
| 245 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", | 245 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", |
| 246 job_.get(), | 246 job_.get(), |
| 247 "Status", status, | 247 "Status", status, |
| 248 "Info", | 248 "Info", |
| 249 "ServiceWorkerVersion is not available, so falling back to network"); | 249 "ServiceWorkerVersion is not available, so falling back to network"); |
| 250 return; | 250 return; |
| 251 } | 251 } |
| 252 | 252 |
| 253 ServiceWorkerMetrics::CountControlledPageLoad(stripped_url_); | 253 ServiceWorkerMetrics::CountControlledPageLoad( |
| 254 stripped_url_, active_version->has_fetch_handler()); |
| 254 | 255 |
| 255 job_->ForwardToServiceWorker(); | 256 job_->ForwardToServiceWorker(); |
| 256 TRACE_EVENT_ASYNC_END2( | 257 TRACE_EVENT_ASYNC_END2( |
| 257 "ServiceWorker", | 258 "ServiceWorker", |
| 258 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", | 259 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", |
| 259 job_.get(), | 260 job_.get(), |
| 260 "Status", status, | 261 "Status", status, |
| 261 "Info", | 262 "Info", |
| 262 "Forwarded to the ServiceWorker"); | 263 "Forwarded to the ServiceWorker"); |
| 263 } | 264 } |
| 264 | 265 |
| 265 void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged( | 266 void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged( |
| 266 ServiceWorkerRegistration* registration, | 267 ServiceWorkerRegistration* registration, |
| 267 ServiceWorkerVersion* version) { | 268 ServiceWorkerVersion* version) { |
| 268 // The job may have been canceled and then destroyed before this was invoked. | 269 // The job may have been canceled and then destroyed before this was invoked. |
| 269 if (!job_) | 270 if (!job_) |
| 270 return; | 271 return; |
| 271 | 272 |
| 272 if (provider_host_) | 273 if (provider_host_) |
| 273 provider_host_->SetAllowAssociation(true); | 274 provider_host_->SetAllowAssociation(true); |
| 274 if (version != registration->active_version() || | 275 if (version != registration->active_version() || |
| 275 version->status() != ServiceWorkerVersion::ACTIVATED || | 276 version->status() != ServiceWorkerVersion::ACTIVATED || |
| 276 !provider_host_) { | 277 !provider_host_) { |
| 277 job_->FallbackToNetwork(); | 278 job_->FallbackToNetwork(); |
| 278 return; | 279 return; |
| 279 } | 280 } |
| 280 | 281 |
| 281 ServiceWorkerMetrics::CountControlledPageLoad(stripped_url_); | 282 ServiceWorkerMetrics::CountControlledPageLoad(stripped_url_, |
| 283 version->has_fetch_handler()); |
| 282 | 284 |
| 283 provider_host_->AssociateRegistration(registration, | 285 provider_host_->AssociateRegistration(registration, |
| 284 false /* notify_controllerchange */); | 286 false /* notify_controllerchange */); |
| 285 job_->ForwardToServiceWorker(); | 287 job_->ForwardToServiceWorker(); |
| 286 } | 288 } |
| 287 | 289 |
| 288 void ServiceWorkerControlleeRequestHandler::DidUpdateRegistration( | 290 void ServiceWorkerControlleeRequestHandler::DidUpdateRegistration( |
| 289 const scoped_refptr<ServiceWorkerRegistration>& original_registration, | 291 const scoped_refptr<ServiceWorkerRegistration>& original_registration, |
| 290 ServiceWorkerStatusCode status, | 292 ServiceWorkerStatusCode status, |
| 291 const std::string& status_message, | 293 const std::string& status_message, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 DCHECK(provider_host_); | 391 DCHECK(provider_host_); |
| 390 // Detach the controller so subresource requests also skip the worker. | 392 // Detach the controller so subresource requests also skip the worker. |
| 391 provider_host_->NotifyControllerLost(); | 393 provider_host_->NotifyControllerLost(); |
| 392 } | 394 } |
| 393 | 395 |
| 394 void ServiceWorkerControlleeRequestHandler::ClearJob() { | 396 void ServiceWorkerControlleeRequestHandler::ClearJob() { |
| 395 job_.reset(); | 397 job_.reset(); |
| 396 } | 398 } |
| 397 | 399 |
| 398 } // namespace content | 400 } // namespace content |
| OLD | NEW |