Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: remoting/host/url_request_context.cc

Issue 10173009: Always create URLRequestContextGetter in ChromotingHostContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/url_request_context.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "remoting/host/vlog_net_log.h"
18 18
19 #if defined(OS_WIN)
20 #include "net/proxy/proxy_config_service_win.h"
21 #elif defined(OS_MACOSX)
22 #include "net/proxy/proxy_config_service_mac.h"
23 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
24 #include "net/proxy/proxy_config_service_linux.h"
25 #endif
26
19 namespace remoting { 27 namespace remoting {
20 28
29 namespace {
30
31 // Config getter that always returns direct settings.
32 class ProxyConfigServiceDirect : public net::ProxyConfigService {
33 public:
34 // ProxyConfigService implementation:
35 virtual void AddObserver(Observer* observer) OVERRIDE {}
36 virtual void RemoveObserver(Observer* observer) OVERRIDE {}
37 virtual ConfigAvailability GetLatestProxyConfig(
38 net::ProxyConfig* config) OVERRIDE {
39 *config = net::ProxyConfig::CreateDirect();
40 return CONFIG_VALID;
41 }
42 };
43
44 net::ProxyConfigService* CreateSystemProxyConfigService(
45 base::MessageLoopProxy* ui_message_loop_,
46 MessageLoop* io_message_loop,
47 MessageLoopForIO* file_message_loop) {
48 DCHECK(ui_message_loop_->BelongsToCurrentThread());
49
50 #if defined(OS_WIN)
51 return new net::ProxyConfigServiceWin();
52 #elif defined(OS_MACOSX)
53 return new net::ProxyConfigServiceMac(io_message_loop);
54 #elif defined(OS_CHROMEOS)
55 NOTREACHED() << "ChromeOS is not a supported target for Chromoting host";
56 return NULL;
57 #elif defined(OS_LINUX)
58 // TODO(sergeyu): Currently ProxyConfigServiceLinux depends on
59 // base::OneShotTimer that doesn't work properly on main NPAPI
60 // thread. Fix that and uncomment the code below.
61 //
62 // net::ProxyConfigServiceLinux* linux_config_service =
63 // new net::ProxyConfigServiceLinux();
64 // linux_config_service->SetupAndFetchInitialConfig(
65 // ui_message_loop_, io_message_loop->message_loop_proxy(),
66 // file_message_loop);
67
68 // return linux_config_service;
69 return new ProxyConfigServiceDirect();
70 #else
71 LOG(WARNING) << "Failed to choose a system proxy settings fetcher "
72 "for this platform.";
73 return new ProxyConfigServiceDirect();
74 #endif
75 }
76
77 } // namespace
78
21 // TODO(willchan): This is largely copied from service_url_request_context.cc, 79 // TODO(willchan): This is largely copied from service_url_request_context.cc,
22 // which is in turn copied from some test code. Move it somewhere reusable. 80 // which is in turn copied from some test code. Move it somewhere reusable.
23 URLRequestContext::URLRequestContext( 81 URLRequestContext::URLRequestContext(
24 scoped_ptr<net::ProxyConfigService> proxy_config_service) 82 scoped_ptr<net::ProxyConfigService> proxy_config_service)
25 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) { 83 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) {
26 scoped_ptr<VlogNetLog> net_log(new VlogNetLog()); 84 scoped_ptr<VlogNetLog> net_log(new VlogNetLog());
27 storage_.set_host_resolver( 85 storage_.set_host_resolver(
28 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, 86 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
29 net::HostResolver::kDefaultRetryAttempts, 87 net::HostResolver::kDefaultRetryAttempts,
30 net_log.get())); 88 net_log.get()));
(...skipping 17 matching lines...) Expand all
48 new net::HttpNetworkSession(session_params)); 106 new net::HttpNetworkSession(session_params));
49 storage_.set_http_transaction_factory( 107 storage_.set_http_transaction_factory(
50 new net::HttpNetworkLayer(network_session)); 108 new net::HttpNetworkLayer(network_session));
51 storage_.set_net_log(net_log.release()); 109 storage_.set_net_log(net_log.release());
52 } 110 }
53 111
54 URLRequestContext::~URLRequestContext() { 112 URLRequestContext::~URLRequestContext() {
55 } 113 }
56 114
57 URLRequestContextGetter::URLRequestContextGetter( 115 URLRequestContextGetter::URLRequestContextGetter(
116 base::MessageLoopProxy* ui_message_loop,
58 MessageLoop* io_message_loop, 117 MessageLoop* io_message_loop,
59 MessageLoop* file_message_loop) 118 MessageLoopForIO* file_message_loop)
60 : io_message_loop_proxy_(io_message_loop->message_loop_proxy()) { 119 : io_message_loop_proxy_(io_message_loop->message_loop_proxy()) {
61 proxy_config_service_.reset( 120 proxy_config_service_.reset(CreateSystemProxyConfigService(
62 net::ProxyService::CreateSystemProxyConfigService( 121 ui_message_loop, io_message_loop, file_message_loop));
63 io_message_loop, file_message_loop));
64 } 122 }
65 123
66 net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { 124 net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
67 if (!url_request_context_) { 125 if (!url_request_context_) {
68 url_request_context_ = 126 url_request_context_ =
69 new URLRequestContext(proxy_config_service_.Pass()); 127 new URLRequestContext(proxy_config_service_.Pass());
70 } 128 }
71 return url_request_context_; 129 return url_request_context_;
72 } 130 }
73 131
74 scoped_refptr<base::MessageLoopProxy> 132 scoped_refptr<base::MessageLoopProxy>
75 URLRequestContextGetter::GetIOMessageLoopProxy() const { 133 URLRequestContextGetter::GetIOMessageLoopProxy() const {
76 return io_message_loop_proxy_; 134 return io_message_loop_proxy_;
77 } 135 }
78 136
79 URLRequestContextGetter::~URLRequestContextGetter() {} 137 URLRequestContextGetter::~URLRequestContextGetter() {}
80 138
81 } // namespace remoting 139 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/url_request_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698