| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/cronet/ios/cronet_environment.h" | 5 #include "components/cronet/ios/cronet_environment.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 quic_hints_.push_back(net::HostPortPair(host, port)); | 214 quic_hints_.push_back(net::HostPortPair(host, port)); |
| 215 } | 215 } |
| 216 | 216 |
| 217 CronetEnvironment::CronetEnvironment(const std::string& user_agent, | 217 CronetEnvironment::CronetEnvironment(const std::string& user_agent, |
| 218 bool user_agent_partial) | 218 bool user_agent_partial) |
| 219 : http2_enabled_(false), | 219 : http2_enabled_(false), |
| 220 quic_enabled_(false), | 220 quic_enabled_(false), |
| 221 http_cache_(URLRequestContextConfig::HttpCacheType::DISK), | 221 http_cache_(URLRequestContextConfig::HttpCacheType::DISK), |
| 222 user_agent_(user_agent), | 222 user_agent_(user_agent), |
| 223 user_agent_partial_(user_agent_partial), | 223 user_agent_partial_(user_agent_partial), |
| 224 net_log_(new net::NetLog) {} | 224 net_log_(new net::NetLog), |
| 225 enable_pkp_bypass_for_local_trust_anchors_(true) {} |
| 225 | 226 |
| 226 void CronetEnvironment::Start() { | 227 void CronetEnvironment::Start() { |
| 227 // Threads setup. | 228 // Threads setup. |
| 228 network_cache_thread_.reset(new base::Thread("Chrome Network Cache Thread")); | 229 network_cache_thread_.reset(new base::Thread("Chrome Network Cache Thread")); |
| 229 network_cache_thread_->StartWithOptions( | 230 network_cache_thread_->StartWithOptions( |
| 230 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 231 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 231 network_io_thread_.reset(new base::Thread("Chrome Network IO Thread")); | 232 network_io_thread_.reset(new base::Thread("Chrome Network IO Thread")); |
| 232 network_io_thread_->StartWithOptions( | 233 network_io_thread_->StartWithOptions( |
| 233 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 234 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 234 file_thread_.reset(new base::Thread("Chrome File Thread")); | 235 file_thread_.reset(new base::Thread("Chrome File Thread")); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 url::SchemeHostPort quic_hint_server("https", quic_hint.host(), | 340 url::SchemeHostPort quic_hint_server("https", quic_hint.host(), |
| 340 quic_hint.port()); | 341 quic_hint.port()); |
| 341 http_server_properties->SetAlternativeService( | 342 http_server_properties->SetAlternativeService( |
| 342 quic_hint_server, alternative_service, base::Time::Max()); | 343 quic_hint_server, alternative_service, base::Time::Max()); |
| 343 } | 344 } |
| 344 | 345 |
| 345 context_builder.SetHttpServerProperties(std::move(http_server_properties)); | 346 context_builder.SetHttpServerProperties(std::move(http_server_properties)); |
| 346 | 347 |
| 347 main_context_ = context_builder.Build(); | 348 main_context_ = context_builder.Build(); |
| 348 | 349 |
| 349 // Iterate through PKP configuration for every host. | 350 main_context_->transport_security_state() |
| 351 ->SetEnablePublicKeyPinningBypassForLocalTrustAnchors( |
| 352 enable_pkp_bypass_for_local_trust_anchors_); |
| 353 |
| 354 // Iterate trhough PKP configuration for every host. |
| 350 for (const auto& pkp : config->pkp_list) { | 355 for (const auto& pkp : config->pkp_list) { |
| 351 // Add the host pinning. | 356 // Add the host pinning. |
| 352 main_context_->transport_security_state()->AddHPKP( | 357 main_context_->transport_security_state()->AddHPKP( |
| 353 pkp->host, pkp->expiration_date, pkp->include_subdomains, | 358 pkp->host, pkp->expiration_date, pkp->include_subdomains, |
| 354 pkp->pin_hashes, GURL::EmptyGURL()); | 359 pkp->pin_hashes, GURL::EmptyGURL()); |
| 355 } | 360 } |
| 356 } | 361 } |
| 357 | 362 |
| 358 std::string CronetEnvironment::user_agent() { | 363 std::string CronetEnvironment::user_agent() { |
| 359 const net::HttpUserAgentSettings* user_agent_settings = | 364 const net::HttpUserAgentSettings* user_agent_settings = |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 event->Signal(); | 396 event->Signal(); |
| 392 } | 397 } |
| 393 | 398 |
| 394 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { | 399 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { |
| 395 return base::SysNSStringToUTF8([[NSBundle mainBundle] | 400 return base::SysNSStringToUTF8([[NSBundle mainBundle] |
| 396 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + | 401 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + |
| 397 " Cronet/" + CRONET_VERSION; | 402 " Cronet/" + CRONET_VERSION; |
| 398 } | 403 } |
| 399 | 404 |
| 400 } // namespace cronet | 405 } // namespace cronet |
| OLD | NEW |