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 20 matching lines...) Expand all Loading... |
31 #include "ios/net/crn_http_protocol_handler.h" | 31 #include "ios/net/crn_http_protocol_handler.h" |
32 #include "ios/net/empty_nsurlcache.h" | 32 #include "ios/net/empty_nsurlcache.h" |
33 #include "ios/net/http_cache_helper.h" | 33 #include "ios/net/http_cache_helper.h" |
34 #include "ios/net/request_tracker.h" | 34 #include "ios/net/request_tracker.h" |
35 #include "ios/web/public/user_agent.h" | 35 #include "ios/web/public/user_agent.h" |
36 #include "net/base/net_errors.h" | 36 #include "net/base/net_errors.h" |
37 #include "net/base/network_change_notifier.h" | 37 #include "net/base/network_change_notifier.h" |
38 #include "net/base/sdch_manager.h" | 38 #include "net/base/sdch_manager.h" |
39 #include "net/cert/cert_verifier.h" | 39 #include "net/cert/cert_verifier.h" |
40 #include "net/cert_net/nss_ocsp.h" | 40 #include "net/cert_net/nss_ocsp.h" |
| 41 #include "net/cookies/cookie_store.h" |
41 #include "net/http/http_auth_handler_factory.h" | 42 #include "net/http/http_auth_handler_factory.h" |
42 #include "net/http/http_cache.h" | 43 #include "net/http/http_cache.h" |
43 #include "net/http/http_server_properties_impl.h" | 44 #include "net/http/http_server_properties_impl.h" |
44 #include "net/http/http_stream_factory.h" | 45 #include "net/http/http_stream_factory.h" |
45 #include "net/http/http_util.h" | 46 #include "net/http/http_util.h" |
46 #include "net/log/net_log.h" | 47 #include "net/log/net_log.h" |
47 #include "net/log/write_to_file_net_log_observer.h" | 48 #include "net/log/write_to_file_net_log_observer.h" |
48 #include "net/proxy/proxy_service.h" | 49 #include "net/proxy/proxy_service.h" |
49 #include "net/sdch/sdch_owner.h" | 50 #include "net/sdch/sdch_owner.h" |
50 #include "net/ssl/channel_id_service.h" | 51 #include "net/ssl/channel_id_service.h" |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 // TODO(mmenke): These really shouldn't be leaked. | 459 // TODO(mmenke): These really shouldn't be leaked. |
459 // See https://crbug.com/523858. | 460 // See https://crbug.com/523858. |
460 net::HttpNetworkSession* http_network_session = | 461 net::HttpNetworkSession* http_network_session = |
461 new net::HttpNetworkSession(params); | 462 new net::HttpNetworkSession(params); |
462 net::HttpCache* main_cache = | 463 net::HttpCache* main_cache = |
463 new net::HttpCache(http_network_session, std::move(main_backend), | 464 new net::HttpCache(http_network_session, std::move(main_backend), |
464 true /* set_up_quic_server_info */); | 465 true /* set_up_quic_server_info */); |
465 main_context_->set_http_transaction_factory(main_cache); | 466 main_context_->set_http_transaction_factory(main_cache); |
466 | 467 |
467 // Cookies | 468 // Cookies |
468 scoped_refptr<net::CookieStore> cookie_store = | 469 cookie_store_ = net::CookieStoreIOS::CreateCookieStore( |
469 net::CookieStoreIOS::CreateCookieStore( | |
470 [NSHTTPCookieStorage sharedHTTPCookieStorage]); | 470 [NSHTTPCookieStorage sharedHTTPCookieStorage]); |
471 main_context_->set_cookie_store(cookie_store.get()); | 471 main_context_->set_cookie_store(cookie_store_.get()); |
472 | 472 |
473 net::URLRequestJobFactoryImpl* job_factory = | 473 net::URLRequestJobFactoryImpl* job_factory = |
474 new net::URLRequestJobFactoryImpl; | 474 new net::URLRequestJobFactoryImpl; |
475 job_factory->SetProtocolHandler( | 475 job_factory->SetProtocolHandler( |
476 "data", make_scoped_ptr(new net::DataProtocolHandler)); | 476 "data", make_scoped_ptr(new net::DataProtocolHandler)); |
477 job_factory->SetProtocolHandler( | 477 job_factory->SetProtocolHandler( |
478 "file", make_scoped_ptr( | 478 "file", make_scoped_ptr( |
479 new net::FileProtocolHandler(file_thread_->task_runner()))); | 479 new net::FileProtocolHandler(file_thread_->task_runner()))); |
480 main_context_->set_job_factory(job_factory); | 480 main_context_->set_job_factory(job_factory); |
481 | 481 |
482 main_context_->set_net_log(net_log_.get()); | 482 main_context_->set_net_log(net_log_.get()); |
483 } | 483 } |
484 | 484 |
485 std::string CrNetEnvironment::user_agent() { | 485 std::string CrNetEnvironment::user_agent() { |
486 const net::HttpUserAgentSettings* user_agent_settings = | 486 const net::HttpUserAgentSettings* user_agent_settings = |
487 main_context_->http_user_agent_settings(); | 487 main_context_->http_user_agent_settings(); |
488 if (!user_agent_settings) { | 488 if (!user_agent_settings) { |
489 return nullptr; | 489 return nullptr; |
490 } | 490 } |
491 | 491 |
492 return user_agent_settings->GetUserAgent(); | 492 return user_agent_settings->GetUserAgent(); |
493 } | 493 } |
494 | 494 |
495 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { | 495 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { |
496 PostToNetworkThread( | 496 PostToNetworkThread( |
497 FROM_HERE, | 497 FROM_HERE, |
498 base::Bind(&net::ClearHttpCache, main_context_getter_, | 498 base::Bind(&net::ClearHttpCache, main_context_getter_, |
499 network_io_thread_->task_runner(), base::BindBlock(callback))); | 499 network_io_thread_->task_runner(), base::BindBlock(callback))); |
500 } | 500 } |
OLD | NEW |