summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 07:41:01 +0000
committerwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 07:41:01 +0000
commit1a6cdf49e9111738b3bd5e5236ec7c7f43416910 (patch)
tree7c91175712da0564db983b954b3c0f37490c9fc8 /remoting
parente41d7ddd66de84c0d521358d1478d9da77384563 (diff)
downloadchromium_src-1a6cdf49e9111738b3bd5e5236ec7c7f43416910.zip
chromium_src-1a6cdf49e9111738b3bd5e5236ec7c7f43416910.tar.gz
chromium_src-1a6cdf49e9111738b3bd5e5236ec7c7f43416910.tar.bz2
Make the UI-integration thread a non-UI thread in the Chrome sense.
BUG= TEST=remoting_simple_host should continue to work after this change is applied. Review URL: http://codereview.chromium.org/6975035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85738 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/chromoting_host_context.cc12
-rw-r--r--remoting/host/chromoting_host_context.h17
-rw-r--r--remoting/host/chromoting_host_context_unittest.cc4
-rw-r--r--remoting/host/event_executor.h4
-rw-r--r--remoting/host/event_executor_linux.cc10
-rw-r--r--remoting/host/event_executor_mac.cc8
-rw-r--r--remoting/host/event_executor_win.cc8
-rw-r--r--remoting/host/host_mock_objects.cc3
-rw-r--r--remoting/host/simple_host_process.cc6
9 files changed, 37 insertions, 35 deletions
diff --git a/remoting/host/chromoting_host_context.cc b/remoting/host/chromoting_host_context.cc
index 3e426f7..b1d9837 100644
--- a/remoting/host/chromoting_host_context.cc
+++ b/remoting/host/chromoting_host_context.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,10 +11,10 @@
namespace remoting {
-ChromotingHostContext::ChromotingHostContext(MessageLoopForUI* ui_message_loop)
+ChromotingHostContext::ChromotingHostContext()
: main_thread_("ChromotingMainThread"),
encode_thread_("ChromotingEncodeThread"),
- ui_message_loop_(ui_message_loop) {
+ ui_thread_("ChromotingUiThread") {
}
ChromotingHostContext::~ChromotingHostContext() {
@@ -25,6 +25,7 @@ void ChromotingHostContext::Start() {
main_thread_.Start();
encode_thread_.Start();
jingle_thread_.Start();
+ ui_thread_.Start();
}
void ChromotingHostContext::Stop() {
@@ -32,6 +33,7 @@ void ChromotingHostContext::Stop() {
jingle_thread_.Stop();
encode_thread_.Stop();
main_thread_.Stop();
+ ui_thread_.Stop();
}
JingleThread* ChromotingHostContext::jingle_thread() {
@@ -50,8 +52,8 @@ MessageLoop* ChromotingHostContext::network_message_loop() {
return jingle_thread_.message_loop();
}
-MessageLoopForUI* ChromotingHostContext::ui_message_loop() {
- return ui_message_loop_;
+MessageLoop* ChromotingHostContext::ui_message_loop() {
+ return ui_thread_.message_loop();
}
} // namespace remoting
diff --git a/remoting/host/chromoting_host_context.h b/remoting/host/chromoting_host_context.h
index 3b3c14f..609da46 100644
--- a/remoting/host/chromoting_host_context.h
+++ b/remoting/host/chromoting_host_context.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,13 +14,11 @@
namespace remoting {
// A class that manages threads and running context for the chromoting host
-// process.
+// process. This class is virtual only for testing purposes (see below).
class ChromotingHostContext {
public:
- // Create a context attached to the specified ui message loop. Since there
- // can only be one such loop on UNIX platforms, it has to be passed into
- // this object rather than being owned by it.
- explicit ChromotingHostContext(MessageLoopForUI* ui_message_loop);
+ // Create a context.
+ ChromotingHostContext();
virtual ~ChromotingHostContext();
// TODO(ajwong): Move the Start/Stop methods out of this class. Then
@@ -35,7 +33,7 @@ class ChromotingHostContext {
virtual MessageLoop* main_message_loop();
virtual MessageLoop* encode_message_loop();
virtual MessageLoop* network_message_loop();
- MessageLoopForUI* ui_message_loop();
+ virtual MessageLoop* ui_message_loop();
private:
FRIEND_TEST_ALL_PREFIXES(ChromotingHostContextTest, StartAndStop);
@@ -49,8 +47,9 @@ class ChromotingHostContext {
// A thread that hosts all encode operations.
base::Thread encode_thread_;
- // The main message loop.
- MessageLoopForUI* ui_message_loop_;
+ // A thread that hosts UI integration (capture, input injection, etc)
+ // This is NOT a Chrome-style UI thread.
+ base::Thread ui_thread_;
DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext);
};
diff --git a/remoting/host/chromoting_host_context_unittest.cc b/remoting/host/chromoting_host_context_unittest.cc
index 6fdda75..21bcab8 100644
--- a/remoting/host/chromoting_host_context_unittest.cc
+++ b/remoting/host/chromoting_host_context_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,7 +11,7 @@ namespace remoting {
// A simple test that starts and stop the context. This tests the context
// operates properly and all threads and message loops are valid.
TEST(ChromotingHostContextTest, StartAndStop) {
- ChromotingHostContext context(NULL);
+ ChromotingHostContext context;
context.Start();
EXPECT_TRUE(context.jingle_thread());
EXPECT_TRUE(context.main_message_loop());
diff --git a/remoting/host/event_executor.h b/remoting/host/event_executor.h
index 449c670..7dd6d43 100644
--- a/remoting/host/event_executor.h
+++ b/remoting/host/event_executor.h
@@ -7,7 +7,7 @@
#include "remoting/protocol/input_stub.h"
-class MessageLoopForUI;
+class MessageLoop;
namespace remoting {
@@ -16,7 +16,7 @@ class Capturer;
class EventExecutor : public protocol::InputStub {
public:
// Creates default event executor for the current platform.
- static EventExecutor* Create(MessageLoopForUI* message_loop,
+ static EventExecutor* Create(MessageLoop* message_loop,
Capturer* capturer);
};
diff --git a/remoting/host/event_executor_linux.cc b/remoting/host/event_executor_linux.cc
index 5f0ef92..04b57f7 100644
--- a/remoting/host/event_executor_linux.cc
+++ b/remoting/host/event_executor_linux.cc
@@ -27,7 +27,7 @@ namespace {
// A class to generate events on Linux.
class EventExecutorLinux : public EventExecutor {
public:
- EventExecutorLinux(MessageLoopForUI* message_loop, Capturer* capturer);
+ EventExecutorLinux(MessageLoop* message_loop, Capturer* capturer);
virtual ~EventExecutorLinux() {};
virtual void InjectKeyEvent(const KeyEvent* event, Task* done) OVERRIDE;
@@ -35,7 +35,7 @@ class EventExecutorLinux : public EventExecutor {
private:
bool Init();
- MessageLoopForUI* message_loop_;
+ MessageLoop* message_loop_;
Capturer* capturer_;
// X11 graphics context.
@@ -235,10 +235,10 @@ int ChromotocolKeycodeToX11Keysym(int32_t keycode) {
}
EventExecutorLinux::EventExecutorLinux(
- MessageLoopForUI* message_loop, Capturer* capturer)
+ MessageLoop* message_loop, Capturer* capturer)
: message_loop_(message_loop),
capturer_(capturer),
- display_(message_loop->GetDisplay()),
+ display_(XOpenDisplay(NULL)),
root_window_(BadValue),
width_(0),
height_(0) {
@@ -360,7 +360,7 @@ void EventExecutorLinux::InjectMouseEvent(const MouseEvent* event,
} // namespace
-EventExecutor* EventExecutor::Create(MessageLoopForUI* message_loop,
+EventExecutor* EventExecutor::Create(MessageLoop* message_loop,
Capturer* capturer) {
return new EventExecutorLinux(message_loop, capturer);
}
diff --git a/remoting/host/event_executor_mac.cc b/remoting/host/event_executor_mac.cc
index 96c8b01..5664f22 100644
--- a/remoting/host/event_executor_mac.cc
+++ b/remoting/host/event_executor_mac.cc
@@ -27,14 +27,14 @@ using protocol::KeyEvent;
// A class to generate events on Mac.
class EventExecutorMac : public EventExecutor {
public:
- EventExecutorMac(MessageLoopForUI* message_loop, Capturer* capturer);
+ EventExecutorMac(MessageLoop* message_loop, Capturer* capturer);
virtual ~EventExecutorMac() {}
virtual void InjectKeyEvent(const KeyEvent* event, Task* done) OVERRIDE;
virtual void InjectMouseEvent(const MouseEvent* event, Task* done) OVERRIDE;
private:
- MessageLoopForUI* message_loop_;
+ MessageLoop* message_loop_;
Capturer* capturer_;
int last_x_, last_y_;
int modifiers_, mouse_buttons_;
@@ -43,7 +43,7 @@ class EventExecutorMac : public EventExecutor {
};
EventExecutorMac::EventExecutorMac(
- MessageLoopForUI* message_loop, Capturer* capturer)
+ MessageLoop* message_loop, Capturer* capturer)
: message_loop_(message_loop),
capturer_(capturer), last_x_(0), last_y_(0), modifiers_(0),
mouse_buttons_(0) {
@@ -308,7 +308,7 @@ void EventExecutorMac::InjectMouseEvent(const MouseEvent* event, Task* done) {
} // namespace
-EventExecutor* EventExecutor::Create(MessageLoopForUI* message_loop,
+EventExecutor* EventExecutor::Create(MessageLoop* message_loop,
Capturer* capturer) {
return new EventExecutorMac(message_loop, capturer);
}
diff --git a/remoting/host/event_executor_win.cc b/remoting/host/event_executor_win.cc
index 2991ace..6eb2c9b 100644
--- a/remoting/host/event_executor_win.cc
+++ b/remoting/host/event_executor_win.cc
@@ -23,7 +23,7 @@ namespace {
// A class to generate events on Windows.
class EventExecutorWin : public EventExecutor {
public:
- EventExecutorWin(MessageLoopForUI* message_loop, Capturer* capturer);
+ EventExecutorWin(MessageLoop* message_loop, Capturer* capturer);
virtual ~EventExecutorWin() {}
virtual void InjectKeyEvent(const KeyEvent* event, Task* done) OVERRIDE;
@@ -33,13 +33,13 @@ class EventExecutorWin : public EventExecutor {
void HandleKey(const KeyEvent* event);
void HandleMouse(const MouseEvent* event);
- MessageLoopForUI* message_loop_;
+ MessageLoop* message_loop_;
Capturer* capturer_;
DISALLOW_COPY_AND_ASSIGN(EventExecutorWin);
};
-EventExecutorWin::EventExecutorWin(MessageLoopForUI* message_loop,
+EventExecutorWin::EventExecutorWin(MessageLoop* message_loop,
Capturer* capturer)
: message_loop_(message_loop),
capturer_(capturer) {
@@ -171,7 +171,7 @@ void EventExecutorWin::HandleMouse(const MouseEvent* event) {
} // namespace
-EventExecutor* EventExecutor::Create(MessageLoopForUI* message_loop,
+EventExecutor* EventExecutor::Create(MessageLoop* message_loop,
Capturer* capturer) {
return new EventExecutorWin(message_loop, capturer);
}
diff --git a/remoting/host/host_mock_objects.cc b/remoting/host/host_mock_objects.cc
index 41acc0d..9fbc108 100644
--- a/remoting/host/host_mock_objects.cc
+++ b/remoting/host/host_mock_objects.cc
@@ -22,8 +22,7 @@ Curtain* Curtain::Create() {
return new MockCurtain();
}
-MockChromotingHostContext::MockChromotingHostContext()
- : ChromotingHostContext(NULL) {}
+MockChromotingHostContext::MockChromotingHostContext() {}
MockChromotingHostContext::~MockChromotingHostContext() {}
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc
index 7684348..c1ed76a 100644
--- a/remoting/host/simple_host_process.cc
+++ b/remoting/host/simple_host_process.cc
@@ -100,9 +100,11 @@ class SimpleHost {
}
int Run() {
- MessageLoopForUI message_loop;
+ // |message_loop| is declared early so that any code we call into which
+ // requires a current message-loop won't complain.
+ MessageLoop message_loop;
- remoting::ChromotingHostContext context(&message_loop);
+ remoting::ChromotingHostContext context;
context.Start();
base::Thread file_io_thread("FileIO");