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