| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/url_request_context.h" | 5 #include "remoting/host/url_request_context.h" |
| 6 | 6 |
| 7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
| 8 #include "net/base/cert_verifier.h" | 8 #include "net/base/cert_verifier.h" |
| 9 #include "net/base/host_resolver.h" | 9 #include "net/base/host_resolver.h" |
| 10 #include "net/base/ssl_config_service_defaults.h" | 10 #include "net/base/ssl_config_service_defaults.h" |
| 11 #include "net/http/http_auth_handler_factory.h" | 11 #include "net/http/http_auth_handler_factory.h" |
| 12 #include "net/http/http_network_layer.h" | 12 #include "net/http/http_network_layer.h" |
| 13 #include "net/http/http_network_session.h" | 13 #include "net/http/http_network_session.h" |
| 14 #include "net/http/http_server_properties_impl.h" | 14 #include "net/http/http_server_properties_impl.h" |
| 15 #include "net/proxy/proxy_config_service.h" | 15 #include "net/proxy/proxy_config_service.h" |
| 16 #include "net/proxy/proxy_service.h" | 16 #include "net/proxy/proxy_service.h" |
| 17 #include "remoting/host/vlog_net_log.h" |
| 17 | 18 |
| 18 namespace remoting { | 19 namespace remoting { |
| 19 | 20 |
| 20 // TODO(willchan): This is largely copied from service_url_request_context.cc, | 21 // TODO(willchan): This is largely copied from service_url_request_context.cc, |
| 21 // which is in turn copied from some test code. Move it somewhere reusable. | 22 // which is in turn copied from some test code. Move it somewhere reusable. |
| 22 URLRequestContext::URLRequestContext( | 23 URLRequestContext::URLRequestContext( |
| 23 net::ProxyConfigService* proxy_config_service) | 24 scoped_ptr<net::ProxyConfigService> proxy_config_service) |
| 24 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) { | 25 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) { |
| 25 net_log_.reset(new VlogNetLog()); | 26 scoped_ptr<VlogNetLog> net_log(new VlogNetLog()); |
| 26 | |
| 27 storage_.set_host_resolver( | 27 storage_.set_host_resolver( |
| 28 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, | 28 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, |
| 29 net::HostResolver::kDefaultRetryAttempts, | 29 net::HostResolver::kDefaultRetryAttempts, |
| 30 net_log_.get())); | 30 net_log.get())); |
| 31 storage_.set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver( | 31 storage_.set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver( |
| 32 proxy_config_service, 0u, net_log_.get())); | 32 proxy_config_service.release(), 0u, net_log.get())); |
| 33 storage_.set_cert_verifier(net::CertVerifier::CreateDefault()); | 33 storage_.set_cert_verifier(net::CertVerifier::CreateDefault()); |
| 34 storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults); | 34 storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults); |
| 35 storage_.set_http_auth_handler_factory( | 35 storage_.set_http_auth_handler_factory( |
| 36 net::HttpAuthHandlerFactory::CreateDefault(host_resolver())); | 36 net::HttpAuthHandlerFactory::CreateDefault(host_resolver())); |
| 37 storage_.set_http_server_properties(new net::HttpServerPropertiesImpl); | 37 storage_.set_http_server_properties(new net::HttpServerPropertiesImpl); |
| 38 | 38 |
| 39 net::HttpNetworkSession::Params session_params; | 39 net::HttpNetworkSession::Params session_params; |
| 40 session_params.host_resolver = host_resolver(); | 40 session_params.host_resolver = host_resolver(); |
| 41 session_params.cert_verifier = cert_verifier(); | 41 session_params.cert_verifier = cert_verifier(); |
| 42 session_params.proxy_service = proxy_service(); | 42 session_params.proxy_service = proxy_service(); |
| 43 session_params.ssl_config_service = ssl_config_service(); | 43 session_params.ssl_config_service = ssl_config_service(); |
| 44 session_params.http_auth_handler_factory = http_auth_handler_factory(); | 44 session_params.http_auth_handler_factory = http_auth_handler_factory(); |
| 45 session_params.http_server_properties = http_server_properties(); | 45 session_params.http_server_properties = http_server_properties(); |
| 46 session_params.net_log = net_log_.get(); | 46 session_params.net_log = net_log.get(); |
| 47 scoped_refptr<net::HttpNetworkSession> network_session( | 47 scoped_refptr<net::HttpNetworkSession> network_session( |
| 48 new net::HttpNetworkSession(session_params)); | 48 new net::HttpNetworkSession(session_params)); |
| 49 storage_.set_http_transaction_factory( | 49 storage_.set_http_transaction_factory( |
| 50 new net::HttpNetworkLayer(network_session)); | 50 new net::HttpNetworkLayer(network_session)); |
| 51 storage_.set_net_log(net_log.release()); |
| 51 } | 52 } |
| 52 | 53 |
| 53 URLRequestContext::~URLRequestContext() { | 54 URLRequestContext::~URLRequestContext() { |
| 54 } | 55 } |
| 55 | 56 |
| 56 URLRequestContextGetter::URLRequestContextGetter( | 57 URLRequestContextGetter::URLRequestContextGetter( |
| 57 MessageLoop* io_message_loop, | 58 MessageLoop* io_message_loop, |
| 58 MessageLoop* file_message_loop) | 59 MessageLoop* file_message_loop) |
| 59 : io_message_loop_proxy_(io_message_loop->message_loop_proxy()) { | 60 : io_message_loop_proxy_(io_message_loop->message_loop_proxy()) { |
| 60 proxy_config_service_.reset( | 61 proxy_config_service_.reset( |
| 61 net::ProxyService::CreateSystemProxyConfigService( | 62 net::ProxyService::CreateSystemProxyConfigService( |
| 62 io_message_loop, file_message_loop)); | 63 io_message_loop, file_message_loop)); |
| 63 } | 64 } |
| 64 | 65 |
| 65 net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { | 66 net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { |
| 66 if (!url_request_context_) | 67 if (!url_request_context_) { |
| 67 url_request_context_ = | 68 url_request_context_ = |
| 68 new URLRequestContext(proxy_config_service_.get()); | 69 new URLRequestContext(proxy_config_service_.Pass()); |
| 70 } |
| 69 return url_request_context_; | 71 return url_request_context_; |
| 70 } | 72 } |
| 71 | 73 |
| 72 scoped_refptr<base::MessageLoopProxy> | 74 scoped_refptr<base::MessageLoopProxy> |
| 73 URLRequestContextGetter::GetIOMessageLoopProxy() const { | 75 URLRequestContextGetter::GetIOMessageLoopProxy() const { |
| 74 return io_message_loop_proxy_; | 76 return io_message_loop_proxy_; |
| 75 } | 77 } |
| 76 | 78 |
| 77 URLRequestContextGetter::~URLRequestContextGetter() {} | 79 URLRequestContextGetter::~URLRequestContextGetter() {} |
| 78 | 80 |
| 79 } // namespace remoting | 81 } // namespace remoting |
| OLD | NEW |