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

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: mmenke comments 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 void ResourceLoader::OnCertificateRequested( 299 void ResourceLoader::OnCertificateRequested(
301 net::URLRequest* unused, 300 net::URLRequest* unused,
302 net::SSLCertRequestInfo* cert_info) { 301 net::SSLCertRequestInfo* cert_info) {
303 DCHECK_EQ(request_.get(), unused); 302 DCHECK_EQ(request_.get(), unused);
304 303
305 if (request_->load_flags() & net::LOAD_PREFETCH) { 304 if (request_->load_flags() & net::LOAD_PREFETCH) {
306 request_->Cancel(); 305 request_->Cancel();
307 return; 306 return;
308 } 307 }
309 308
310 DCHECK(!ssl_client_auth_handler_.get()) 309 DCHECK(!ssl_client_auth_handler_)
311 << "OnCertificateRequested called with ssl_client_auth_handler pending"; 310 << "OnCertificateRequested called with ssl_client_auth_handler pending";
312 ssl_client_auth_handler_ = new SSLClientAuthHandler( 311 ssl_client_auth_handler_.reset(new SSLClientAuthHandler(
313 GetRequestInfo()->GetContext()->CreateClientCertStore(), 312 GetRequestInfo()->GetContext()->CreateClientCertStore(), request_.get(),
314 request_.get(), 313 cert_info, base::Bind(&ResourceLoader::ContinueWithCertificate,
315 cert_info, 314 weak_ptr_factory_.GetWeakPtr())));
316 base::Bind(&ResourceLoader::ContinueWithCertificate,
317 weak_ptr_factory_.GetWeakPtr()));
318 ssl_client_auth_handler_->SelectCertificate(); 315 ssl_client_auth_handler_->SelectCertificate();
319 } 316 }
320 317
321 void ResourceLoader::OnSSLCertificateError(net::URLRequest* request, 318 void ResourceLoader::OnSSLCertificateError(net::URLRequest* request,
322 const net::SSLInfo& ssl_info, 319 const net::SSLInfo& ssl_info,
323 bool fatal) { 320 bool fatal) {
324 ResourceRequestInfoImpl* info = GetRequestInfo(); 321 ResourceRequestInfoImpl* info = GetRequestInfo();
325 322
326 int render_process_id; 323 int render_process_id;
327 int render_frame_id; 324 int render_frame_id;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 } 577 }
581 578
582 // TODO(darin): Perhaps we should really be looking to see if the status is 579 // TODO(darin): Perhaps we should really be looking to see if the status is
583 // IO_PENDING? 580 // IO_PENDING?
584 bool was_pending = request_->is_pending(); 581 bool was_pending = request_->is_pending();
585 582
586 if (login_delegate_.get()) { 583 if (login_delegate_.get()) {
587 login_delegate_->OnRequestCancelled(); 584 login_delegate_->OnRequestCancelled();
588 login_delegate_ = NULL; 585 login_delegate_ = NULL;
589 } 586 }
590 if (ssl_client_auth_handler_.get()) { 587 ssl_client_auth_handler_.reset();
591 ssl_client_auth_handler_->OnRequestCancelled();
592 ssl_client_auth_handler_ = NULL;
593 }
594 588
595 request_->CancelWithError(error); 589 request_->CancelWithError(error);
596 590
597 if (!was_pending) { 591 if (!was_pending) {
598 // If the request isn't in flight, then we won't get an asynchronous 592 // If the request isn't in flight, then we won't get an asynchronous
599 // notification from the request, so we have to signal ourselves to finish 593 // notification from the request, so we have to signal ourselves to finish
600 // this request. 594 // this request.
601 base::MessageLoop::current()->PostTask( 595 base::MessageLoop::current()->PostTask(
602 FROM_HERE, 596 FROM_HERE,
603 base::Bind(&ResourceLoader::ResponseCompleted, 597 base::Bind(&ResourceLoader::ResponseCompleted,
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 case net::URLRequestStatus::FAILED: 844 case net::URLRequestStatus::FAILED:
851 status = STATUS_UNDEFINED; 845 status = STATUS_UNDEFINED;
852 break; 846 break;
853 } 847 }
854 848
855 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); 849 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX);
856 } 850 }
857 } 851 }
858 852
859 void ResourceLoader::ContinueWithCertificate(net::X509Certificate* cert) { 853 void ResourceLoader::ContinueWithCertificate(net::X509Certificate* cert) {
860 ssl_client_auth_handler_ = NULL; 854 ssl_client_auth_handler_.reset();
pneubeck (no reviews) 2014/12/14 16:45:12 please don't do this in a call stack containing ss
davidben 2015/01/23 21:05:35 Made it a DeleteSoon.
861 request_->ContinueWithCertificate(cert); 855 request_->ContinueWithCertificate(cert);
862 } 856 }
863 857
864 } // namespace content 858 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698