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