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

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

Issue 2334613003: Re-write many calls to WrapUnique() with MakeUnique() (Closed)
Patch Set: Changes from review by sky Created 4 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 return nullptr; 923 return nullptr;
924 } 924 }
925 925
926 std::unique_ptr<net::ClientCertStore> ProfileIOData::CreateClientCertStore() { 926 std::unique_ptr<net::ClientCertStore> ProfileIOData::CreateClientCertStore() {
927 if (!client_cert_store_factory_.is_null()) 927 if (!client_cert_store_factory_.is_null())
928 return client_cert_store_factory_.Run(); 928 return client_cert_store_factory_.Run();
929 #if defined(OS_CHROMEOS) 929 #if defined(OS_CHROMEOS)
930 return std::unique_ptr<net::ClientCertStore>( 930 return std::unique_ptr<net::ClientCertStore>(
931 new chromeos::ClientCertStoreChromeOS( 931 new chromeos::ClientCertStoreChromeOS(
932 certificate_provider_ ? certificate_provider_->Copy() : nullptr, 932 certificate_provider_ ? certificate_provider_->Copy() : nullptr,
933 base::WrapUnique(new chromeos::ClientCertFilterChromeOS( 933 base::MakeUnique<chromeos::ClientCertFilterChromeOS>(
934 use_system_key_slot_, username_hash_)), 934 use_system_key_slot_, username_hash_),
935 base::Bind(&CreateCryptoModuleBlockingPasswordDelegate, 935 base::Bind(&CreateCryptoModuleBlockingPasswordDelegate,
936 chrome::kCryptoModulePasswordClientAuth))); 936 chrome::kCryptoModulePasswordClientAuth)));
937 #elif defined(USE_NSS_CERTS) 937 #elif defined(USE_NSS_CERTS)
938 return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS( 938 return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS(
939 base::Bind(&CreateCryptoModuleBlockingPasswordDelegate, 939 base::Bind(&CreateCryptoModuleBlockingPasswordDelegate,
940 chrome::kCryptoModulePasswordClientAuth))); 940 chrome::kCryptoModulePasswordClientAuth)));
941 #elif defined(OS_WIN) 941 #elif defined(OS_WIN)
942 return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreWin()); 942 return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreWin());
943 #elif defined(OS_MACOSX) 943 #elif defined(OS_MACOSX)
944 return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreMac()); 944 return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreMac());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 got_delegate_callback = 1007 got_delegate_callback =
1008 base::Bind(&InitializeAndPassKeygenHandler, 1008 base::Bind(&InitializeAndPassKeygenHandler,
1009 base::Passed(&keygen_handler), callback); 1009 base::Passed(&keygen_handler), callback);
1010 1010
1011 ChromeNSSCryptoModuleDelegate::CreateForResourceContext( 1011 ChromeNSSCryptoModuleDelegate::CreateForResourceContext(
1012 chrome::kCryptoModulePasswordKeygen, 1012 chrome::kCryptoModulePasswordKeygen,
1013 net::HostPortPair::FromURL(url), 1013 net::HostPortPair::FromURL(url),
1014 this, 1014 this,
1015 got_delegate_callback); 1015 got_delegate_callback);
1016 #else 1016 #else
1017 callback.Run(base::WrapUnique( 1017 callback.Run(base::MakeUnique<net::KeygenHandler>(key_size_in_bits,
1018 new net::KeygenHandler(key_size_in_bits, challenge_string, url))); 1018 challenge_string, url));
1019 #endif 1019 #endif
1020 } 1020 }
1021 1021
1022 std::string ProfileIOData::ResourceContext::GetMediaDeviceIDSalt() { 1022 std::string ProfileIOData::ResourceContext::GetMediaDeviceIDSalt() {
1023 if (io_data_->HasMediaDeviceIDSalt()) 1023 if (io_data_->HasMediaDeviceIDSalt())
1024 return io_data_->GetMediaDeviceIDSalt(); 1024 return io_data_->GetMediaDeviceIDSalt();
1025 1025
1026 return content::ResourceContext::GetMediaDeviceIDSalt(); 1026 return content::ResourceContext::GetMediaDeviceIDSalt();
1027 } 1027 }
1028 1028
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory, 1203 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory,
1204 content::URLRequestInterceptorScopedVector request_interceptors, 1204 content::URLRequestInterceptorScopedVector request_interceptors,
1205 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 1205 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
1206 protocol_handler_interceptor, 1206 protocol_handler_interceptor,
1207 net::NetworkDelegate* network_delegate, 1207 net::NetworkDelegate* network_delegate,
1208 net::FtpTransactionFactory* ftp_transaction_factory) const { 1208 net::FtpTransactionFactory* ftp_transaction_factory) const {
1209 // NOTE(willchan): Keep these protocol handlers in sync with 1209 // NOTE(willchan): Keep these protocol handlers in sync with
1210 // ProfileIOData::IsHandledProtocol(). 1210 // ProfileIOData::IsHandledProtocol().
1211 bool set_protocol = job_factory->SetProtocolHandler( 1211 bool set_protocol = job_factory->SetProtocolHandler(
1212 url::kFileScheme, 1212 url::kFileScheme,
1213 base::WrapUnique(new net::FileProtocolHandler( 1213 base::MakeUnique<net::FileProtocolHandler>(
1214 content::BrowserThread::GetBlockingPool() 1214 content::BrowserThread::GetBlockingPool()
1215 ->GetTaskRunnerWithShutdownBehavior( 1215 ->GetTaskRunnerWithShutdownBehavior(
1216 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)))); 1216 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
1217 DCHECK(set_protocol); 1217 DCHECK(set_protocol);
1218 1218
1219 #if defined(ENABLE_EXTENSIONS) 1219 #if defined(ENABLE_EXTENSIONS)
1220 DCHECK(extension_info_map_.get()); 1220 DCHECK(extension_info_map_.get());
1221 // Check only for incognito (and not Chrome OS guest mode GUEST_PROFILE). 1221 // Check only for incognito (and not Chrome OS guest mode GUEST_PROFILE).
1222 bool is_incognito = profile_type() == Profile::INCOGNITO_PROFILE; 1222 bool is_incognito = profile_type() == Profile::INCOGNITO_PROFILE;
1223 set_protocol = job_factory->SetProtocolHandler( 1223 set_protocol = job_factory->SetProtocolHandler(
1224 extensions::kExtensionScheme, 1224 extensions::kExtensionScheme,
1225 extensions::CreateExtensionProtocolHandler(is_incognito, 1225 extensions::CreateExtensionProtocolHandler(is_incognito,
1226 extension_info_map_.get())); 1226 extension_info_map_.get()));
1227 DCHECK(set_protocol); 1227 DCHECK(set_protocol);
1228 set_protocol = job_factory->SetProtocolHandler( 1228 set_protocol = job_factory->SetProtocolHandler(
1229 extensions::kExtensionResourceScheme, 1229 extensions::kExtensionResourceScheme,
1230 CreateExtensionResourceProtocolHandler()); 1230 CreateExtensionResourceProtocolHandler());
1231 DCHECK(set_protocol); 1231 DCHECK(set_protocol);
1232 #endif 1232 #endif
1233 set_protocol = job_factory->SetProtocolHandler( 1233 set_protocol = job_factory->SetProtocolHandler(
1234 url::kDataScheme, base::WrapUnique(new net::DataProtocolHandler())); 1234 url::kDataScheme, base::MakeUnique<net::DataProtocolHandler>());
1235 DCHECK(set_protocol); 1235 DCHECK(set_protocol);
1236 #if defined(OS_CHROMEOS) 1236 #if defined(OS_CHROMEOS)
1237 if (profile_params_) { 1237 if (profile_params_) {
1238 set_protocol = job_factory->SetProtocolHandler( 1238 set_protocol = job_factory->SetProtocolHandler(
1239 content::kExternalFileScheme, 1239 content::kExternalFileScheme,
1240 base::WrapUnique(new chromeos::ExternalFileProtocolHandler( 1240 base::MakeUnique<chromeos::ExternalFileProtocolHandler>(
1241 profile_params_->profile))); 1241 profile_params_->profile));
1242 DCHECK(set_protocol); 1242 DCHECK(set_protocol);
1243 } 1243 }
1244 #endif // defined(OS_CHROMEOS) 1244 #endif // defined(OS_CHROMEOS)
1245 #if defined(OS_ANDROID) 1245 #if defined(OS_ANDROID)
1246 set_protocol = job_factory->SetProtocolHandler( 1246 set_protocol = job_factory->SetProtocolHandler(
1247 url::kContentScheme, 1247 url::kContentScheme,
1248 content::ContentProtocolHandler::Create( 1248 content::ContentProtocolHandler::Create(
1249 content::BrowserThread::GetBlockingPool() 1249 content::BrowserThread::GetBlockingPool()
1250 ->GetTaskRunnerWithShutdownBehavior( 1250 ->GetTaskRunnerWithShutdownBehavior(
1251 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); 1251 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
1252 #endif 1252 #endif
1253 1253
1254 job_factory->SetProtocolHandler( 1254 job_factory->SetProtocolHandler(
1255 url::kAboutScheme, 1255 url::kAboutScheme,
1256 base::WrapUnique(new about_handler::AboutProtocolHandler())); 1256 base::MakeUnique<about_handler::AboutProtocolHandler>());
1257 #if !defined(DISABLE_FTP_SUPPORT) 1257 #if !defined(DISABLE_FTP_SUPPORT)
1258 DCHECK(ftp_transaction_factory); 1258 DCHECK(ftp_transaction_factory);
1259 job_factory->SetProtocolHandler( 1259 job_factory->SetProtocolHandler(
1260 url::kFtpScheme, 1260 url::kFtpScheme,
1261 base::WrapUnique(new net::FtpProtocolHandler(ftp_transaction_factory))); 1261 base::MakeUnique<net::FtpProtocolHandler>(ftp_transaction_factory));
1262 #endif // !defined(DISABLE_FTP_SUPPORT) 1262 #endif // !defined(DISABLE_FTP_SUPPORT)
1263 1263
1264 #if defined(DEBUG_DEVTOOLS) 1264 #if defined(DEBUG_DEVTOOLS)
1265 request_interceptors.push_back(new DebugDevToolsInterceptor); 1265 request_interceptors.push_back(new DebugDevToolsInterceptor);
1266 #endif 1266 #endif
1267 1267
1268 // Set up interceptors in the reverse order. 1268 // Set up interceptors in the reverse order.
1269 std::unique_ptr<net::URLRequestJobFactory> top_job_factory = 1269 std::unique_ptr<net::URLRequestJobFactory> top_job_factory =
1270 std::move(job_factory); 1270 std::move(job_factory);
1271 for (content::URLRequestInterceptorScopedVector::reverse_iterator i = 1271 for (content::URLRequestInterceptorScopedVector::reverse_iterator i =
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 if (data_reduction_proxy_io_data_.get()) 1358 if (data_reduction_proxy_io_data_.get())
1359 params.proxy_delegate = data_reduction_proxy_io_data_->proxy_delegate(); 1359 params.proxy_delegate = data_reduction_proxy_io_data_->proxy_delegate();
1360 1360
1361 return std::unique_ptr<net::HttpNetworkSession>( 1361 return std::unique_ptr<net::HttpNetworkSession>(
1362 new net::HttpNetworkSession(params)); 1362 new net::HttpNetworkSession(params));
1363 } 1363 }
1364 1364
1365 std::unique_ptr<net::HttpCache> ProfileIOData::CreateMainHttpFactory( 1365 std::unique_ptr<net::HttpCache> ProfileIOData::CreateMainHttpFactory(
1366 net::HttpNetworkSession* session, 1366 net::HttpNetworkSession* session,
1367 std::unique_ptr<net::HttpCache::BackendFactory> main_backend) const { 1367 std::unique_ptr<net::HttpCache::BackendFactory> main_backend) const {
1368 return base::WrapUnique(new net::HttpCache( 1368 return base::MakeUnique<net::HttpCache>(
1369 base::WrapUnique(new DevToolsNetworkTransactionFactory( 1369 base::WrapUnique(new DevToolsNetworkTransactionFactory(
1370 network_controller_handle_.GetController(), session)), 1370 network_controller_handle_.GetController(), session)),
1371 std::move(main_backend), true /* set_up_quic_server_info */)); 1371 std::move(main_backend), true /* set_up_quic_server_info */);
1372 } 1372 }
1373 1373
1374 std::unique_ptr<net::HttpCache> ProfileIOData::CreateHttpFactory( 1374 std::unique_ptr<net::HttpCache> ProfileIOData::CreateHttpFactory(
1375 net::HttpNetworkSession* shared_session, 1375 net::HttpNetworkSession* shared_session,
1376 std::unique_ptr<net::HttpCache::BackendFactory> backend) const { 1376 std::unique_ptr<net::HttpCache::BackendFactory> backend) const {
1377 return base::WrapUnique(new net::HttpCache( 1377 return base::MakeUnique<net::HttpCache>(
1378 base::WrapUnique(new DevToolsNetworkTransactionFactory( 1378 base::WrapUnique(new DevToolsNetworkTransactionFactory(
1379 network_controller_handle_.GetController(), shared_session)), 1379 network_controller_handle_.GetController(), shared_session)),
1380 std::move(backend), true /* set_up_quic_server_info */)); 1380 std::move(backend), true /* set_up_quic_server_info */);
1381 } 1381 }
1382 1382
1383 void ProfileIOData::SetCookieSettingsForTesting( 1383 void ProfileIOData::SetCookieSettingsForTesting(
1384 content_settings::CookieSettings* cookie_settings) { 1384 content_settings::CookieSettings* cookie_settings) {
1385 DCHECK(!cookie_settings_.get()); 1385 DCHECK(!cookie_settings_.get());
1386 cookie_settings_ = cookie_settings; 1386 cookie_settings_ = cookie_settings;
1387 } 1387 }
1388 1388
1389 policy::URLBlacklist::URLBlacklistState ProfileIOData::GetURLBlacklistState( 1389 policy::URLBlacklist::URLBlacklistState ProfileIOData::GetURLBlacklistState(
1390 const GURL& url) const { 1390 const GURL& url) const {
1391 return url_blacklist_manager_->GetURLBlacklistState(url); 1391 return url_blacklist_manager_->GetURLBlacklistState(url);
1392 } 1392 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.cc ('k') | chrome/browser/profiles/profile_statistics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698