| 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> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 YES); | 433 YES); |
| 434 base::FilePath cache_path = | 434 base::FilePath cache_path = |
| 435 base::mac::NSStringToFilePath([dirs objectAtIndex:0]); | 435 base::mac::NSStringToFilePath([dirs objectAtIndex:0]); |
| 436 cache_path = cache_path.Append(FILE_PATH_LITERAL("crnet")); | 436 cache_path = cache_path.Append(FILE_PATH_LITERAL("crnet")); |
| 437 std::unique_ptr<net::HttpCache::DefaultBackend> main_backend( | 437 std::unique_ptr<net::HttpCache::DefaultBackend> main_backend( |
| 438 new net::HttpCache::DefaultBackend(net::DISK_CACHE, | 438 new net::HttpCache::DefaultBackend(net::DISK_CACHE, |
| 439 net::CACHE_BACKEND_DEFAULT, cache_path, | 439 net::CACHE_BACKEND_DEFAULT, cache_path, |
| 440 0, // Default cache size. | 440 0, // Default cache size. |
| 441 network_cache_thread_->task_runner())); | 441 network_cache_thread_->task_runner())); |
| 442 | 442 |
| 443 net::HttpNetworkSession::Params params; | 443 net::HttpNetworkSession::Params session_params; |
| 444 params.host_resolver = main_context_->host_resolver(); | 444 session_params.enable_http2 = spdy_enabled(); |
| 445 params.cert_verifier = main_context_->cert_verifier(); | 445 session_params.enable_quic = quic_enabled(); |
| 446 params.cert_transparency_verifier = | 446 |
| 447 net::HttpNetworkSession::Context session_context; |
| 448 session_context.host_resolver = main_context_->host_resolver(); |
| 449 session_context.cert_verifier = main_context_->cert_verifier(); |
| 450 session_context.cert_transparency_verifier = |
| 447 main_context_->cert_transparency_verifier(); | 451 main_context_->cert_transparency_verifier(); |
| 448 params.ct_policy_enforcer = main_context_->ct_policy_enforcer(); | 452 session_context.ct_policy_enforcer = main_context_->ct_policy_enforcer(); |
| 449 params.channel_id_service = main_context_->channel_id_service(); | 453 session_context.channel_id_service = main_context_->channel_id_service(); |
| 450 params.transport_security_state = main_context_->transport_security_state(); | 454 session_context.transport_security_state = |
| 451 params.proxy_service = main_context_->proxy_service(); | 455 main_context_->transport_security_state(); |
| 452 params.ssl_config_service = main_context_->ssl_config_service(); | 456 session_context.proxy_service = main_context_->proxy_service(); |
| 453 params.http_auth_handler_factory = main_context_->http_auth_handler_factory(); | 457 session_context.ssl_config_service = main_context_->ssl_config_service(); |
| 454 params.http_server_properties = main_context_->http_server_properties(); | 458 session_context.http_auth_handler_factory = |
| 455 params.net_log = main_context_->net_log(); | 459 main_context_->http_auth_handler_factory(); |
| 456 params.enable_http2 = spdy_enabled(); | 460 session_context.http_server_properties = |
| 457 params.enable_quic = quic_enabled(); | 461 main_context_->http_server_properties(); |
| 462 session_context.net_log = main_context_->net_log(); |
| 458 | 463 |
| 459 if (!params.channel_id_service) { | 464 if (!session_context.channel_id_service) { |
| 460 // The main context may not have a ChannelIDService, since it is lazily | 465 // The main context may not have a ChannelIDService, since it is lazily |
| 461 // constructed. If not, build an ephemeral ChannelIDService with no backing | 466 // constructed. If not, build an ephemeral ChannelIDService with no backing |
| 462 // disk store. | 467 // disk store. |
| 463 // TODO(ellyjones): support persisting ChannelID. | 468 // TODO(ellyjones): support persisting ChannelID. |
| 464 params.channel_id_service = | 469 session_context.channel_id_service = |
| 465 new net::ChannelIDService(new net::DefaultChannelIDStore(NULL)); | 470 new net::ChannelIDService(new net::DefaultChannelIDStore(NULL)); |
| 466 } | 471 } |
| 467 | 472 |
| 468 // TODO(mmenke): These really shouldn't be leaked. | 473 // TODO(mmenke): These really shouldn't be leaked. |
| 469 // See https://crbug.com/523858. | 474 // See https://crbug.com/523858. |
| 470 net::HttpNetworkSession* http_network_session = | 475 net::HttpNetworkSession* http_network_session = |
| 471 new net::HttpNetworkSession(params); | 476 new net::HttpNetworkSession(session_params, session_context); |
| 472 net::HttpCache* main_cache = | 477 net::HttpCache* main_cache = |
| 473 new net::HttpCache(http_network_session, std::move(main_backend), | 478 new net::HttpCache(http_network_session, std::move(main_backend), |
| 474 true /* set_up_quic_server_info */); | 479 true /* set_up_quic_server_info */); |
| 475 main_context_->set_http_transaction_factory(main_cache); | 480 main_context_->set_http_transaction_factory(main_cache); |
| 476 | 481 |
| 477 // Cookies | 482 // Cookies |
| 478 [[NSHTTPCookieStorage sharedHTTPCookieStorage] | 483 [[NSHTTPCookieStorage sharedHTTPCookieStorage] |
| 479 setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; | 484 setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; |
| 480 cookie_store_ = base::MakeUnique<net::CookieStoreIOS>( | 485 cookie_store_ = base::MakeUnique<net::CookieStoreIOS>( |
| 481 [NSHTTPCookieStorage sharedHTTPCookieStorage]); | 486 [NSHTTPCookieStorage sharedHTTPCookieStorage]); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 504 | 509 |
| 505 return user_agent_settings->GetUserAgent(); | 510 return user_agent_settings->GetUserAgent(); |
| 506 } | 511 } |
| 507 | 512 |
| 508 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { | 513 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { |
| 509 PostToNetworkThread( | 514 PostToNetworkThread( |
| 510 FROM_HERE, base::Bind(&net::ClearHttpCache, main_context_getter_, | 515 FROM_HERE, base::Bind(&net::ClearHttpCache, main_context_getter_, |
| 511 network_io_thread_->task_runner(), base::Time(), | 516 network_io_thread_->task_runner(), base::Time(), |
| 512 base::Time::Max(), base::BindBlock(callback))); | 517 base::Time::Max(), base::BindBlock(callback))); |
| 513 } | 518 } |
| OLD | NEW |