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

Unified Diff: ios/components/io_thread/ios_io_thread.mm

Issue 2946533002: Make iOS's IOThread class use URLRequestContextBuilder.
Patch Set: Minor fix, more needed Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/components/io_thread/ios_io_thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/components/io_thread/ios_io_thread.mm
diff --git a/ios/components/io_thread/ios_io_thread.mm b/ios/components/io_thread/ios_io_thread.mm
index ababca51c1f515fa04f0cde2f15d6b7d5929900c..a910340048f6b93439773eb0b5072adff874143f 100644
--- a/ios/components/io_thread/ios_io_thread.mm
+++ b/ios/components/io_thread/ios_io_thread.mm
@@ -37,39 +37,18 @@
#include "ios/web/public/user_agent.h"
#include "ios/web/public/web_client.h"
#include "ios/web/public/web_thread.h"
-#include "net/base/sdch_manager.h"
-#include "net/cert/cert_verifier.h"
#include "net/cert/ct_known_logs.h"
#include "net/cert/ct_log_verifier.h"
-#include "net/cert/ct_policy_enforcer.h"
#include "net/cert/ct_verifier.h"
#include "net/cert/multi_log_ct_verifier.h"
#include "net/cert/multi_threaded_cert_verifier.h"
-#include "net/cookies/cookie_monster.h"
-#include "net/cookies/cookie_store.h"
-#include "net/dns/host_cache.h"
-#include "net/dns/host_resolver.h"
-#include "net/http/http_auth_filter.h"
-#include "net/http/http_auth_handler_factory.h"
-#include "net/http/http_auth_preferences.h"
-#include "net/http/http_network_layer.h"
-#include "net/http/http_server_properties_impl.h"
#include "net/log/net_log_event_type.h"
#include "net/proxy/proxy_config_service.h"
-#include "net/proxy/proxy_script_fetcher_impl.h"
-#include "net/proxy/proxy_service.h"
#include "net/socket/tcp_client_socket.h"
-#include "net/spdy/chromium/spdy_session.h"
-#include "net/ssl/channel_id_service.h"
#include "net/ssl/default_channel_id_store.h"
-#include "net/url_request/data_protocol_handler.h"
-#include "net/url_request/file_protocol_handler.h"
-#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_context_getter.h"
-#include "net/url_request/url_request_job_factory_impl.h"
-#include "url/url_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
@@ -80,12 +59,6 @@
namespace io_thread {
-namespace {
-
-const char kSupportedAuthSchemes[] = "basic,digest,ntlm";
-
-} // namespace
-
// Used for the "system" URLRequestContext.
class SystemURLRequestContext : public net::URLRequestContext {
public:
@@ -312,37 +285,24 @@ void IOSIOThread::Init() {
// Setup the HistogramWatcher to run on the IO thread.
net::NetworkChangeNotifier::InitHistogramWatcher();
- globals_->system_network_delegate = CreateSystemNetworkDelegate();
- globals_->host_resolver = CreateGlobalHostResolver(net_log_);
-
- globals_->cert_verifier = net::CertVerifier::CreateDefault();
-
- globals_->transport_security_state.reset(new net::TransportSecurityState());
+ net::URLrequestContextBuilder builder;
+ builder.set_net_log(net_log_);
+ builder.set_network_delegate(CreateSystemNetworkDelegate());
std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs(
net::ct::CreateLogVerifiersForKnownLogs());
- net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier();
- globals_->cert_transparency_verifier.reset(ct_verifier);
+ std::unique_ptr<net::MultiLogCTVerifier> ct_verifier(
+ base::MakeUnique<net::MultiLogCTVerifier>());
// Add built-in logs
ct_verifier->AddLogs(ct_logs);
+ builder.set_ct_verifier(std::move(ct_verfier));
- globals_->ct_policy_enforcer.reset(new net::CTPolicyEnforcer());
+ builder.set_ssl_config_service(
+ base::scoped_refptr<net::SSLConfigService>(GetSSLConfigService()));
- globals_->ssl_config_service = GetSSLConfigService();
-
- CreateDefaultAuthHandlerFactory();
- globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl());
- // In-memory cookie store.
- globals_->system_cookie_store.reset(new net::CookieMonster(nullptr, nullptr));
- // In-memory channel ID store.
- globals_->system_channel_id_service.reset(
- new net::ChannelIDService(new net::DefaultChannelIDStore(nullptr)));
- globals_->system_cookie_store->SetChannelIDServiceID(
- globals_->system_channel_id_service->GetUniqueID());
- globals_->http_user_agent_settings.reset(new net::StaticHttpUserAgentSettings(
- std::string(),
- web::GetWebClient()->GetUserAgent(web::UserAgentType::MOBILE)));
+ builder.set_user_agent(
+ web::GetWebClient()->GetUserAgent(web::UserAgentType::MOBILE));
params_.ignore_certificate_errors = false;
params_.enable_user_alternate_protocol_ports = false;
@@ -359,13 +319,11 @@ void IOSIOThread::Init() {
network_session_configurator::ParseCommandLineAndFieldTrials(
base::CommandLine(base::CommandLine::NO_PROGRAM),
/*is_quic_force_disabled=*/false, quic_user_agent_id, &params_);
+ builder.set_http_network_session_params(params_);
- globals_->system_proxy_service = ProxyServiceFactory::CreateProxyService(
- net_log_, nullptr, globals_->system_network_delegate.get(),
- std::move(system_proxy_config_service_), true /* quick_check_enabled */);
+ builder.set_data_enabled(true);
- globals_->system_request_context.reset(
- ConstructSystemRequestContext(globals_, params_, net_log_));
+ globals_->system_request_context = builder.build();
}
void IOSIOThread::CleanUp() {
@@ -429,54 +387,4 @@ void IOSIOThread::ChangedToOnTheRecordOnIOThread() {
ClearHostCache();
}
-net::URLRequestContext* IOSIOThread::ConstructSystemRequestContext(
- IOSIOThread::Globals* globals,
- const net::HttpNetworkSession::Params& params,
- net::NetLog* net_log) {
- net::URLRequestContext* context = new SystemURLRequestContext;
- context->set_net_log(net_log);
- context->set_host_resolver(globals->host_resolver.get());
- context->set_cert_verifier(globals->cert_verifier.get());
- context->set_transport_security_state(
- globals->transport_security_state.get());
- context->set_cert_transparency_verifier(
- globals->cert_transparency_verifier.get());
- context->set_ssl_config_service(globals->ssl_config_service.get());
- context->set_http_auth_handler_factory(
- globals->http_auth_handler_factory.get());
- context->set_proxy_service(globals->system_proxy_service.get());
- context->set_ct_policy_enforcer(globals->ct_policy_enforcer.get());
-
- net::URLRequestJobFactoryImpl* system_job_factory =
- new net::URLRequestJobFactoryImpl();
- // Data URLs are always loaded through the system request context on iOS
- // (due to UIWebView limitations).
- bool set_protocol = system_job_factory->SetProtocolHandler(
- url::kDataScheme, base::MakeUnique<net::DataProtocolHandler>());
- DCHECK(set_protocol);
- globals->system_url_request_job_factory.reset(system_job_factory);
- context->set_job_factory(globals->system_url_request_job_factory.get());
-
- context->set_cookie_store(globals->system_cookie_store.get());
- context->set_channel_id_service(globals->system_channel_id_service.get());
- context->set_network_delegate(globals->system_network_delegate.get());
- context->set_http_user_agent_settings(
- globals->http_user_agent_settings.get());
-
- context->set_http_server_properties(globals->http_server_properties.get());
-
- net::HttpNetworkSession::Context system_context;
- net::URLRequestContextBuilder::SetHttpNetworkSessionComponents(
- context, &system_context);
-
- globals->system_http_network_session.reset(
- new net::HttpNetworkSession(params, system_context));
- globals->system_http_transaction_factory.reset(
- new net::HttpNetworkLayer(globals->system_http_network_session.get()));
- context->set_http_transaction_factory(
- globals->system_http_transaction_factory.get());
-
- return context;
-}
-
} // namespace io_thread
« no previous file with comments | « ios/components/io_thread/ios_io_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698