| 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 if (ssl_client_auth_handler_.get()) | 100 ssl_client_auth_handler_.reset(); |
| 101 ssl_client_auth_handler_->OnRequestCancelled(); | |
| 102 | 101 |
| 103 // Run ResourceHandler destructor before we tear-down the rest of our state | 102 // Run ResourceHandler destructor before we tear-down the rest of our state |
| 104 // as the ResourceHandler may want to inspect the URLRequest and other state. | 103 // as the ResourceHandler may want to inspect the URLRequest and other state. |
| 105 handler_.reset(); | 104 handler_.reset(); |
| 106 } | 105 } |
| 107 | 106 |
| 108 void ResourceLoader::StartRequest() { | 107 void ResourceLoader::StartRequest() { |
| 109 if (delegate_->HandleExternalProtocol(this, request_->url())) { | 108 if (delegate_->HandleExternalProtocol(this, request_->url())) { |
| 110 CancelAndIgnore(); | 109 CancelAndIgnore(); |
| 111 return; | 110 return; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 203 } |
| 205 | 204 |
| 206 ResourceRequestInfoImpl* ResourceLoader::GetRequestInfo() { | 205 ResourceRequestInfoImpl* ResourceLoader::GetRequestInfo() { |
| 207 return ResourceRequestInfoImpl::ForRequest(request_.get()); | 206 return ResourceRequestInfoImpl::ForRequest(request_.get()); |
| 208 } | 207 } |
| 209 | 208 |
| 210 void ResourceLoader::ClearLoginDelegate() { | 209 void ResourceLoader::ClearLoginDelegate() { |
| 211 login_delegate_ = NULL; | 210 login_delegate_ = NULL; |
| 212 } | 211 } |
| 213 | 212 |
| 214 void ResourceLoader::ClearSSLClientAuthHandler() { | |
| 215 ssl_client_auth_handler_ = NULL; | |
| 216 } | |
| 217 | |
| 218 void ResourceLoader::OnUploadProgressACK() { | 213 void ResourceLoader::OnUploadProgressACK() { |
| 219 waiting_for_upload_progress_ack_ = false; | 214 waiting_for_upload_progress_ack_ = false; |
| 220 } | 215 } |
| 221 | 216 |
| 222 void ResourceLoader::OnReceivedRedirect(net::URLRequest* unused, | 217 void ResourceLoader::OnReceivedRedirect(net::URLRequest* unused, |
| 223 const net::RedirectInfo& redirect_info, | 218 const net::RedirectInfo& redirect_info, |
| 224 bool* defer) { | 219 bool* defer) { |
| 225 DCHECK_EQ(request_.get(), unused); | 220 DCHECK_EQ(request_.get(), unused); |
| 226 | 221 |
| 227 VLOG(1) << "OnReceivedRedirect: " << request_->url().spec(); | 222 VLOG(1) << "OnReceivedRedirect: " << request_->url().spec(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 void ResourceLoader::OnCertificateRequested( | 280 void ResourceLoader::OnCertificateRequested( |
| 286 net::URLRequest* unused, | 281 net::URLRequest* unused, |
| 287 net::SSLCertRequestInfo* cert_info) { | 282 net::SSLCertRequestInfo* cert_info) { |
| 288 DCHECK_EQ(request_.get(), unused); | 283 DCHECK_EQ(request_.get(), unused); |
| 289 | 284 |
| 290 if (request_->load_flags() & net::LOAD_PREFETCH) { | 285 if (request_->load_flags() & net::LOAD_PREFETCH) { |
| 291 request_->Cancel(); | 286 request_->Cancel(); |
| 292 return; | 287 return; |
| 293 } | 288 } |
| 294 | 289 |
| 295 DCHECK(!ssl_client_auth_handler_.get()) | 290 DCHECK(!ssl_client_auth_handler_) |
| 296 << "OnCertificateRequested called with ssl_client_auth_handler pending"; | 291 << "OnCertificateRequested called with ssl_client_auth_handler pending"; |
| 297 ssl_client_auth_handler_ = new SSLClientAuthHandler( | 292 ssl_client_auth_handler_.reset(new SSLClientAuthHandler( |
| 298 GetRequestInfo()->GetContext()->CreateClientCertStore(), | 293 GetRequestInfo()->GetContext()->CreateClientCertStore(), |
| 299 request_.get(), | 294 request_.get(), |
| 300 cert_info); | 295 cert_info, |
| 296 base::Bind(&ResourceLoader::ContinueWithCertificate, |
| 297 weak_ptr_factory_.GetWeakPtr()))); |
| 301 ssl_client_auth_handler_->SelectCertificate(); | 298 ssl_client_auth_handler_->SelectCertificate(); |
| 302 } | 299 } |
| 303 | 300 |
| 304 void ResourceLoader::OnSSLCertificateError(net::URLRequest* request, | 301 void ResourceLoader::OnSSLCertificateError(net::URLRequest* request, |
| 305 const net::SSLInfo& ssl_info, | 302 const net::SSLInfo& ssl_info, |
| 306 bool fatal) { | 303 bool fatal) { |
| 307 ResourceRequestInfoImpl* info = GetRequestInfo(); | 304 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 308 | 305 |
| 309 int render_process_id; | 306 int render_process_id; |
| 310 int render_frame_id; | 307 int render_frame_id; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 } | 519 } |
| 523 | 520 |
| 524 // TODO(darin): Perhaps we should really be looking to see if the status is | 521 // TODO(darin): Perhaps we should really be looking to see if the status is |
| 525 // IO_PENDING? | 522 // IO_PENDING? |
| 526 bool was_pending = request_->is_pending(); | 523 bool was_pending = request_->is_pending(); |
| 527 | 524 |
| 528 if (login_delegate_.get()) { | 525 if (login_delegate_.get()) { |
| 529 login_delegate_->OnRequestCancelled(); | 526 login_delegate_->OnRequestCancelled(); |
| 530 login_delegate_ = NULL; | 527 login_delegate_ = NULL; |
| 531 } | 528 } |
| 532 if (ssl_client_auth_handler_.get()) { | 529 ssl_client_auth_handler_.reset(); |
| 533 ssl_client_auth_handler_->OnRequestCancelled(); | |
| 534 ssl_client_auth_handler_ = NULL; | |
| 535 } | |
| 536 | 530 |
| 537 request_->CancelWithError(error); | 531 request_->CancelWithError(error); |
| 538 | 532 |
| 539 if (!was_pending) { | 533 if (!was_pending) { |
| 540 // If the request isn't in flight, then we won't get an asynchronous | 534 // If the request isn't in flight, then we won't get an asynchronous |
| 541 // notification from the request, so we have to signal ourselves to finish | 535 // notification from the request, so we have to signal ourselves to finish |
| 542 // this request. | 536 // this request. |
| 543 base::MessageLoop::current()->PostTask( | 537 base::MessageLoop::current()->PostTask( |
| 544 FROM_HERE, | 538 FROM_HERE, |
| 545 base::Bind(&ResourceLoader::ResponseCompleted, | 539 base::Bind(&ResourceLoader::ResponseCompleted, |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 case net::URLRequestStatus::IO_PENDING: | 757 case net::URLRequestStatus::IO_PENDING: |
| 764 case net::URLRequestStatus::FAILED: | 758 case net::URLRequestStatus::FAILED: |
| 765 status = STATUS_UNDEFINED; | 759 status = STATUS_UNDEFINED; |
| 766 break; | 760 break; |
| 767 } | 761 } |
| 768 | 762 |
| 769 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); | 763 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); |
| 770 } | 764 } |
| 771 } | 765 } |
| 772 | 766 |
| 767 void ResourceLoader::ContinueWithCertificate(net::X509Certificate* cert) { |
| 768 ssl_client_auth_handler_.reset(); |
| 769 request_->ContinueWithCertificate(cert); |
| 770 } |
| 771 |
| 773 } // namespace content | 772 } // namespace content |
| OLD | NEW |