| 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 <set> | |
| 9 #include <string> | 8 #include <string> |
| 10 | 9 |
| 11 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 12 #include "content/browser/service_worker/service_worker_context_core.h" | 11 #include "content/browser/service_worker/service_worker_context_core.h" |
| 13 #include "content/browser/service_worker/service_worker_metrics.h" | 12 #include "content/browser/service_worker/service_worker_metrics.h" |
| 14 #include "content/browser/service_worker/service_worker_provider_host.h" | 13 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 15 #include "content/browser/service_worker/service_worker_registration.h" | 14 #include "content/browser/service_worker/service_worker_registration.h" |
| 16 #include "content/browser/service_worker/service_worker_response_info.h" | 15 #include "content/browser/service_worker/service_worker_response_info.h" |
| 17 #include "content/browser/service_worker/service_worker_url_request_job.h" | 16 #include "content/browser/service_worker/service_worker_url_request_job.h" |
| 18 #include "content/common/resource_request_body.h" | 17 #include "content/common/resource_request_body.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 job_->FallbackToNetwork(); | 206 job_->FallbackToNetwork(); |
| 208 TRACE_EVENT_ASYNC_END2( | 207 TRACE_EVENT_ASYNC_END2( |
| 209 "ServiceWorker", | 208 "ServiceWorker", |
| 210 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", | 209 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", |
| 211 job_.get(), | 210 job_.get(), |
| 212 "Status", status, | 211 "Status", status, |
| 213 "Info", "ServiceWorker is blocked"); | 212 "Info", "ServiceWorker is blocked"); |
| 214 return; | 213 return; |
| 215 } | 214 } |
| 216 | 215 |
| 217 if (!provider_host_->IsContextSecureForServiceWorker()) { | |
| 218 // TODO(falken): Figure out a way to surface in the page's DevTools | |
| 219 // console that the service worker was blocked for security. | |
| 220 job_->FallbackToNetwork(); | |
| 221 TRACE_EVENT_ASYNC_END1( | |
| 222 "ServiceWorker", | |
| 223 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", | |
| 224 job_.get(), "Info", "Insecure context"); | |
| 225 return; | |
| 226 } | |
| 227 | |
| 228 if (need_to_update) { | 216 if (need_to_update) { |
| 229 force_update_started_ = true; | 217 force_update_started_ = true; |
| 230 context_->UpdateServiceWorker( | 218 context_->UpdateServiceWorker( |
| 231 registration.get(), true /* force_bypass_cache */, | 219 registration.get(), true /* force_bypass_cache */, |
| 232 true /* skip_script_comparison */, provider_host_.get(), | 220 true /* skip_script_comparison */, provider_host_.get(), |
| 233 base::Bind(&self::DidUpdateRegistration, weak_factory_.GetWeakPtr(), | 221 base::Bind(&self::DidUpdateRegistration, weak_factory_.GetWeakPtr(), |
| 234 registration)); | 222 registration)); |
| 235 return; | 223 return; |
| 236 } | 224 } |
| 237 | 225 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 DCHECK(provider_host_); | 411 DCHECK(provider_host_); |
| 424 // Detach the controller so subresource requests also skip the worker. | 412 // Detach the controller so subresource requests also skip the worker. |
| 425 provider_host_->NotifyControllerLost(); | 413 provider_host_->NotifyControllerLost(); |
| 426 } | 414 } |
| 427 | 415 |
| 428 void ServiceWorkerControlleeRequestHandler::ClearJob() { | 416 void ServiceWorkerControlleeRequestHandler::ClearJob() { |
| 429 job_.reset(); | 417 job_.reset(); |
| 430 } | 418 } |
| 431 | 419 |
| 432 } // namespace content | 420 } // namespace content |
| OLD | NEW |