| 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 int port, | 214 int port, |
| 215 int alternate_port) { | 215 int alternate_port) { |
| 216 DCHECK(port == alternate_port); | 216 DCHECK(port == alternate_port); |
| 217 quic_hints_.push_back(net::HostPortPair(host, port)); | 217 quic_hints_.push_back(net::HostPortPair(host, port)); |
| 218 } | 218 } |
| 219 | 219 |
| 220 CronetEnvironment::CronetEnvironment(const std::string& user_agent, | 220 CronetEnvironment::CronetEnvironment(const std::string& user_agent, |
| 221 bool user_agent_partial) | 221 bool user_agent_partial) |
| 222 : http2_enabled_(false), | 222 : http2_enabled_(false), |
| 223 quic_enabled_(false), | 223 quic_enabled_(false), |
| 224 http_cache_(URLRequestContextConfig::HttpCacheType::DISK), |
| 224 user_agent_(user_agent), | 225 user_agent_(user_agent), |
| 225 user_agent_partial_(user_agent_partial), | 226 user_agent_partial_(user_agent_partial), |
| 226 net_log_(new net::NetLog) {} | 227 net_log_(new net::NetLog) {} |
| 227 | 228 |
| 228 void CronetEnvironment::Start() { | 229 void CronetEnvironment::Start() { |
| 229 // Threads setup. | 230 // Threads setup. |
| 230 network_cache_thread_.reset(new base::Thread("Chrome Network Cache Thread")); | 231 network_cache_thread_.reset(new base::Thread("Chrome Network Cache Thread")); |
| 231 network_cache_thread_->StartWithOptions( | 232 network_cache_thread_->StartWithOptions( |
| 232 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 233 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 233 network_io_thread_.reset(new base::Thread("Chrome Network IO Thread")); | 234 network_io_thread_.reset(new base::Thread("Chrome Network IO Thread")); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 281 |
| 281 // Cache | 282 // Cache |
| 282 base::FilePath cache_path; | 283 base::FilePath cache_path; |
| 283 if (!PathService::Get(base::DIR_CACHE, &cache_path)) | 284 if (!PathService::Get(base::DIR_CACHE, &cache_path)) |
| 284 return; | 285 return; |
| 285 cache_path = cache_path.Append(FILE_PATH_LITERAL("cronet")); | 286 cache_path = cache_path.Append(FILE_PATH_LITERAL("cronet")); |
| 286 | 287 |
| 287 URLRequestContextConfigBuilder context_config_builder; | 288 URLRequestContextConfigBuilder context_config_builder; |
| 288 context_config_builder.enable_quic = quic_enabled_; // Enable QUIC. | 289 context_config_builder.enable_quic = quic_enabled_; // Enable QUIC. |
| 289 context_config_builder.enable_spdy = http2_enabled_; // Enable HTTP/2. | 290 context_config_builder.enable_spdy = http2_enabled_; // Enable HTTP/2. |
| 290 context_config_builder.http_cache = URLRequestContextConfig::DISK; | 291 context_config_builder.http_cache = http_cache_; // Set HTTP cache |
| 291 context_config_builder.storage_path = | 292 context_config_builder.storage_path = |
| 292 cache_path.value(); // Storage path for http cache and cookie storage. | 293 cache_path.value(); // Storage path for http cache and cookie storage. |
| 293 context_config_builder.user_agent = | 294 context_config_builder.user_agent = |
| 294 user_agent_; // User-Agent request header field. | 295 user_agent_; // User-Agent request header field. |
| 295 context_config_builder.mock_cert_verifier = std::move( | 296 context_config_builder.mock_cert_verifier = std::move( |
| 296 mock_cert_verifier_); // MockCertVerifier to use for testing purposes. | 297 mock_cert_verifier_); // MockCertVerifier to use for testing purposes. |
| 297 std::unique_ptr<URLRequestContextConfig> config = | 298 std::unique_ptr<URLRequestContextConfig> config = |
| 298 context_config_builder.Build(); | 299 context_config_builder.Build(); |
| 299 | 300 |
| 300 net::URLRequestContextBuilder context_builder; | 301 net::URLRequestContextBuilder context_builder; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 event->Signal(); | 371 event->Signal(); |
| 371 } | 372 } |
| 372 | 373 |
| 373 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { | 374 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { |
| 374 return base::SysNSStringToUTF8([[NSBundle mainBundle] | 375 return base::SysNSStringToUTF8([[NSBundle mainBundle] |
| 375 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + | 376 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + |
| 376 " Cronet/" + CRONET_VERSION; | 377 " Cronet/" + CRONET_VERSION; |
| 377 } | 378 } |
| 378 | 379 |
| 379 } // namespace cronet | 380 } // namespace cronet |
| OLD | NEW |