Chromium Code Reviews| 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 "content/browser/service_worker/service_worker_context_core.h" | 7 #include "content/browser/service_worker/service_worker_context_core.h" |
| 8 #include "content/browser/service_worker/service_worker_provider_host.h" | 8 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 9 #include "content/browser/service_worker/service_worker_registration.h" | 9 #include "content/browser/service_worker/service_worker_registration.h" |
| 10 #include "content/browser/service_worker/service_worker_url_request_job.h" | 10 #include "content/browser/service_worker/service_worker_url_request_job.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 if (is_main_resource_load_) | 38 if (is_main_resource_load_) |
| 39 provider_host_->active_version()->ScheduleUpdate(); | 39 provider_host_->active_version()->ScheduleUpdate(); |
| 40 else | 40 else |
| 41 provider_host_->active_version()->DeferScheduledUpdate(); | 41 provider_host_->active_version()->DeferScheduledUpdate(); |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 net::URLRequestJob* ServiceWorkerControlleeRequestHandler::MaybeCreateJob( | 45 net::URLRequestJob* ServiceWorkerControlleeRequestHandler::MaybeCreateJob( |
| 46 net::URLRequest* request, | 46 net::URLRequest* request, |
| 47 net::NetworkDelegate* network_delegate) { | 47 net::NetworkDelegate* network_delegate) { |
| 48 if (is_main_resource_load_ && provider_host_) | |
| 49 provider_host_->SetDocumentUrl(request->url()); | |
| 50 | |
| 48 if (!context_ || !provider_host_ || | 51 if (!context_ || !provider_host_ || |
| 49 request->load_flags() & net::LOAD_BYPASS_CACHE) { | 52 request->load_flags() & net::LOAD_BYPASS_CACHE) { |
|
michaeln
2014/07/02 18:40:30
might make sense to split the BYPASS condition out
| |
| 50 // We can't do anything other than to fall back to network. | 53 // We can't do anything other than to fall back to network. |
| 51 job_ = NULL; | 54 job_ = NULL; |
| 52 return NULL; | 55 return NULL; |
| 53 } | 56 } |
| 54 | 57 |
| 55 // This may get called multiple times for original and redirect requests: | 58 // This may get called multiple times for original and redirect requests: |
| 56 // A. original request case: job_ is null, no previous location info. | 59 // A. original request case: job_ is null, no previous location info. |
| 57 // B. redirect or restarted request case: | 60 // B. redirect or restarted request case: |
| 58 // a) job_ is non-null if the previous location was forwarded to SW. | 61 // a) job_ is non-null if the previous location was forwarded to SW. |
| 59 // b) job_ is null if the previous location was fallback. | 62 // b) job_ is null if the previous location was fallback. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 90 void ServiceWorkerControlleeRequestHandler::PrepareForMainResource( | 93 void ServiceWorkerControlleeRequestHandler::PrepareForMainResource( |
| 91 const GURL& url) { | 94 const GURL& url) { |
| 92 DCHECK(job_.get()); | 95 DCHECK(job_.get()); |
| 93 DCHECK(context_); | 96 DCHECK(context_); |
| 94 // The corresponding provider_host may already have associate version in | 97 // The corresponding provider_host may already have associate version in |
| 95 // redirect case, unassociate it now. | 98 // redirect case, unassociate it now. |
| 96 provider_host_->SetActiveVersion(NULL); | 99 provider_host_->SetActiveVersion(NULL); |
| 97 provider_host_->SetWaitingVersion(NULL); | 100 provider_host_->SetWaitingVersion(NULL); |
| 98 | 101 |
| 99 GURL stripped_url = net::SimplifyUrlForRequest(url); | 102 GURL stripped_url = net::SimplifyUrlForRequest(url); |
| 100 provider_host_->SetDocumentUrl(stripped_url); | |
|
michaeln
2014/07/02 18:40:30
probably should continue to pass in a stripped_url
| |
| 101 context_->storage()->FindRegistrationForDocument( | 103 context_->storage()->FindRegistrationForDocument( |
| 102 stripped_url, | 104 stripped_url, |
| 103 base::Bind(&self::DidLookupRegistrationForMainResource, | 105 base::Bind(&self::DidLookupRegistrationForMainResource, |
| 104 weak_factory_.GetWeakPtr())); | 106 weak_factory_.GetWeakPtr())); |
| 105 } | 107 } |
| 106 | 108 |
| 107 void | 109 void |
| 108 ServiceWorkerControlleeRequestHandler::DidLookupRegistrationForMainResource( | 110 ServiceWorkerControlleeRequestHandler::DidLookupRegistrationForMainResource( |
| 109 ServiceWorkerStatusCode status, | 111 ServiceWorkerStatusCode status, |
| 110 const scoped_refptr<ServiceWorkerRegistration>& registration) { | 112 const scoped_refptr<ServiceWorkerRegistration>& registration) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 124 } | 126 } |
| 125 | 127 |
| 126 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { | 128 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { |
| 127 DCHECK(job_.get()); | 129 DCHECK(job_.get()); |
| 128 DCHECK(context_); | 130 DCHECK(context_); |
| 129 DCHECK(provider_host_->active_version()); | 131 DCHECK(provider_host_->active_version()); |
| 130 job_->ForwardToServiceWorker(); | 132 job_->ForwardToServiceWorker(); |
| 131 } | 133 } |
| 132 | 134 |
| 133 } // namespace content | 135 } // namespace content |
| OLD | NEW |