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

Side by Side Diff: remoting/base/url_request_context_getter.cc

Issue 542473002: Uses ProxyConfigServiceLinux in the chromoting host to configure proxy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « remoting/base/url_request_context_getter.h ('k') | remoting/host/chromoting_host_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "remoting/base/url_request_context_getter.h" 5 #include "remoting/base/url_request_context_getter.h"
6 6
7 #include "base/message_loop/message_loop_proxy.h" 7 #include "base/single_thread_task_runner.h"
8 #include "net/proxy/proxy_config_service.h" 8 #include "net/proxy/proxy_config_service.h"
9 #include "net/url_request/url_request_context.h"
9 #include "net/url_request/url_request_context_builder.h" 10 #include "net/url_request/url_request_context_builder.h"
10 #include "remoting/base/vlog_net_log.h" 11 #include "remoting/base/vlog_net_log.h"
11 12
12 #if defined(OS_WIN)
13 #include "net/proxy/proxy_config_service_win.h"
14 #elif defined(OS_IOS)
15 #include "net/proxy/proxy_config_service_ios.h"
16 #elif defined(OS_MACOSX)
17 #include "net/proxy/proxy_config_service_mac.h"
18 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
19 #include "net/proxy/proxy_config_service_linux.h"
20 #endif
21
22 namespace remoting { 13 namespace remoting {
23 14
24 namespace {
25
26 // Config getter that always returns direct settings.
27 class ProxyConfigServiceDirect : public net::ProxyConfigService {
28 public:
29 // ProxyConfigService implementation:
30 virtual void AddObserver(Observer* observer) OVERRIDE {}
31 virtual void RemoveObserver(Observer* observer) OVERRIDE {}
32 virtual ConfigAvailability GetLatestProxyConfig(
33 net::ProxyConfig* config) OVERRIDE {
34 *config = net::ProxyConfig::CreateDirect();
35 return CONFIG_VALID;
36 }
37 };
38
39 net::ProxyConfigService* CreateSystemProxyConfigService(
40 base::SingleThreadTaskRunner* io_thread_task_runner) {
41 #if defined(OS_WIN)
42 return new net::ProxyConfigServiceWin();
mmenke 2014/09/04 16:17:40 So this was relying on NET_EXPORT_PRIVATE not actu
43 #elif defined(OS_IOS)
44 return new net::ProxyConfigServiceIOS();
45 #elif defined(OS_MACOSX)
46 return new net::ProxyConfigServiceMac(io_thread_task_runner);
47 #elif defined(OS_CHROMEOS)
48 NOTREACHED() << "ChromeOS is not a supported target for Chromoting host";
49 return NULL;
50 #elif defined(OS_LINUX)
51 // TODO(sergeyu): Currently ProxyConfigServiceLinux depends on
52 // base::OneShotTimer that doesn't work properly on main NPAPI
53 // thread. Fix that and uncomment the code below.
54 //
55 // net::ProxyConfigServiceLinux* linux_config_service =
56 // new net::ProxyConfigServiceLinux();
57 // linux_config_service->SetupAndFetchInitialConfig(
58 // ui_message_loop_, io_message_loop->message_loop_proxy(),
59 // file_message_loop);
60
61 // return linux_config_service;
62 return new ProxyConfigServiceDirect();
63 #else
64 LOG(WARNING) << "Failed to choose a system proxy settings fetcher "
65 "for this platform.";
66 return new ProxyConfigServiceDirect();
67 #endif
68 }
69
70 } // namespace
71
72 URLRequestContextGetter::URLRequestContextGetter( 15 URLRequestContextGetter::URLRequestContextGetter(
73 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) 16 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
17 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner)
74 : network_task_runner_(network_task_runner) { 18 : network_task_runner_(network_task_runner) {
75 proxy_config_service_.reset(CreateSystemProxyConfigService( 19 proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService(
76 network_task_runner_.get())); 20 network_task_runner_, file_task_runner));
77 } 21 }
78 22
79 net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { 23 net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
80 if (!url_request_context_.get()) { 24 if (!url_request_context_.get()) {
81 net::URLRequestContextBuilder builder; 25 net::URLRequestContextBuilder builder;
82 builder.set_net_log(new VlogNetLog()); 26 builder.set_net_log(new VlogNetLog());
83 builder.DisableHttpCache(); 27 builder.DisableHttpCache();
84 builder.set_proxy_config_service(proxy_config_service_.release()); 28 builder.set_proxy_config_service(proxy_config_service_.release());
85 url_request_context_.reset(builder.Build()); 29 url_request_context_.reset(builder.Build());
86 } 30 }
87 return url_request_context_.get(); 31 return url_request_context_.get();
88 } 32 }
89 33
90 scoped_refptr<base::SingleThreadTaskRunner> 34 scoped_refptr<base::SingleThreadTaskRunner>
91 URLRequestContextGetter::GetNetworkTaskRunner() const { 35 URLRequestContextGetter::GetNetworkTaskRunner() const {
92 return network_task_runner_; 36 return network_task_runner_;
93 } 37 }
94 38
95 URLRequestContextGetter::~URLRequestContextGetter() { 39 URLRequestContextGetter::~URLRequestContextGetter() {
96 } 40 }
97 41
98 } // namespace remoting 42 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/url_request_context_getter.h ('k') | remoting/host/chromoting_host_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698