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 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory = |
473 new net::URLRequestJobFactoryImpl; | 473 net::URLRequestJobFactoryImpl::CreateWithDefaultProtocolHandlers(); |
474 job_factory->SetProtocolHandler( | 474 job_factory->SetProtocolHandler( |
475 "data", base::WrapUnique(new net::DataProtocolHandler)); | 475 "data", base::WrapUnique(new net::DataProtocolHandler)); |
476 job_factory->SetProtocolHandler( | 476 job_factory->SetProtocolHandler( |
477 "file", base::WrapUnique( | 477 "file", base::WrapUnique( |
478 new net::FileProtocolHandler(file_thread_->task_runner()))); | 478 new net::FileProtocolHandler(file_thread_->task_runner()))); |
479 main_context_->set_job_factory(job_factory); | 479 main_context_->set_job_factory(job_factory.release()); |
mmenke
2016/04/22 18:37:53
Please add a TODO about fixing this leak
mgersh
2016/04/27 16:13:52
Done.
| |
480 | 480 |
481 main_context_->set_net_log(net_log_.get()); | 481 main_context_->set_net_log(net_log_.get()); |
482 } | 482 } |
483 | 483 |
484 std::string CrNetEnvironment::user_agent() { | 484 std::string CrNetEnvironment::user_agent() { |
485 const net::HttpUserAgentSettings* user_agent_settings = | 485 const net::HttpUserAgentSettings* user_agent_settings = |
486 main_context_->http_user_agent_settings(); | 486 main_context_->http_user_agent_settings(); |
487 if (!user_agent_settings) { | 487 if (!user_agent_settings) { |
488 return nullptr; | 488 return nullptr; |
489 } | 489 } |
490 | 490 |
491 return user_agent_settings->GetUserAgent(); | 491 return user_agent_settings->GetUserAgent(); |
492 } | 492 } |
493 | 493 |
494 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { | 494 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { |
495 PostToNetworkThread( | 495 PostToNetworkThread( |
496 FROM_HERE, | 496 FROM_HERE, |
497 base::Bind(&net::ClearHttpCache, main_context_getter_, | 497 base::Bind(&net::ClearHttpCache, main_context_getter_, |
498 network_io_thread_->task_runner(), base::BindBlock(callback))); | 498 network_io_thread_->task_runner(), base::BindBlock(callback))); |
499 } | 499 } |
OLD | NEW |