| 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> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 11 #include "content/browser/service_worker/service_worker_context_core.h" | 12 #include "content/browser/service_worker/service_worker_context_core.h" |
| 12 #include "content/browser/service_worker/service_worker_metrics.h" | 13 #include "content/browser/service_worker/service_worker_metrics.h" |
| 13 #include "content/browser/service_worker/service_worker_provider_host.h" | 14 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 14 #include "content/browser/service_worker/service_worker_registration.h" | 15 #include "content/browser/service_worker/service_worker_registration.h" |
| 15 #include "content/browser/service_worker/service_worker_response_info.h" | 16 #include "content/browser/service_worker/service_worker_response_info.h" |
| 16 #include "content/browser/service_worker/service_worker_url_request_job.h" | 17 #include "content/browser/service_worker/service_worker_url_request_job.h" |
| 17 #include "content/common/resource_request_body.h" | 18 #include "content/common/resource_request_body.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 job_->FallbackToNetwork(); | 189 job_->FallbackToNetwork(); |
| 189 TRACE_EVENT_ASYNC_END2( | 190 TRACE_EVENT_ASYNC_END2( |
| 190 "ServiceWorker", | 191 "ServiceWorker", |
| 191 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", | 192 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", |
| 192 job_.get(), | 193 job_.get(), |
| 193 "Status", status, | 194 "Status", status, |
| 194 "Info", "ServiceWorker is blocked"); | 195 "Info", "ServiceWorker is blocked"); |
| 195 return; | 196 return; |
| 196 } | 197 } |
| 197 | 198 |
| 199 if (!provider_host_->IsContextSecureForServiceWorker()) { |
| 200 // TODO(falken): Figure out a way to surface in the page's DevTools |
| 201 // console that the service worker was blocked for security. |
| 202 job_->FallbackToNetwork(); |
| 203 TRACE_EVENT_ASYNC_END1( |
| 204 "ServiceWorker", |
| 205 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", |
| 206 job_.get(), "Info", "Insecure context"); |
| 207 return; |
| 208 } |
| 209 |
| 198 if (need_to_update) { | 210 if (need_to_update) { |
| 199 force_update_started_ = true; | 211 force_update_started_ = true; |
| 200 context_->UpdateServiceWorker( | 212 context_->UpdateServiceWorker( |
| 201 registration.get(), true /* force_bypass_cache */, | 213 registration.get(), true /* force_bypass_cache */, |
| 202 true /* skip_script_comparison */, provider_host_.get(), | 214 true /* skip_script_comparison */, provider_host_.get(), |
| 203 base::Bind(&self::DidUpdateRegistration, weak_factory_.GetWeakPtr(), | 215 base::Bind(&self::DidUpdateRegistration, weak_factory_.GetWeakPtr(), |
| 204 registration)); | 216 registration)); |
| 205 return; | 217 return; |
| 206 } | 218 } |
| 207 | 219 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 DCHECK(provider_host_); | 401 DCHECK(provider_host_); |
| 390 // Detach the controller so subresource requests also skip the worker. | 402 // Detach the controller so subresource requests also skip the worker. |
| 391 provider_host_->NotifyControllerLost(); | 403 provider_host_->NotifyControllerLost(); |
| 392 } | 404 } |
| 393 | 405 |
| 394 void ServiceWorkerControlleeRequestHandler::ClearJob() { | 406 void ServiceWorkerControlleeRequestHandler::ClearJob() { |
| 395 job_.reset(); | 407 job_.reset(); |
| 396 } | 408 } |
| 397 | 409 |
| 398 } // namespace content | 410 } // namespace content |
| OLD | NEW |