OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/loader/resource_loader.h" | 5 #include "content/browser/loader/resource_loader.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 waiting_for_upload_progress_ack_(false), | 90 waiting_for_upload_progress_ack_(false), |
91 is_transferring_(false), | 91 is_transferring_(false), |
92 weak_ptr_factory_(this) { | 92 weak_ptr_factory_(this) { |
93 request_->set_delegate(this); | 93 request_->set_delegate(this); |
94 handler_->SetController(this); | 94 handler_->SetController(this); |
95 } | 95 } |
96 | 96 |
97 ResourceLoader::~ResourceLoader() { | 97 ResourceLoader::~ResourceLoader() { |
98 if (login_delegate_.get()) | 98 if (login_delegate_.get()) |
99 login_delegate_->OnRequestCancelled(); | 99 login_delegate_->OnRequestCancelled(); |
100 ssl_client_auth_handler_.reset(); | 100 if (ssl_client_auth_handler_.get()) |
| 101 ssl_client_auth_handler_->OnRequestCancelled(); |
101 | 102 |
102 // Run ResourceHandler destructor before we tear-down the rest of our state | 103 // Run ResourceHandler destructor before we tear-down the rest of our state |
103 // as the ResourceHandler may want to inspect the URLRequest and other state. | 104 // as the ResourceHandler may want to inspect the URLRequest and other state. |
104 handler_.reset(); | 105 handler_.reset(); |
105 } | 106 } |
106 | 107 |
107 void ResourceLoader::StartRequest() { | 108 void ResourceLoader::StartRequest() { |
108 if (delegate_->HandleExternalProtocol(this, request_->url())) { | 109 if (delegate_->HandleExternalProtocol(this, request_->url())) { |
109 CancelAndIgnore(); | 110 CancelAndIgnore(); |
110 return; | 111 return; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 204 } |
204 | 205 |
205 ResourceRequestInfoImpl* ResourceLoader::GetRequestInfo() { | 206 ResourceRequestInfoImpl* ResourceLoader::GetRequestInfo() { |
206 return ResourceRequestInfoImpl::ForRequest(request_.get()); | 207 return ResourceRequestInfoImpl::ForRequest(request_.get()); |
207 } | 208 } |
208 | 209 |
209 void ResourceLoader::ClearLoginDelegate() { | 210 void ResourceLoader::ClearLoginDelegate() { |
210 login_delegate_ = NULL; | 211 login_delegate_ = NULL; |
211 } | 212 } |
212 | 213 |
| 214 void ResourceLoader::ClearSSLClientAuthHandler() { |
| 215 ssl_client_auth_handler_ = NULL; |
| 216 } |
| 217 |
213 void ResourceLoader::OnUploadProgressACK() { | 218 void ResourceLoader::OnUploadProgressACK() { |
214 waiting_for_upload_progress_ack_ = false; | 219 waiting_for_upload_progress_ack_ = false; |
215 } | 220 } |
216 | 221 |
217 void ResourceLoader::OnReceivedRedirect(net::URLRequest* unused, | 222 void ResourceLoader::OnReceivedRedirect(net::URLRequest* unused, |
218 const net::RedirectInfo& redirect_info, | 223 const net::RedirectInfo& redirect_info, |
219 bool* defer) { | 224 bool* defer) { |
220 DCHECK_EQ(request_.get(), unused); | 225 DCHECK_EQ(request_.get(), unused); |
221 | 226 |
222 VLOG(1) << "OnReceivedRedirect: " << request_->url().spec(); | 227 VLOG(1) << "OnReceivedRedirect: " << request_->url().spec(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 void ResourceLoader::OnCertificateRequested( | 285 void ResourceLoader::OnCertificateRequested( |
281 net::URLRequest* unused, | 286 net::URLRequest* unused, |
282 net::SSLCertRequestInfo* cert_info) { | 287 net::SSLCertRequestInfo* cert_info) { |
283 DCHECK_EQ(request_.get(), unused); | 288 DCHECK_EQ(request_.get(), unused); |
284 | 289 |
285 if (request_->load_flags() & net::LOAD_PREFETCH) { | 290 if (request_->load_flags() & net::LOAD_PREFETCH) { |
286 request_->Cancel(); | 291 request_->Cancel(); |
287 return; | 292 return; |
288 } | 293 } |
289 | 294 |
290 DCHECK(!ssl_client_auth_handler_) | 295 DCHECK(!ssl_client_auth_handler_.get()) |
291 << "OnCertificateRequested called with ssl_client_auth_handler pending"; | 296 << "OnCertificateRequested called with ssl_client_auth_handler pending"; |
292 ssl_client_auth_handler_.reset(new SSLClientAuthHandler( | 297 ssl_client_auth_handler_ = new SSLClientAuthHandler( |
293 GetRequestInfo()->GetContext()->CreateClientCertStore(), | 298 GetRequestInfo()->GetContext()->CreateClientCertStore(), |
294 request_.get(), | 299 request_.get(), |
295 cert_info, | 300 cert_info); |
296 base::Bind(&ResourceLoader::ContinueWithCertificate, | |
297 weak_ptr_factory_.GetWeakPtr()))); | |
298 ssl_client_auth_handler_->SelectCertificate(); | 301 ssl_client_auth_handler_->SelectCertificate(); |
299 } | 302 } |
300 | 303 |
301 void ResourceLoader::OnSSLCertificateError(net::URLRequest* request, | 304 void ResourceLoader::OnSSLCertificateError(net::URLRequest* request, |
302 const net::SSLInfo& ssl_info, | 305 const net::SSLInfo& ssl_info, |
303 bool fatal) { | 306 bool fatal) { |
304 ResourceRequestInfoImpl* info = GetRequestInfo(); | 307 ResourceRequestInfoImpl* info = GetRequestInfo(); |
305 | 308 |
306 int render_process_id; | 309 int render_process_id; |
307 int render_frame_id; | 310 int render_frame_id; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 } | 563 } |
561 | 564 |
562 // TODO(darin): Perhaps we should really be looking to see if the status is | 565 // TODO(darin): Perhaps we should really be looking to see if the status is |
563 // IO_PENDING? | 566 // IO_PENDING? |
564 bool was_pending = request_->is_pending(); | 567 bool was_pending = request_->is_pending(); |
565 | 568 |
566 if (login_delegate_.get()) { | 569 if (login_delegate_.get()) { |
567 login_delegate_->OnRequestCancelled(); | 570 login_delegate_->OnRequestCancelled(); |
568 login_delegate_ = NULL; | 571 login_delegate_ = NULL; |
569 } | 572 } |
570 ssl_client_auth_handler_.reset(); | 573 if (ssl_client_auth_handler_.get()) { |
| 574 ssl_client_auth_handler_->OnRequestCancelled(); |
| 575 ssl_client_auth_handler_ = NULL; |
| 576 } |
571 | 577 |
572 request_->CancelWithError(error); | 578 request_->CancelWithError(error); |
573 | 579 |
574 if (!was_pending) { | 580 if (!was_pending) { |
575 // If the request isn't in flight, then we won't get an asynchronous | 581 // If the request isn't in flight, then we won't get an asynchronous |
576 // notification from the request, so we have to signal ourselves to finish | 582 // notification from the request, so we have to signal ourselves to finish |
577 // this request. | 583 // this request. |
578 base::MessageLoop::current()->PostTask( | 584 base::MessageLoop::current()->PostTask( |
579 FROM_HERE, | 585 FROM_HERE, |
580 base::Bind(&ResourceLoader::ResponseCompleted, | 586 base::Bind(&ResourceLoader::ResponseCompleted, |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 case net::URLRequestStatus::IO_PENDING: | 812 case net::URLRequestStatus::IO_PENDING: |
807 case net::URLRequestStatus::FAILED: | 813 case net::URLRequestStatus::FAILED: |
808 status = STATUS_UNDEFINED; | 814 status = STATUS_UNDEFINED; |
809 break; | 815 break; |
810 } | 816 } |
811 | 817 |
812 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); | 818 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); |
813 } | 819 } |
814 } | 820 } |
815 | 821 |
816 void ResourceLoader::ContinueWithCertificate(net::X509Certificate* cert) { | |
817 ssl_client_auth_handler_.reset(); | |
818 request_->ContinueWithCertificate(cert); | |
819 } | |
820 | |
821 } // namespace content | 822 } // namespace content |
OLD | NEW |