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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 main_context_->set_host_resolver( | 401 main_context_->set_host_resolver( |
402 net::HostResolver::CreateDefaultResolver(nullptr).release()); | 402 net::HostResolver::CreateDefaultResolver(nullptr).release()); |
403 main_context_->set_cert_verifier( | 403 main_context_->set_cert_verifier( |
404 net::CertVerifier::CreateDefault().release()); | 404 net::CertVerifier::CreateDefault().release()); |
405 main_context_->set_http_auth_handler_factory( | 405 main_context_->set_http_auth_handler_factory( |
406 net::HttpAuthHandlerRegistryFactory::CreateDefault( | 406 net::HttpAuthHandlerRegistryFactory::CreateDefault( |
407 main_context_->host_resolver()) | 407 main_context_->host_resolver()) |
408 .release()); | 408 .release()); |
409 main_context_->set_proxy_service( | 409 main_context_->set_proxy_service( |
410 net::ProxyService::CreateUsingSystemProxyResolver( | 410 net::ProxyService::CreateUsingSystemProxyResolver( |
411 proxy_config_service_.get(), 0, nullptr) | 411 proxy_config_service_.Pass(), 0, nullptr) |
412 .release()); | 412 .release()); |
413 | 413 |
414 // Cache | 414 // Cache |
415 NSArray* dirs = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, | 415 NSArray* dirs = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, |
416 NSUserDomainMask, | 416 NSUserDomainMask, |
417 YES); | 417 YES); |
418 base::FilePath cache_path = | 418 base::FilePath cache_path = |
419 base::mac::NSStringToFilePath([dirs objectAtIndex:0]); | 419 base::mac::NSStringToFilePath([dirs objectAtIndex:0]); |
420 cache_path = cache_path.Append(FILE_PATH_LITERAL("crnet")); | 420 cache_path = cache_path.Append(FILE_PATH_LITERAL("crnet")); |
421 net::HttpCache::DefaultBackend* main_backend = | 421 net::HttpCache::DefaultBackend* main_backend = |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 if (backend) | 503 if (backend) |
504 backend->DoomAllEntries(client_callback); | 504 backend->DoomAllEntries(client_callback); |
505 }); | 505 }); |
506 int rc = cache->GetBackend(&backend, doom_callback); | 506 int rc = cache->GetBackend(&backend, doom_callback); |
507 if (rc != net::ERR_IO_PENDING) { | 507 if (rc != net::ERR_IO_PENDING) { |
508 // GetBackend doesn't call the callback if it completes synchronously, so | 508 // GetBackend doesn't call the callback if it completes synchronously, so |
509 // call it directly here. | 509 // call it directly here. |
510 doom_callback.Run(rc); | 510 doom_callback.Run(rc); |
511 } | 511 } |
512 } | 512 } |
OLD | NEW |