Commit 2eea4348 authored by Sergey Ulanov's avatar Sergey Ulanov

Use ProxyConfigServiceLinux in the chromoting host to configure proxy.

Previously chromoting host wasn't using proxies on linux because
ProxyConfigServiceLinux doesn't work in NPAPI plugins. Now it's not
a problem because we no longer support NPAPI.

BUG=410521,125104
R=jamiewalch@chromium.org, mmenke@chromium.org

Review URL: https://codereview.chromium.org/542473002

Cr-Commit-Position: refs/heads/master@{#293602}
parent 422789b6
......@@ -20,10 +20,7 @@ class SingleThreadTaskRunner;
namespace net {
// TODO(sergeyu): This class needs to be exported because remoting code
// creates it directly. Fix that and remove NET_EXPORT here.
// crbug.com/125104
class NET_EXPORT ProxyConfigServiceMac : public ProxyConfigService {
class ProxyConfigServiceMac : public ProxyConfigService {
public:
// Constructs a ProxyConfigService that watches the Mac OS system settings.
// This instance is expected to be operated and deleted on the same thread
......
......@@ -4,76 +4,20 @@
#include "remoting/base/url_request_context_getter.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/single_thread_task_runner.h"
#include "net/proxy/proxy_config_service.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "remoting/base/vlog_net_log.h"
#if defined(OS_WIN)
#include "net/proxy/proxy_config_service_win.h"
#elif defined(OS_IOS)
#include "net/proxy/proxy_config_service_ios.h"
#elif defined(OS_MACOSX)
#include "net/proxy/proxy_config_service_mac.h"
#elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
#include "net/proxy/proxy_config_service_linux.h"
#endif
namespace remoting {
namespace {
// Config getter that always returns direct settings.
class ProxyConfigServiceDirect : public net::ProxyConfigService {
public:
// ProxyConfigService implementation:
virtual void AddObserver(Observer* observer) OVERRIDE {}
virtual void RemoveObserver(Observer* observer) OVERRIDE {}
virtual ConfigAvailability GetLatestProxyConfig(
net::ProxyConfig* config) OVERRIDE {
*config = net::ProxyConfig::CreateDirect();
return CONFIG_VALID;
}
};
net::ProxyConfigService* CreateSystemProxyConfigService(
base::SingleThreadTaskRunner* io_thread_task_runner) {
#if defined(OS_WIN)
return new net::ProxyConfigServiceWin();
#elif defined(OS_IOS)
return new net::ProxyConfigServiceIOS();
#elif defined(OS_MACOSX)
return new net::ProxyConfigServiceMac(io_thread_task_runner);
#elif defined(OS_CHROMEOS)
NOTREACHED() << "ChromeOS is not a supported target for Chromoting host";
return NULL;
#elif defined(OS_LINUX)
// TODO(sergeyu): Currently ProxyConfigServiceLinux depends on
// base::OneShotTimer that doesn't work properly on main NPAPI
// thread. Fix that and uncomment the code below.
//
// net::ProxyConfigServiceLinux* linux_config_service =
// new net::ProxyConfigServiceLinux();
// linux_config_service->SetupAndFetchInitialConfig(
// ui_message_loop_, io_message_loop->message_loop_proxy(),
// file_message_loop);
// return linux_config_service;
return new ProxyConfigServiceDirect();
#else
LOG(WARNING) << "Failed to choose a system proxy settings fetcher "
"for this platform.";
return new ProxyConfigServiceDirect();
#endif
}
} // namespace
URLRequestContextGetter::URLRequestContextGetter(
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner)
: network_task_runner_(network_task_runner) {
proxy_config_service_.reset(CreateSystemProxyConfigService(
network_task_runner_.get()));
proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService(
network_task_runner_, file_task_runner));
}
net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
......
......@@ -5,26 +5,25 @@
#ifndef REMOTING_BASE_URL_REQUEST_CONTEXT_GETTER_H_
#define REMOTING_BASE_URL_REQUEST_CONTEXT_GETTER_H_
#include <string>
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "net/proxy/proxy_config_service.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_context_storage.h"
namespace base {
class MessageLoopProxy;
class SingleThreadTaskRunner;
} // namespace base
namespace net {
class ProxyConfigService;
} // namespace net
namespace remoting {
class URLRequestContextGetter : public net::URLRequestContextGetter {
public:
URLRequestContextGetter(
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner);
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner);
// Overridden from net::URLRequestContextGetter:
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
......
......@@ -191,7 +191,8 @@ ChromotingJniRuntime::ChromotingJniRuntime() {
display_task_runner_ = AutoThread::Create("native_disp",
ui_task_runner_);
url_requester_ = new URLRequestContextGetter(network_task_runner_);
url_requester_ =
new URLRequestContextGetter(network_task_runner_, network_task_runner_);
// Allows later decoding of video frames.
media::InitializeCPUSpecificYUVConversions();
......
......@@ -40,7 +40,7 @@ ChromotingHostContext::ChromotingHostContext(
"ChromotingEncodeThread", ui_task_runner_);
url_request_context_getter_ = new URLRequestContextGetter(
network_task_runner_);
network_task_runner_, file_task_runner_);
}
ChromotingHostContext::~ChromotingHostContext() {
......
......@@ -86,6 +86,10 @@ int StartMe2MeNativeMessagingHost() {
io_thread.StartWithOptions(
base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
base::Thread file_thread("file_thread");
file_thread.StartWithOptions(
base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
base::MessageLoopForUI message_loop;
base::RunLoop run_loop;
......@@ -174,9 +178,10 @@ int StartMe2MeNativeMessagingHost() {
#error Not implemented.
#endif
// OAuth client (for credential requests).
// OAuth client (for credential requests). IO thread is used for blocking
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter(
new URLRequestContextGetter(io_thread.message_loop_proxy()));
new URLRequestContextGetter(io_thread.task_runner(),
file_thread.task_runner()));
scoped_ptr<OAuthClient> oauth_client(
new OAuthClient(url_request_context_getter));
......@@ -225,11 +230,11 @@ int StartMe2MeNativeMessagingHost() {
return kInitializationFailed;
pairing_registry = new PairingRegistry(
io_thread.message_loop_proxy(),
io_thread.task_runner(),
delegate.PassAs<PairingRegistry::Delegate>());
#else // defined(OS_WIN)
pairing_registry =
CreatePairingRegistry(io_thread.message_loop_proxy());
CreatePairingRegistry(io_thread.task_runner());
#endif // !defined(OS_WIN)
// Set up the native messaging channel.
......
......@@ -145,12 +145,15 @@ int main(int argc, char** argv) {
// Provide message loops and threads for the URLRequestContextGetter.
base::MessageLoop message_loop;
g_message_loop = &message_loop;
base::Thread io_thread("IO thread");
base::Thread::Options io_thread_options(base::MessageLoop::TYPE_IO, 0);
base::Thread io_thread("IO thread");
io_thread.StartWithOptions(io_thread_options);
base::Thread file_thread("file thread");
file_thread.StartWithOptions(io_thread_options);
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter(
new remoting::URLRequestContextGetter(io_thread.message_loop_proxy()));
new remoting::URLRequestContextGetter(io_thread.task_runner(),
file_thread.task_runner()));
net::URLFetcher::SetIgnoreCertificateRequests(true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment