summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-25 20:48:50 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-25 20:48:50 +0000
commit92e1a00ddcbb8b672368046bfeda5f6c145d777c (patch)
treee53c51427cec9312d211578c2614d0ec4317b4d9 /remoting
parent8affc2428b6c8a81618056c55207566394f2fc06 (diff)
downloadchromium_src-92e1a00ddcbb8b672368046bfeda5f6c145d777c.zip
chromium_src-92e1a00ddcbb8b672368046bfeda5f6c145d777c.tar.gz
chromium_src-92e1a00ddcbb8b672368046bfeda5f6c145d777c.tar.bz2
Always create URLRequestContextGetter in ChromotingHostContext.
BUG=124728 Review URL: http://codereview.chromium.org/10173009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133974 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/chromoting_host_context.cc10
-rw-r--r--remoting/host/url_fetcher_unittest.cc6
-rw-r--r--remoting/host/url_request_context.cc66
-rw-r--r--remoting/host/url_request_context.h5
4 files changed, 72 insertions, 15 deletions
diff --git a/remoting/host/chromoting_host_context.cc b/remoting/host/chromoting_host_context.cc
index 57571a9..1eaa454 100644
--- a/remoting/host/chromoting_host_context.cc
+++ b/remoting/host/chromoting_host_context.cc
@@ -37,13 +37,9 @@ bool ChromotingHostContext::Start() {
if (!started)
return false;
- // net::ProxyService::CreateSystemProxyConfigService requires a UI thread.
- // TODO(jamiewalch): Clean up this dependency.
- MessageLoop* loop = MessageLoop::current();
- if (loop && loop->type() == MessageLoop::TYPE_UI) {
- url_request_context_getter_ = new URLRequestContextGetter(
- io_thread_.message_loop(), file_thread_.message_loop());
- }
+ url_request_context_getter_ = new URLRequestContextGetter(
+ ui_message_loop_, io_thread_.message_loop(),
+ static_cast<MessageLoopForIO*>(file_thread_.message_loop()));
return true;
}
diff --git a/remoting/host/url_fetcher_unittest.cc b/remoting/host/url_fetcher_unittest.cc
index 614474e..811fe41 100644
--- a/remoting/host/url_fetcher_unittest.cc
+++ b/remoting/host/url_fetcher_unittest.cc
@@ -31,8 +31,10 @@ class UrlFetcherTest : public testing::Test {
base::Thread::Options(MessageLoop::TYPE_IO, 0)));
ASSERT_TRUE(file_thread_.StartWithOptions(
base::Thread::Options(MessageLoop::TYPE_IO, 0)));
- context_getter_ = new URLRequestContextGetter(io_thread_.message_loop(),
- file_thread_.message_loop());
+ context_getter_ = new URLRequestContextGetter(
+ message_loop_.message_loop_proxy(),
+ io_thread_.message_loop(),
+ static_cast<MessageLoopForIO*>(file_thread_.message_loop()));
ASSERT_TRUE(test_server_.Start());
}
diff --git a/remoting/host/url_request_context.cc b/remoting/host/url_request_context.cc
index 0e23350..901dc09 100644
--- a/remoting/host/url_request_context.cc
+++ b/remoting/host/url_request_context.cc
@@ -16,8 +16,66 @@
#include "net/proxy/proxy_service.h"
#include "remoting/host/vlog_net_log.h"
+#if defined(OS_WIN)
+#include "net/proxy/proxy_config_service_win.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::MessageLoopProxy* ui_message_loop_,
+ MessageLoop* io_message_loop,
+ MessageLoopForIO* file_message_loop) {
+ DCHECK(ui_message_loop_->BelongsToCurrentThread());
+
+#if defined(OS_WIN)
+ return new net::ProxyConfigServiceWin();
+#elif defined(OS_MACOSX)
+ return new net::ProxyConfigServiceMac(io_message_loop);
+#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
+
// TODO(willchan): This is largely copied from service_url_request_context.cc,
// which is in turn copied from some test code. Move it somewhere reusable.
URLRequestContext::URLRequestContext(
@@ -55,12 +113,12 @@ URLRequestContext::~URLRequestContext() {
}
URLRequestContextGetter::URLRequestContextGetter(
+ base::MessageLoopProxy* ui_message_loop,
MessageLoop* io_message_loop,
- MessageLoop* file_message_loop)
+ MessageLoopForIO* file_message_loop)
: io_message_loop_proxy_(io_message_loop->message_loop_proxy()) {
- proxy_config_service_.reset(
- net::ProxyService::CreateSystemProxyConfigService(
- io_message_loop, file_message_loop));
+ proxy_config_service_.reset(CreateSystemProxyConfigService(
+ ui_message_loop, io_message_loop, file_message_loop));
}
net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
diff --git a/remoting/host/url_request_context.h b/remoting/host/url_request_context.h
index 9461275..5c0c6ee 100644
--- a/remoting/host/url_request_context.h
+++ b/remoting/host/url_request_context.h
@@ -39,8 +39,9 @@ class URLRequestContext : public net::URLRequestContext {
class URLRequestContextGetter : public net::URLRequestContextGetter {
public:
- URLRequestContextGetter(MessageLoop* io_message_loop,
- MessageLoop* file_message_loop);
+ URLRequestContextGetter(base::MessageLoopProxy* ui_message_loop,
+ MessageLoop* io_message_loop,
+ MessageLoopForIO* file_message_loop);
// Overridden from net::URLRequestContextGetter:
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;