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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 net::HttpCache* main_cache = | 473 net::HttpCache* main_cache = |
474 new net::HttpCache(http_network_session, std::move(main_backend), | 474 new net::HttpCache(http_network_session, std::move(main_backend), |
475 true /* set_up_quic_server_info */); | 475 true /* set_up_quic_server_info */); |
476 main_context_->set_http_transaction_factory(main_cache); | 476 main_context_->set_http_transaction_factory(main_cache); |
477 | 477 |
478 // Cookies | 478 // Cookies |
479 cookie_store_ = net::CookieStoreIOS::CreateCookieStore( | 479 cookie_store_ = net::CookieStoreIOS::CreateCookieStore( |
480 [NSHTTPCookieStorage sharedHTTPCookieStorage]); | 480 [NSHTTPCookieStorage sharedHTTPCookieStorage]); |
481 main_context_->set_cookie_store(cookie_store_.get()); | 481 main_context_->set_cookie_store(cookie_store_.get()); |
482 | 482 |
483 net::URLRequestJobFactoryImpl* job_factory = | 483 // TODO(mgersh): Fix this leak too. See https://crbug.com/523858 |
484 new net::URLRequestJobFactoryImpl; | 484 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory = |
| 485 net::URLRequestJobFactoryImpl::CreateWithHttpProtocolHandlers(); |
485 job_factory->SetProtocolHandler( | 486 job_factory->SetProtocolHandler( |
486 "data", base::WrapUnique(new net::DataProtocolHandler)); | 487 "data", base::WrapUnique(new net::DataProtocolHandler)); |
487 #if !defined(DISABLE_FILE_SUPPORT) | 488 #if !defined(DISABLE_FILE_SUPPORT) |
488 job_factory->SetProtocolHandler( | 489 job_factory->SetProtocolHandler( |
489 "file", | 490 "file", |
490 base::MakeUnique<net::FileProtocolHandler>(file_thread_->task_runner())); | 491 base::MakeUnique<net::FileProtocolHandler>(file_thread_->task_runner())); |
491 #endif // !defined(DISABLE_FILE_SUPPORT) | 492 #endif // !defined(DISABLE_FILE_SUPPORT) |
492 main_context_->set_job_factory(job_factory); | 493 main_context_->set_job_factory(job_factory.release()); |
493 | |
494 main_context_->set_net_log(net_log_.get()); | 494 main_context_->set_net_log(net_log_.get()); |
495 } | 495 } |
496 | 496 |
497 std::string CrNetEnvironment::user_agent() { | 497 std::string CrNetEnvironment::user_agent() { |
498 const net::HttpUserAgentSettings* user_agent_settings = | 498 const net::HttpUserAgentSettings* user_agent_settings = |
499 main_context_->http_user_agent_settings(); | 499 main_context_->http_user_agent_settings(); |
500 if (!user_agent_settings) { | 500 if (!user_agent_settings) { |
501 return nullptr; | 501 return nullptr; |
502 } | 502 } |
503 | 503 |
504 return user_agent_settings->GetUserAgent(); | 504 return user_agent_settings->GetUserAgent(); |
505 } | 505 } |
506 | 506 |
507 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { | 507 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { |
508 PostToNetworkThread( | 508 PostToNetworkThread( |
509 FROM_HERE, base::Bind(&net::ClearHttpCache, main_context_getter_, | 509 FROM_HERE, base::Bind(&net::ClearHttpCache, main_context_getter_, |
510 network_io_thread_->task_runner(), base::Time(), | 510 network_io_thread_->task_runner(), base::Time(), |
511 base::Time::Max(), base::BindBlock(callback))); | 511 base::Time::Max(), base::BindBlock(callback))); |
512 } | 512 } |
OLD | NEW |