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