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 <utility> |
| 10 |
9 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
10 #include "base/command_line.h" | 12 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
12 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
13 #include "base/files/scoped_file.h" | 15 #include "base/files/scoped_file.h" |
14 #include "base/i18n/icu_util.h" | 16 #include "base/i18n/icu_util.h" |
15 #include "base/json/json_writer.h" | 17 #include "base/json/json_writer.h" |
16 #include "base/mac/bind_objc_block.h" | 18 #include "base/mac/bind_objc_block.h" |
17 #include "base/mac/foundation_util.h" | 19 #include "base/mac/foundation_util.h" |
18 #include "base/mac/scoped_block.h" | 20 #include "base/mac/scoped_block.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 base::ScopedFILE file(base::OpenFile(full_path, "w")); | 193 base::ScopedFILE file(base::OpenFile(full_path, "w")); |
192 if (!file) | 194 if (!file) |
193 return; | 195 return; |
194 | 196 |
195 net::NetLogCaptureMode capture_mode = log_bytes ? | 197 net::NetLogCaptureMode capture_mode = log_bytes ? |
196 net::NetLogCaptureMode::IncludeSocketBytes() : | 198 net::NetLogCaptureMode::IncludeSocketBytes() : |
197 net::NetLogCaptureMode::Default(); | 199 net::NetLogCaptureMode::Default(); |
198 | 200 |
199 net_log_observer_.reset(new net::WriteToFileNetLogObserver()); | 201 net_log_observer_.reset(new net::WriteToFileNetLogObserver()); |
200 net_log_observer_->set_capture_mode(capture_mode); | 202 net_log_observer_->set_capture_mode(capture_mode); |
201 net_log_observer_->StartObserving(net_log_.get(), file.Pass(), nullptr, | 203 net_log_observer_->StartObserving(net_log_.get(), std::move(file), nullptr, |
202 nullptr); | 204 nullptr); |
203 } | 205 } |
204 | 206 |
205 void CrNetEnvironment::StopNetLog() { | 207 void CrNetEnvironment::StopNetLog() { |
206 PostToFileUserBlockingThread(FROM_HERE, | 208 PostToFileUserBlockingThread(FROM_HERE, |
207 base::Bind(&CrNetEnvironment::StopNetLogInternal, | 209 base::Bind(&CrNetEnvironment::StopNetLogInternal, |
208 base::Unretained(this))); | 210 base::Unretained(this))); |
209 } | 211 } |
210 | 212 |
211 void CrNetEnvironment::StopNetLogInternal() { | 213 void CrNetEnvironment::StopNetLogInternal() { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 main_context_->set_host_resolver( | 402 main_context_->set_host_resolver( |
401 net::HostResolver::CreateDefaultResolver(nullptr).release()); | 403 net::HostResolver::CreateDefaultResolver(nullptr).release()); |
402 main_context_->set_cert_verifier( | 404 main_context_->set_cert_verifier( |
403 net::CertVerifier::CreateDefault().release()); | 405 net::CertVerifier::CreateDefault().release()); |
404 main_context_->set_http_auth_handler_factory( | 406 main_context_->set_http_auth_handler_factory( |
405 net::HttpAuthHandlerRegistryFactory::CreateDefault( | 407 net::HttpAuthHandlerRegistryFactory::CreateDefault( |
406 main_context_->host_resolver()) | 408 main_context_->host_resolver()) |
407 .release()); | 409 .release()); |
408 main_context_->set_proxy_service( | 410 main_context_->set_proxy_service( |
409 net::ProxyService::CreateUsingSystemProxyResolver( | 411 net::ProxyService::CreateUsingSystemProxyResolver( |
410 proxy_config_service_.Pass(), 0, nullptr) | 412 std::move(proxy_config_service_), 0, nullptr) |
411 .release()); | 413 .release()); |
412 | 414 |
413 // Cache | 415 // Cache |
414 NSArray* dirs = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, | 416 NSArray* dirs = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, |
415 NSUserDomainMask, | 417 NSUserDomainMask, |
416 YES); | 418 YES); |
417 base::FilePath cache_path = | 419 base::FilePath cache_path = |
418 base::mac::NSStringToFilePath([dirs objectAtIndex:0]); | 420 base::mac::NSStringToFilePath([dirs objectAtIndex:0]); |
419 cache_path = cache_path.Append(FILE_PATH_LITERAL("crnet")); | 421 cache_path = cache_path.Append(FILE_PATH_LITERAL("crnet")); |
420 scoped_ptr<net::HttpCache::DefaultBackend> main_backend( | 422 scoped_ptr<net::HttpCache::DefaultBackend> main_backend( |
(...skipping 27 matching lines...) Expand all Loading... |
448 // TODO(ellyjones): support persisting ChannelID. | 450 // TODO(ellyjones): support persisting ChannelID. |
449 params.channel_id_service = new net::ChannelIDService( | 451 params.channel_id_service = new net::ChannelIDService( |
450 new net::DefaultChannelIDStore(NULL), | 452 new net::DefaultChannelIDStore(NULL), |
451 base::WorkerPool::GetTaskRunner(true)); | 453 base::WorkerPool::GetTaskRunner(true)); |
452 } | 454 } |
453 | 455 |
454 // TODO(mmenke): These really shouldn't be leaked. | 456 // TODO(mmenke): These really shouldn't be leaked. |
455 // See https://crbug.com/523858. | 457 // See https://crbug.com/523858. |
456 net::HttpNetworkSession* http_network_session = | 458 net::HttpNetworkSession* http_network_session = |
457 new net::HttpNetworkSession(params); | 459 new net::HttpNetworkSession(params); |
458 net::HttpCache* main_cache = new net::HttpCache( | 460 net::HttpCache* main_cache = |
459 http_network_session, main_backend.Pass(), | 461 new net::HttpCache(http_network_session, std::move(main_backend), |
460 true /* set_up_quic_server_info */); | 462 true /* set_up_quic_server_info */); |
461 main_context_->set_http_transaction_factory(main_cache); | 463 main_context_->set_http_transaction_factory(main_cache); |
462 | 464 |
463 // Cookies | 465 // Cookies |
464 scoped_refptr<net::CookieStore> cookie_store = | 466 scoped_refptr<net::CookieStore> cookie_store = |
465 net::CookieStoreIOS::CreateCookieStore( | 467 net::CookieStoreIOS::CreateCookieStore( |
466 [NSHTTPCookieStorage sharedHTTPCookieStorage]); | 468 [NSHTTPCookieStorage sharedHTTPCookieStorage]); |
467 main_context_->set_cookie_store(cookie_store.get()); | 469 main_context_->set_cookie_store(cookie_store.get()); |
468 | 470 |
469 net::URLRequestJobFactoryImpl* job_factory = | 471 net::URLRequestJobFactoryImpl* job_factory = |
470 new net::URLRequestJobFactoryImpl; | 472 new net::URLRequestJobFactoryImpl; |
(...skipping 16 matching lines...) Expand all Loading... |
487 | 489 |
488 return user_agent_settings->GetUserAgent(); | 490 return user_agent_settings->GetUserAgent(); |
489 } | 491 } |
490 | 492 |
491 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { | 493 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { |
492 PostToNetworkThread( | 494 PostToNetworkThread( |
493 FROM_HERE, | 495 FROM_HERE, |
494 base::Bind(&net::ClearHttpCache, main_context_getter_, | 496 base::Bind(&net::ClearHttpCache, main_context_getter_, |
495 network_io_thread_->task_runner(), base::BindBlock(callback))); | 497 network_io_thread_->task_runner(), base::BindBlock(callback))); |
496 } | 498 } |
OLD | NEW |