| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "mojo/loader/url_request_context_getter.h" | 5 #include "mojo/loader/url_request_context_getter.h" |
| 6 | 6 |
| 7 #include "net/cookies/cookie_monster.h" | 7 #include "net/cookies/cookie_monster.h" |
| 8 #include "net/http/http_cache.h" | 8 #include "net/http/http_cache.h" |
| 9 #include "net/http/http_network_session.h" | 9 #include "net/http/http_network_session.h" |
| 10 #include "net/http/http_server_properties_impl.h" | 10 #include "net/http/http_server_properties_impl.h" |
| 11 #include "net/proxy/proxy_service.h" | 11 #include "net/proxy/proxy_service.h" |
| 12 #include "net/ssl/ssl_config_service_defaults.h" | 12 #include "net/ssl/ssl_config_service_defaults.h" |
| 13 #include "net/url_request/file_protocol_handler.h" |
| 13 #include "net/url_request/static_http_user_agent_settings.h" | 14 #include "net/url_request/static_http_user_agent_settings.h" |
| 14 #include "net/url_request/url_request_context.h" | 15 #include "net/url_request/url_request_context.h" |
| 16 #include "net/url_request/url_request_file_job.h" |
| 15 #include "net/url_request/url_request_job_factory_impl.h" | 17 #include "net/url_request/url_request_job_factory_impl.h" |
| 16 | 18 |
| 17 namespace mojo { | 19 namespace mojo { |
| 18 namespace loader { | 20 namespace loader { |
| 19 | 21 |
| 20 URLRequestContextGetter::URLRequestContextGetter( | 22 URLRequestContextGetter::URLRequestContextGetter( |
| 21 base::FilePath base_path, | 23 base::FilePath base_path, |
| 22 base::SingleThreadTaskRunner* network_task_runner, | 24 base::SingleThreadTaskRunner* network_task_runner, |
| 23 base::MessageLoopProxy* cache_task_runner) | 25 base::SingleThreadTaskRunner* file_task_runner, |
| 26 base::MessageLoopProxy* cache_task_runner, |
| 27 scoped_ptr<net::NetworkDelegate> network_delegate) |
| 24 : base_path_(base_path), | 28 : base_path_(base_path), |
| 29 file_task_runner_(file_task_runner), |
| 25 network_task_runner_(network_task_runner), | 30 network_task_runner_(network_task_runner), |
| 26 cache_task_runner_(cache_task_runner), | 31 cache_task_runner_(cache_task_runner), |
| 32 network_delegate_(network_delegate.Pass()), |
| 27 net_log_(new net::NetLog()) { | 33 net_log_(new net::NetLog()) { |
| 28 } | 34 } |
| 29 | 35 |
| 30 URLRequestContextGetter::~URLRequestContextGetter() { | 36 URLRequestContextGetter::~URLRequestContextGetter() { |
| 31 } | 37 } |
| 32 | 38 |
| 33 net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { | 39 net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { |
| 34 if (!url_request_context_) { | 40 if (!url_request_context_) { |
| 35 url_request_context_.reset(new net::URLRequestContext()); | 41 url_request_context_.reset(new net::URLRequestContext()); |
| 36 url_request_context_->set_net_log(net_log_.get()); | 42 url_request_context_->set_net_log(net_log_.get()); |
| 43 url_request_context_->set_network_delegate(network_delegate_.get()); |
| 37 | 44 |
| 38 storage_.reset( | 45 storage_.reset( |
| 39 new net::URLRequestContextStorage(url_request_context_.get())); | 46 new net::URLRequestContextStorage(url_request_context_.get())); |
| 40 | 47 |
| 41 storage_->set_cookie_store(new net::CookieMonster(NULL, NULL)); | 48 storage_->set_cookie_store(new net::CookieMonster(NULL, NULL)); |
| 42 storage_->set_http_user_agent_settings( | 49 storage_->set_http_user_agent_settings( |
| 43 new net::StaticHttpUserAgentSettings("en-us,en", "Mojo/0.1")); | 50 new net::StaticHttpUserAgentSettings("en-us,en", "Mojo/0.1")); |
| 44 | 51 |
| 45 storage_->set_proxy_service(net::ProxyService::CreateDirect()); | 52 storage_->set_proxy_service(net::ProxyService::CreateDirect()); |
| 46 storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults); | 53 storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 71 cache_path, | 78 cache_path, |
| 72 0, | 79 0, |
| 73 cache_task_runner_.get()); | 80 cache_task_runner_.get()); |
| 74 | 81 |
| 75 net::HttpCache* main_cache = new net::HttpCache( | 82 net::HttpCache* main_cache = new net::HttpCache( |
| 76 network_session_params, main_backend); | 83 network_session_params, main_backend); |
| 77 storage_->set_http_transaction_factory(main_cache); | 84 storage_->set_http_transaction_factory(main_cache); |
| 78 | 85 |
| 79 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 86 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
| 80 new net::URLRequestJobFactoryImpl()); | 87 new net::URLRequestJobFactoryImpl()); |
| 81 | 88 job_factory->SetProtocolHandler( |
| 89 "file", |
| 90 new net::FileProtocolHandler(file_task_runner_)); |
| 82 storage_->set_job_factory(job_factory.release()); | 91 storage_->set_job_factory(job_factory.release()); |
| 83 } | 92 } |
| 84 | 93 |
| 85 return url_request_context_.get(); | 94 return url_request_context_.get(); |
| 86 } | 95 } |
| 87 | 96 |
| 88 scoped_refptr<base::SingleThreadTaskRunner> | 97 scoped_refptr<base::SingleThreadTaskRunner> |
| 89 URLRequestContextGetter::GetNetworkTaskRunner() const { | 98 URLRequestContextGetter::GetNetworkTaskRunner() const { |
| 90 return network_task_runner_; | 99 return network_task_runner_; |
| 91 } | 100 } |
| 92 | 101 |
| 93 } // namespace loader | 102 } // namespace loader |
| 94 } // namespace mojo | 103 } // namespace mojo |
| OLD | NEW |