| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 ts->Shutdown(); | 259 ts->Shutdown(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void CronetEnvironment::InitializeOnNetworkThread() { | 262 void CronetEnvironment::InitializeOnNetworkThread() { |
| 263 DCHECK(network_io_thread_->task_runner()->BelongsToCurrentThread()); | 263 DCHECK(network_io_thread_->task_runner()->BelongsToCurrentThread()); |
| 264 base::FeatureList::InitializeInstance(std::string(), std::string()); | 264 base::FeatureList::InitializeInstance(std::string(), std::string()); |
| 265 | 265 |
| 266 static bool ssl_key_log_file_set = false; | 266 static bool ssl_key_log_file_set = false; |
| 267 if (!ssl_key_log_file_set && !ssl_key_log_file_name_.empty()) { | 267 if (!ssl_key_log_file_set && !ssl_key_log_file_name_.empty()) { |
| 268 ssl_key_log_file_set = true; | 268 ssl_key_log_file_set = true; |
| 269 base::FilePath ssl_key_log_file(ssl_key_log_file_name_); | 269 base::FilePath ssl_key_log_file; |
| 270 net::SSLClientSocket::SetSSLKeyLogFile(ssl_key_log_file, | 270 if (!PathService::Get(base::DIR_HOME, &ssl_key_log_file)) |
| 271 file_thread_->task_runner()); | 271 return; |
| 272 net::SSLClientSocket::SetSSLKeyLogFile( |
| 273 ssl_key_log_file.Append(ssl_key_log_file_name_), |
| 274 file_thread_->task_runner()); |
| 272 } | 275 } |
| 273 | 276 |
| 274 if (user_agent_partial_) | 277 if (user_agent_partial_) |
| 275 user_agent_ = web::BuildUserAgentFromProduct(user_agent_); | 278 user_agent_ = web::BuildUserAgentFromProduct(user_agent_); |
| 276 | 279 |
| 277 // Cache | 280 // Cache |
| 278 base::FilePath cache_path; | 281 base::FilePath cache_path; |
| 279 if (!PathService::Get(base::DIR_CACHE, &cache_path)) | 282 if (!PathService::Get(base::DIR_CACHE, &cache_path)) |
| 280 return; | 283 return; |
| 281 cache_path = cache_path.Append(FILE_PATH_LITERAL("cronet")); | 284 cache_path = cache_path.Append(FILE_PATH_LITERAL("cronet")); |
| 282 | 285 |
| 283 URLRequestContextConfigBuilder context_config_builder; | 286 URLRequestContextConfigBuilder context_config_builder; |
| 284 context_config_builder.enable_quic = quic_enabled_; // Enable QUIC. | 287 context_config_builder.enable_quic = quic_enabled_; // Enable QUIC. |
| 285 context_config_builder.enable_spdy = http2_enabled_; // Enable HTTP/2. | 288 context_config_builder.enable_spdy = http2_enabled_; // Enable HTTP/2. |
| 286 context_config_builder.http_cache = http_cache_; // Set HTTP cache | 289 context_config_builder.http_cache = http_cache_; // Set HTTP cache |
| 287 context_config_builder.storage_path = | 290 context_config_builder.storage_path = |
| 288 cache_path.value(); // Storage path for http cache and cookie storage. | 291 cache_path.value(); // Storage path for http cache and cookie storage. |
| 289 context_config_builder.user_agent = | 292 context_config_builder.user_agent = |
| 290 user_agent_; // User-Agent request header field. | 293 user_agent_; // User-Agent request header field. |
| 291 context_config_builder.experimental_options = | |
| 292 experimental_options_; // Set experimental Cronet options. | |
| 293 context_config_builder.mock_cert_verifier = std::move( | 294 context_config_builder.mock_cert_verifier = std::move( |
| 294 mock_cert_verifier_); // MockCertVerifier to use for testing purposes. | 295 mock_cert_verifier_); // MockCertVerifier to use for testing purposes. |
| 295 std::unique_ptr<URLRequestContextConfig> config = | 296 std::unique_ptr<URLRequestContextConfig> config = |
| 296 context_config_builder.Build(); | 297 context_config_builder.Build(); |
| 297 | 298 |
| 298 net::URLRequestContextBuilder context_builder; | 299 net::URLRequestContextBuilder context_builder; |
| 299 | 300 |
| 300 context_builder.set_accept_language(accept_language_); | 301 context_builder.set_accept_language(accept_language_); |
| 301 | 302 |
| 302 config->ConfigureURLRequestContextBuilder(&context_builder, net_log_.get(), | 303 config->ConfigureURLRequestContextBuilder(&context_builder, net_log_.get(), |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 event->Signal(); | 374 event->Signal(); |
| 374 } | 375 } |
| 375 | 376 |
| 376 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { | 377 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { |
| 377 return base::SysNSStringToUTF8([[NSBundle mainBundle] | 378 return base::SysNSStringToUTF8([[NSBundle mainBundle] |
| 378 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + | 379 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + |
| 379 " Cronet/" + CRONET_VERSION; | 380 " Cronet/" + CRONET_VERSION; |
| 380 } | 381 } |
| 381 | 382 |
| 382 } // namespace cronet | 383 } // namespace cronet |
| OLD | NEW |