| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 file_thread_->StartWithOptions( | 275 file_thread_->StartWithOptions( |
| 276 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 276 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 277 file_user_blocking_thread_.reset( | 277 file_user_blocking_thread_.reset( |
| 278 new base::Thread("Chrome File User Blocking Thread")); | 278 new base::Thread("Chrome File User Blocking Thread")); |
| 279 file_user_blocking_thread_->StartWithOptions( | 279 file_user_blocking_thread_->StartWithOptions( |
| 280 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 280 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 281 | 281 |
| 282 // The network change notifier must be initialized so that registered | 282 // The network change notifier must be initialized so that registered |
| 283 // delegates will receive callbacks. | 283 // delegates will receive callbacks. |
| 284 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 284 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
| 285 proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService( | 285 proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService( |
| 286 network_io_thread_->task_runner(), nullptr)); | 286 network_io_thread_->task_runner(), nullptr); |
| 287 | 287 |
| 288 PostToNetworkThread(FROM_HERE, | 288 PostToNetworkThread(FROM_HERE, |
| 289 base::Bind(&CrNetEnvironment::InitializeOnNetworkThread, | 289 base::Bind(&CrNetEnvironment::InitializeOnNetworkThread, |
| 290 base::Unretained(this))); | 290 base::Unretained(this))); |
| 291 | 291 |
| 292 net::SetURLRequestContextForNSSHttpIO(main_context_.get()); | 292 net::SetURLRequestContextForNSSHttpIO(main_context_.get()); |
| 293 main_context_getter_ = new CrNetURLRequestContextGetter( | 293 main_context_getter_ = new CrNetURLRequestContextGetter( |
| 294 main_context_.get(), network_io_thread_->task_runner()); | 294 main_context_.get(), network_io_thread_->task_runner()); |
| 295 SetRequestFilterBlock(nil); | 295 SetRequestFilterBlock(nil); |
| 296 } | 296 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 main_context_->set_host_resolver( | 397 main_context_->set_host_resolver( |
| 398 net::HostResolver::CreateDefaultResolver(nullptr).release()); | 398 net::HostResolver::CreateDefaultResolver(nullptr).release()); |
| 399 main_context_->set_cert_verifier(net::CertVerifier::CreateDefault()); | 399 main_context_->set_cert_verifier(net::CertVerifier::CreateDefault()); |
| 400 main_context_->set_http_auth_handler_factory( | 400 main_context_->set_http_auth_handler_factory( |
| 401 net::HttpAuthHandlerRegistryFactory::CreateDefault( | 401 net::HttpAuthHandlerRegistryFactory::CreateDefault( |
| 402 main_context_->host_resolver())); | 402 main_context_->host_resolver())); |
| 403 main_context_->set_proxy_service( | 403 main_context_->set_proxy_service( |
| 404 net::ProxyService::CreateUsingSystemProxyResolver( | 404 net::ProxyService::CreateUsingSystemProxyResolver( |
| 405 proxy_config_service_.get(), 0, nullptr)); | 405 proxy_config_service_.Pass(), 0, nullptr)); |
| 406 | 406 |
| 407 // Cache | 407 // Cache |
| 408 NSArray* dirs = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, | 408 NSArray* dirs = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, |
| 409 NSUserDomainMask, | 409 NSUserDomainMask, |
| 410 YES); | 410 YES); |
| 411 base::FilePath cache_path = | 411 base::FilePath cache_path = |
| 412 base::mac::NSStringToFilePath([dirs objectAtIndex:0]); | 412 base::mac::NSStringToFilePath([dirs objectAtIndex:0]); |
| 413 cache_path = cache_path.Append(FILE_PATH_LITERAL("crnet")); | 413 cache_path = cache_path.Append(FILE_PATH_LITERAL("crnet")); |
| 414 net::HttpCache::DefaultBackend* main_backend = | 414 net::HttpCache::DefaultBackend* main_backend = |
| 415 new net::HttpCache::DefaultBackend(net::DISK_CACHE, | 415 new net::HttpCache::DefaultBackend(net::DISK_CACHE, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 if (backend) | 494 if (backend) |
| 495 backend->DoomAllEntries(client_callback); | 495 backend->DoomAllEntries(client_callback); |
| 496 }); | 496 }); |
| 497 int rc = cache->GetBackend(&backend, doom_callback); | 497 int rc = cache->GetBackend(&backend, doom_callback); |
| 498 if (rc != net::ERR_IO_PENDING) { | 498 if (rc != net::ERR_IO_PENDING) { |
| 499 // GetBackend doesn't call the callback if it completes synchronously, so | 499 // GetBackend doesn't call the callback if it completes synchronously, so |
| 500 // call it directly here. | 500 // call it directly here. |
| 501 doom_callback.Run(rc); | 501 doom_callback.Run(rc); |
| 502 } | 502 } |
| 503 } | 503 } |
| OLD | NEW |