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

Unified Diff: remoting/host/session_event_executor_win.cc

Issue 10572005: Use SingleThreadTaskRunner instead of MessageLoopProxy in remoting/host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/session_event_executor_win.h ('k') | remoting/host/simple_host_process.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/session_event_executor_win.cc
diff --git a/remoting/host/session_event_executor_win.cc b/remoting/host/session_event_executor_win.cc
index 8168ccc15d63853f628f1910c872bc6b9cbf99c4..1bda46386a351983864de08054a65d489ced7aca 100644
--- a/remoting/host/session_event_executor_win.cc
+++ b/remoting/host/session_event_executor_win.cc
@@ -9,7 +9,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
-#include "base/message_loop.h"
+#include "base/single_thread_task_runner.h"
#include "base/win/windows_version.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
@@ -29,7 +29,7 @@ const uint32 kUsbLeftAlt = 0x0700e2;
const uint32 kUsbRightAlt = 0x0700e6;
const uint32 kUsbDelete = 0x07004c;
-bool areCtrlAndAltPressed(const std::set<uint32>& pressed_keys) {
+bool CheckCtrlAndAltArePressed(const std::set<uint32>& pressed_keys) {
size_t ctrl_keys = pressed_keys.count(kUsbLeftControl) +
pressed_keys.count(kUsbRightControl);
size_t alt_keys = pressed_keys.count(kUsbLeftAlt) +
@@ -41,7 +41,7 @@ bool areCtrlAndAltPressed(const std::set<uint32>& pressed_keys) {
// Emulates Secure Attention Sequence (Ctrl+Alt+Del) by switching to
// the Winlogon desktop and injecting Ctrl+Alt+Del as a hot key.
// N.B. Windows XP/W2K3 only.
-void emulateSecureAttentionSequence() {
+void EmulateSecureAttentionSequence() {
const wchar_t kWinlogonDesktopName[] = L"Winlogon";
const wchar_t kSasWindowClassName[] = L"SAS window class";
const wchar_t kSasWindowTitle[] = L"SAS window";
@@ -74,16 +74,16 @@ using protocol::MouseEvent;
using protocol::KeyEvent;
SessionEventExecutorWin::SessionEventExecutorWin(
- MessageLoop* message_loop,
- base::MessageLoopProxy* io_message_loop,
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_ptr<EventExecutor> nested_executor)
: nested_executor_(nested_executor.Pass()),
- message_loop_(message_loop),
+ task_runner_(main_task_runner),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
weak_ptr_(weak_ptr_factory_.GetWeakPtr()) {
- // Let weak_ptr_ be used on the message_loop_ thread.
- // weak_ptr_ and weak_ptr_factory_ share a ThreadChecker, so the following
- // line affects both of them.
+ // Let |weak_ptr_| be used on the |task_runner_| thread.
+ // |weak_ptr_| and |weak_ptr_factory_| share a ThreadChecker, so the
+ // following line affects both of them.
weak_ptr_factory_.DetachFromThread();
std::string channel_name =
@@ -93,21 +93,18 @@ SessionEventExecutorWin::SessionEventExecutorWin(
// line.
if (!channel_name.empty()) {
chromoting_channel_.reset(new IPC::ChannelProxy(
- channel_name,
- IPC::Channel::MODE_CLIENT,
- this,
- io_message_loop));
+ channel_name, IPC::Channel::MODE_CLIENT, this, io_task_runner));
}
}
SessionEventExecutorWin::~SessionEventExecutorWin() {
- DCHECK(MessageLoop::current() == message_loop_);
+ DCHECK(task_runner_->BelongsToCurrentThread());
}
void SessionEventExecutorWin::OnSessionStarted(
scoped_ptr<protocol::ClipboardStub> client_clipboard) {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
+ if (!task_runner_->BelongsToCurrentThread()) {
+ task_runner_->PostTask(
FROM_HERE,
base::Bind(&SessionEventExecutorWin::OnSessionStarted,
weak_ptr_, base::Passed(&client_clipboard)));
@@ -118,8 +115,8 @@ void SessionEventExecutorWin::OnSessionStarted(
}
void SessionEventExecutorWin::OnSessionFinished() {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
+ if (!task_runner_->BelongsToCurrentThread()) {
+ task_runner_->PostTask(
FROM_HERE,
base::Bind(&SessionEventExecutorWin::OnSessionFinished,
weak_ptr_));
@@ -131,8 +128,8 @@ void SessionEventExecutorWin::OnSessionFinished() {
void SessionEventExecutorWin::InjectClipboardEvent(
const ClipboardEvent& event) {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
+ if (!task_runner_->BelongsToCurrentThread()) {
+ task_runner_->PostTask(
FROM_HERE,
base::Bind(&SessionEventExecutorWin::InjectClipboardEvent,
weak_ptr_, event));
@@ -143,8 +140,8 @@ void SessionEventExecutorWin::InjectClipboardEvent(
}
void SessionEventExecutorWin::InjectKeyEvent(const KeyEvent& event) {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
+ if (!task_runner_->BelongsToCurrentThread()) {
+ task_runner_->PostTask(
FROM_HERE,
base::Bind(&SessionEventExecutorWin::InjectKeyEvent,
weak_ptr_, event));
@@ -158,11 +155,11 @@ void SessionEventExecutorWin::InjectKeyEvent(const KeyEvent& event) {
if (event.pressed()) {
// Simulate secure attention sequence if Ctrl-Alt-Del was just pressed.
if (event.usb_keycode() == kUsbDelete &&
- areCtrlAndAltPressed(pressed_keys_)) {
+ CheckCtrlAndAltArePressed(pressed_keys_)) {
VLOG(3) << "Sending Secure Attention Sequence to console";
if (base::win::GetVersion() == base::win::VERSION_XP) {
- emulateSecureAttentionSequence();
+ EmulateSecureAttentionSequence();
} else if (chromoting_channel_.get()) {
chromoting_channel_->Send(new ChromotingHostMsg_SendSasToConsole());
}
@@ -179,8 +176,8 @@ void SessionEventExecutorWin::InjectKeyEvent(const KeyEvent& event) {
}
void SessionEventExecutorWin::InjectMouseEvent(const MouseEvent& event) {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
+ if (!task_runner_->BelongsToCurrentThread()) {
+ task_runner_->PostTask(
FROM_HERE,
base::Bind(&SessionEventExecutorWin::InjectMouseEvent,
weak_ptr_, event));
« no previous file with comments | « remoting/host/session_event_executor_win.h ('k') | remoting/host/simple_host_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698