Index: remoting/host/client_session.cc |
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc |
index 9baf6f7d58d2b802054ebbd4194bf4188662d209..e063fdac316c04ea569cfc2f3fffe78521609d29 100644 |
--- a/remoting/host/client_session.cc |
+++ b/remoting/host/client_session.cc |
@@ -28,7 +28,7 @@ using protocol::MouseEvent; |
ClientSession::ClientSession( |
EventHandler* event_handler, |
- scoped_refptr<protocol::ConnectionToClient> connection, |
+ protocol::ConnectionToClient* connection, |
protocol::InputStub* input_stub, |
Capturer* capturer) |
: event_handler_(event_handler), |
@@ -52,6 +52,8 @@ ClientSession::~ClientSession() { |
} |
void ClientSession::InjectKeyEvent(const KeyEvent& event) { |
+ DCHECK(CalledOnValidThread()); |
+ |
if (authenticated_ && !ShouldIgnoreRemoteKeyboardInput(event)) { |
RecordKeyEvent(event); |
input_stub_->InjectKeyEvent(event); |
@@ -59,6 +61,8 @@ void ClientSession::InjectKeyEvent(const KeyEvent& event) { |
} |
void ClientSession::InjectMouseEvent(const MouseEvent& event) { |
+ DCHECK(CalledOnValidThread()); |
+ |
if (authenticated_ && !ShouldIgnoreRemoteMouseInput(event)) { |
RecordMouseButtonState(event); |
MouseEvent event_to_inject = event; |
@@ -91,6 +95,7 @@ void ClientSession::InjectMouseEvent(const MouseEvent& event) { |
void ClientSession::OnConnectionOpened( |
protocol::ConnectionToClient* connection) { |
+ DCHECK(CalledOnValidThread()); |
DCHECK_EQ(connection_.get(), connection); |
authenticated_ = true; |
event_handler_->OnSessionAuthenticated(this); |
@@ -98,27 +103,29 @@ void ClientSession::OnConnectionOpened( |
void ClientSession::OnConnectionClosed( |
protocol::ConnectionToClient* connection) { |
+ DCHECK(CalledOnValidThread()); |
DCHECK_EQ(connection_.get(), connection); |
- scoped_refptr<ClientSession> self = this; |
event_handler_->OnSessionClosed(this); |
} |
void ClientSession::OnConnectionFailed( |
protocol::ConnectionToClient* connection) { |
+ DCHECK(CalledOnValidThread()); |
DCHECK_EQ(connection_.get(), connection); |
// TODO(sergeyu): Log failure reason? |
- scoped_refptr<ClientSession> self = this; |
event_handler_->OnSessionClosed(this); |
} |
void ClientSession::OnSequenceNumberUpdated( |
protocol::ConnectionToClient* connection, int64 sequence_number) { |
+ DCHECK(CalledOnValidThread()); |
DCHECK_EQ(connection_.get(), connection); |
event_handler_->OnSessionSequenceNumber(this, sequence_number); |
} |
void ClientSession::Disconnect() { |
- DCHECK(connection_); |
+ DCHECK(CalledOnValidThread()); |
+ DCHECK(connection_.get()); |
authenticated_ = false; |
RestoreEventState(); |
@@ -128,6 +135,8 @@ void ClientSession::Disconnect() { |
} |
void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) { |
+ DCHECK(CalledOnValidThread()); |
+ |
// If this is a genuine local input event (rather than an echo of a remote |
// input event that we've just injected), then ignore remote inputs for a |
// short time. |
@@ -152,6 +161,8 @@ void ClientSession::LocalMouseMoved(const SkIPoint& mouse_pos) { |
bool ClientSession::ShouldIgnoreRemoteMouseInput( |
const protocol::MouseEvent& event) const { |
+ DCHECK(CalledOnValidThread()); |
+ |
// If the last remote input event was a click or a drag, then it's not safe |
// to block remote mouse events. For example, it might result in the host |
// missing the mouse-up event and being stuck with the button pressed. |
@@ -171,6 +182,8 @@ bool ClientSession::ShouldIgnoreRemoteMouseInput( |
bool ClientSession::ShouldIgnoreRemoteKeyboardInput( |
const KeyEvent& event) const { |
+ DCHECK(CalledOnValidThread()); |
+ |
// If the host user has not yet approved the continuation of the connection, |
// then all remote keyboard input is ignored, except to release keys that |
// were already pressed. |
@@ -182,6 +195,8 @@ bool ClientSession::ShouldIgnoreRemoteKeyboardInput( |
} |
void ClientSession::RecordKeyEvent(const KeyEvent& event) { |
+ DCHECK(CalledOnValidThread()); |
+ |
if (event.pressed()) { |
pressed_keys_.insert(event.keycode()); |
} else { |
@@ -190,6 +205,8 @@ void ClientSession::RecordKeyEvent(const KeyEvent& event) { |
} |
void ClientSession::RecordMouseButtonState(const MouseEvent& event) { |
+ DCHECK(CalledOnValidThread()); |
+ |
if (event.has_button() && event.has_button_down()) { |
// Button values are defined in remoting/proto/event.proto. |
if (event.button() >= 1 && event.button() < MouseEvent::BUTTON_MAX) { |
@@ -204,6 +221,8 @@ void ClientSession::RecordMouseButtonState(const MouseEvent& event) { |
} |
void ClientSession::RestoreEventState() { |
+ DCHECK(CalledOnValidThread()); |
+ |
// Undo any currently pressed keys. |
std::set<int>::iterator i; |
for (i = pressed_keys_.begin(); i != pressed_keys_.end(); ++i) { |