Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: content/browser/loader/resource_loader.cc

Issue 795773002: Un-refcount SSLClientAuthHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 void ResourceLoader::OnCertificateRequested( 280 void ResourceLoader::OnCertificateRequested(
282 net::URLRequest* unused, 281 net::URLRequest* unused,
283 net::SSLCertRequestInfo* cert_info) { 282 net::SSLCertRequestInfo* cert_info) {
284 DCHECK_EQ(request_.get(), unused); 283 DCHECK_EQ(request_.get(), unused);
285 284
286 if (request_->load_flags() & net::LOAD_PREFETCH) { 285 if (request_->load_flags() & net::LOAD_PREFETCH) {
287 request_->Cancel(); 286 request_->Cancel();
288 return; 287 return;
289 } 288 }
290 289
291 DCHECK(!ssl_client_auth_handler_.get()) 290 DCHECK(!ssl_client_auth_handler_)
292 << "OnCertificateRequested called with ssl_client_auth_handler pending"; 291 << "OnCertificateRequested called with ssl_client_auth_handler pending";
293 ssl_client_auth_handler_ = new SSLClientAuthHandler( 292 ssl_client_auth_handler_.reset(new SSLClientAuthHandler(
294 GetRequestInfo()->GetContext()->CreateClientCertStore(), 293 GetRequestInfo()->GetContext()->CreateClientCertStore(), request_.get(),
295 request_.get(), 294 cert_info, base::Bind(&ResourceLoader::ContinueWithCertificate,
296 cert_info, 295 weak_ptr_factory_.GetWeakPtr())));
297 base::Bind(&ResourceLoader::ContinueWithCertificate,
298 weak_ptr_factory_.GetWeakPtr()));
299 ssl_client_auth_handler_->SelectCertificate(); 296 ssl_client_auth_handler_->SelectCertificate();
300 } 297 }
301 298
302 void ResourceLoader::OnSSLCertificateError(net::URLRequest* request, 299 void ResourceLoader::OnSSLCertificateError(net::URLRequest* request,
303 const net::SSLInfo& ssl_info, 300 const net::SSLInfo& ssl_info,
304 bool fatal) { 301 bool fatal) {
305 ResourceRequestInfoImpl* info = GetRequestInfo(); 302 ResourceRequestInfoImpl* info = GetRequestInfo();
306 303
307 int render_process_id; 304 int render_process_id;
308 int render_frame_id; 305 int render_frame_id;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 558 }
562 559
563 // TODO(darin): Perhaps we should really be looking to see if the status is 560 // TODO(darin): Perhaps we should really be looking to see if the status is
564 // IO_PENDING? 561 // IO_PENDING?
565 bool was_pending = request_->is_pending(); 562 bool was_pending = request_->is_pending();
566 563
567 if (login_delegate_.get()) { 564 if (login_delegate_.get()) {
568 login_delegate_->OnRequestCancelled(); 565 login_delegate_->OnRequestCancelled();
569 login_delegate_ = NULL; 566 login_delegate_ = NULL;
570 } 567 }
571 if (ssl_client_auth_handler_.get()) { 568 ssl_client_auth_handler_.reset();
572 ssl_client_auth_handler_->OnRequestCancelled();
573 ssl_client_auth_handler_ = NULL;
574 }
575 569
576 request_->CancelWithError(error); 570 request_->CancelWithError(error);
577 571
578 if (!was_pending) { 572 if (!was_pending) {
579 // If the request isn't in flight, then we won't get an asynchronous 573 // If the request isn't in flight, then we won't get an asynchronous
580 // notification from the request, so we have to signal ourselves to finish 574 // notification from the request, so we have to signal ourselves to finish
581 // this request. 575 // this request.
582 base::MessageLoop::current()->PostTask( 576 base::MessageLoop::current()->PostTask(
583 FROM_HERE, 577 FROM_HERE,
584 base::Bind(&ResourceLoader::ResponseCompleted, 578 base::Bind(&ResourceLoader::ResponseCompleted,
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 case net::URLRequestStatus::FAILED: 825 case net::URLRequestStatus::FAILED:
832 status = STATUS_UNDEFINED; 826 status = STATUS_UNDEFINED;
833 break; 827 break;
834 } 828 }
835 829
836 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); 830 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX);
837 } 831 }
838 } 832 }
839 833
840 void ResourceLoader::ContinueWithCertificate(net::X509Certificate* cert) { 834 void ResourceLoader::ContinueWithCertificate(net::X509Certificate* cert) {
841 ssl_client_auth_handler_ = NULL; 835 ssl_client_auth_handler_.reset();
842 request_->ContinueWithCertificate(cert); 836 request_->ContinueWithCertificate(cert);
843 } 837 }
844 838
845 } // namespace content 839 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698