OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/crnet/crnet_environment.h" | 5 #include "ios/crnet/crnet_environment.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 }]; | 387 }]; |
388 main_context_->set_http_user_agent_settings( | 388 main_context_->set_http_user_agent_settings( |
389 new net::StaticHttpUserAgentSettings(acceptable_languages, user_agent)); | 389 new net::StaticHttpUserAgentSettings(acceptable_languages, user_agent)); |
390 | 390 |
391 main_context_->set_ssl_config_service(new net::SSLConfigServiceDefaults); | 391 main_context_->set_ssl_config_service(new net::SSLConfigServiceDefaults); |
392 main_context_->set_transport_security_state( | 392 main_context_->set_transport_security_state( |
393 new net::TransportSecurityState()); | 393 new net::TransportSecurityState()); |
394 http_server_properties_.reset(new net::HttpServerPropertiesImpl()); | 394 http_server_properties_.reset(new net::HttpServerPropertiesImpl()); |
395 main_context_->set_http_server_properties( | 395 main_context_->set_http_server_properties( |
396 http_server_properties_->GetWeakPtr()); | 396 http_server_properties_->GetWeakPtr()); |
| 397 // TODO(rdsmith): Note that the ".release()" calls below are leaking |
| 398 // the objects in question; this should be fixed by having an object |
| 399 // corresponding to URLRequestContextStorage that actually owns those |
| 400 // objects. See http://crbug.com/523858. |
397 main_context_->set_host_resolver( | 401 main_context_->set_host_resolver( |
398 net::HostResolver::CreateDefaultResolver(nullptr).release()); | 402 net::HostResolver::CreateDefaultResolver(nullptr).release()); |
399 main_context_->set_cert_verifier(net::CertVerifier::CreateDefault()); | 403 main_context_->set_cert_verifier( |
| 404 net::CertVerifier::CreateDefault().release()); |
400 main_context_->set_http_auth_handler_factory( | 405 main_context_->set_http_auth_handler_factory( |
401 net::HttpAuthHandlerRegistryFactory::CreateDefault( | 406 net::HttpAuthHandlerRegistryFactory::CreateDefault( |
402 main_context_->host_resolver())); | 407 main_context_->host_resolver()) |
| 408 .release()); |
403 main_context_->set_proxy_service( | 409 main_context_->set_proxy_service( |
404 net::ProxyService::CreateUsingSystemProxyResolver( | 410 net::ProxyService::CreateUsingSystemProxyResolver( |
405 proxy_config_service_.get(), 0, nullptr)); | 411 proxy_config_service_.get(), 0, nullptr) |
| 412 .release()); |
406 | 413 |
407 // Cache | 414 // Cache |
408 NSArray* dirs = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, | 415 NSArray* dirs = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, |
409 NSUserDomainMask, | 416 NSUserDomainMask, |
410 YES); | 417 YES); |
411 base::FilePath cache_path = | 418 base::FilePath cache_path = |
412 base::mac::NSStringToFilePath([dirs objectAtIndex:0]); | 419 base::mac::NSStringToFilePath([dirs objectAtIndex:0]); |
413 cache_path = cache_path.Append(FILE_PATH_LITERAL("crnet")); | 420 cache_path = cache_path.Append(FILE_PATH_LITERAL("crnet")); |
414 net::HttpCache::DefaultBackend* main_backend = | 421 net::HttpCache::DefaultBackend* main_backend = |
415 new net::HttpCache::DefaultBackend(net::DISK_CACHE, | 422 new net::HttpCache::DefaultBackend(net::DISK_CACHE, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 if (backend) | 503 if (backend) |
497 backend->DoomAllEntries(client_callback); | 504 backend->DoomAllEntries(client_callback); |
498 }); | 505 }); |
499 int rc = cache->GetBackend(&backend, doom_callback); | 506 int rc = cache->GetBackend(&backend, doom_callback); |
500 if (rc != net::ERR_IO_PENDING) { | 507 if (rc != net::ERR_IO_PENDING) { |
501 // GetBackend doesn't call the callback if it completes synchronously, so | 508 // GetBackend doesn't call the callback if it completes synchronously, so |
502 // call it directly here. | 509 // call it directly here. |
503 doom_callback.Run(rc); | 510 doom_callback.Run(rc); |
504 } | 511 } |
505 } | 512 } |
OLD | NEW |