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

Side by Side Diff: chrome/browser/profiles/profile_io_data.cc

Issue 516453002: Fix leak of MultiThreadedCertVerifier in ProfileIOData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarified comment. Created 6 years, 3 months 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
« no previous file with comments | « chrome/browser/profiles/profile_io_data.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/profiles/profile_io_data.h" 5 #include "chrome/browser/profiles/profile_io_data.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 #include "chrome/browser/chromeos/profiles/profile_helper.h" 117 #include "chrome/browser/chromeos/profiles/profile_helper.h"
118 #include "chrome/browser/chromeos/settings/cros_settings.h" 118 #include "chrome/browser/chromeos/settings/cros_settings.h"
119 #include "chrome/browser/net/nss_context.h" 119 #include "chrome/browser/net/nss_context.h"
120 #include "chromeos/dbus/cryptohome_client.h" 120 #include "chromeos/dbus/cryptohome_client.h"
121 #include "chromeos/dbus/dbus_thread_manager.h" 121 #include "chromeos/dbus/dbus_thread_manager.h"
122 #include "chromeos/settings/cros_settings_names.h" 122 #include "chromeos/settings/cros_settings_names.h"
123 #include "components/user_manager/user.h" 123 #include "components/user_manager/user.h"
124 #include "components/user_manager/user_manager.h" 124 #include "components/user_manager/user_manager.h"
125 #include "crypto/nss_util.h" 125 #include "crypto/nss_util.h"
126 #include "crypto/nss_util_internal.h" 126 #include "crypto/nss_util_internal.h"
127 #include "net/cert/cert_verifier.h"
127 #include "net/cert/multi_threaded_cert_verifier.h" 128 #include "net/cert/multi_threaded_cert_verifier.h"
128 #include "net/ssl/client_cert_store_chromeos.h" 129 #include "net/ssl/client_cert_store_chromeos.h"
129 #endif // defined(OS_CHROMEOS) 130 #endif // defined(OS_CHROMEOS)
130 131
131 #if defined(USE_NSS) 132 #if defined(USE_NSS)
132 #include "chrome/browser/ui/crypto_module_delegate_nss.h" 133 #include "chrome/browser/ui/crypto_module_delegate_nss.h"
133 #include "net/ssl/client_cert_store_nss.h" 134 #include "net/ssl/client_cert_store_nss.h"
134 #endif 135 #endif
135 136
136 #if defined(OS_WIN) 137 #if defined(OS_WIN)
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 network_prediction_enabled_.Init(prefs::kNetworkPredictionEnabled, 469 network_prediction_enabled_.Init(prefs::kNetworkPredictionEnabled,
469 pref_service); 470 pref_service);
470 network_prediction_enabled_.MoveToThread(io_message_loop_proxy); 471 network_prediction_enabled_.MoveToThread(io_message_loop_proxy);
471 472
472 network_prediction_options_.Init(prefs::kNetworkPredictionOptions, 473 network_prediction_options_.Init(prefs::kNetworkPredictionOptions,
473 pref_service); 474 pref_service);
474 475
475 network_prediction_options_.MoveToThread(io_message_loop_proxy); 476 network_prediction_options_.MoveToThread(io_message_loop_proxy);
476 477
477 #if defined(OS_CHROMEOS) 478 #if defined(OS_CHROMEOS)
478 cert_verifier_ = policy::PolicyCertServiceFactory::CreateForProfile(profile); 479 scoped_ptr<policy::PolicyCertVerifier> verifier =
480 policy::PolicyCertServiceFactory::CreateForProfile(profile);
481 policy_cert_verifier_ = verifier.get();
482 cert_verifier_ = verifier.Pass();
479 #endif 483 #endif
480 // The URLBlacklistManager has to be created on the UI thread to register 484 // The URLBlacklistManager has to be created on the UI thread to register
481 // observers of |pref_service|, and it also has to clean up on 485 // observers of |pref_service|, and it also has to clean up on
482 // ShutdownOnUIThread to release these observers on the right thread. 486 // ShutdownOnUIThread to release these observers on the right thread.
483 // Don't pass it in |profile_params_| to make sure it is correctly cleaned up, 487 // Don't pass it in |profile_params_| to make sure it is correctly cleaned up,
484 // in particular when this ProfileIOData isn't |initialized_| during deletion. 488 // in particular when this ProfileIOData isn't |initialized_| during deletion.
485 #if defined(ENABLE_CONFIGURATION_POLICY) 489 #if defined(ENABLE_CONFIGURATION_POLICY)
486 policy::URLBlacklist::SegmentURLCallback callback = 490 policy::URLBlacklist::SegmentURLCallback callback =
487 static_cast<policy::URLBlacklist::SegmentURLCallback>( 491 static_cast<policy::URLBlacklist::SegmentURLCallback>(
488 url_fixer::SegmentURL); 492 url_fixer::SegmentURL);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 use_system_key_slot(false), 568 use_system_key_slot(false),
565 #endif 569 #endif
566 profile(NULL) { 570 profile(NULL) {
567 } 571 }
568 572
569 ProfileIOData::ProfileParams::~ProfileParams() {} 573 ProfileIOData::ProfileParams::~ProfileParams() {}
570 574
571 ProfileIOData::ProfileIOData(Profile::ProfileType profile_type) 575 ProfileIOData::ProfileIOData(Profile::ProfileType profile_type)
572 : initialized_(false), 576 : initialized_(false),
573 #if defined(OS_CHROMEOS) 577 #if defined(OS_CHROMEOS)
578 policy_cert_verifier_(NULL),
574 use_system_key_slot_(false), 579 use_system_key_slot_(false),
575 #endif 580 #endif
576 resource_context_(new ResourceContext(this)), 581 resource_context_(new ResourceContext(this)),
577 initialized_on_UI_thread_(false), 582 initialized_on_UI_thread_(false),
578 profile_type_(profile_type) { 583 profile_type_(profile_type) {
579 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 584 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
580 } 585 }
581 586
582 ProfileIOData::~ProfileIOData() { 587 ProfileIOData::~ProfileIOData() {
583 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) 588 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO))
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 #if defined(ENABLE_MANAGED_USERS) 1079 #if defined(ENABLE_MANAGED_USERS)
1075 supervised_user_url_filter_ = profile_params_->supervised_user_url_filter; 1080 supervised_user_url_filter_ = profile_params_->supervised_user_url_filter;
1076 #endif 1081 #endif
1077 1082
1078 #if defined(OS_CHROMEOS) 1083 #if defined(OS_CHROMEOS)
1079 username_hash_ = profile_params_->username_hash; 1084 username_hash_ = profile_params_->username_hash;
1080 use_system_key_slot_ = profile_params_->use_system_key_slot; 1085 use_system_key_slot_ = profile_params_->use_system_key_slot;
1081 if (use_system_key_slot_) 1086 if (use_system_key_slot_)
1082 EnableNSSSystemKeySlotForResourceContext(resource_context_.get()); 1087 EnableNSSSystemKeySlotForResourceContext(resource_context_.get());
1083 1088
1084 scoped_refptr<net::CertVerifyProc> verify_proc;
1085 crypto::ScopedPK11Slot public_slot = 1089 crypto::ScopedPK11Slot public_slot =
1086 crypto::GetPublicSlotForChromeOSUser(username_hash_); 1090 crypto::GetPublicSlotForChromeOSUser(username_hash_);
1087 // The private slot won't be ready by this point. It shouldn't be necessary 1091 // The private slot won't be ready by this point. It shouldn't be necessary
1088 // for cert trust purposes anyway. 1092 // for cert trust purposes anyway.
1089 verify_proc = new chromeos::CertVerifyProcChromeOS(public_slot.Pass()); 1093 scoped_refptr<net::CertVerifyProc> verify_proc(
1090 if (cert_verifier_) { 1094 new chromeos::CertVerifyProcChromeOS(public_slot.Pass()));
1091 cert_verifier_->InitializeOnIOThread(verify_proc); 1095 if (policy_cert_verifier_) {
1092 main_request_context_->set_cert_verifier(cert_verifier_.get()); 1096 DCHECK_EQ(policy_cert_verifier_, cert_verifier_.get());
1097 policy_cert_verifier_->InitializeOnIOThread(verify_proc);
1093 } else { 1098 } else {
1094 main_request_context_->set_cert_verifier( 1099 cert_verifier_.reset(new net::MultiThreadedCertVerifier(verify_proc.get()));
1095 new net::MultiThreadedCertVerifier(verify_proc.get()));
1096 } 1100 }
1101 main_request_context_->set_cert_verifier(cert_verifier_.get());
1097 #else 1102 #else
1098 main_request_context_->set_cert_verifier( 1103 main_request_context_->set_cert_verifier(
1099 io_thread_globals->cert_verifier.get()); 1104 io_thread_globals->cert_verifier.get());
1100 #endif 1105 #endif
1101 1106
1102 InitializeInternal( 1107 InitializeInternal(
1103 profile_params_.get(), protocol_handlers, request_interceptors.Pass()); 1108 profile_params_.get(), protocol_handlers, request_interceptors.Pass());
1104 1109
1105 profile_params_.reset(); 1110 profile_params_.reset();
1106 initialized_ = true; 1111 initialized_ = true;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 void ProfileIOData::SetCookieSettingsForTesting( 1300 void ProfileIOData::SetCookieSettingsForTesting(
1296 CookieSettings* cookie_settings) { 1301 CookieSettings* cookie_settings) {
1297 DCHECK(!cookie_settings_.get()); 1302 DCHECK(!cookie_settings_.get());
1298 cookie_settings_ = cookie_settings; 1303 cookie_settings_ = cookie_settings;
1299 } 1304 }
1300 1305
1301 void ProfileIOData::set_signin_names_for_testing( 1306 void ProfileIOData::set_signin_names_for_testing(
1302 SigninNamesOnIOThread* signin_names) { 1307 SigninNamesOnIOThread* signin_names) {
1303 signin_names_.reset(signin_names); 1308 signin_names_.reset(signin_names);
1304 } 1309 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_io_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698