Skip to content

Commit

Permalink
Fix stuck keys problem with Chromoting when host disconnects while ke…
Browse files Browse the repository at this point in the history
…ys are

down.

BUG=84544
TEST=manual

Review URL: http://codereview.chromium.org/7799014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98825 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
garykac@chromium.org committed Aug 30, 2011
1 parent 5268439 commit 42f5c7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
17 changes: 9 additions & 8 deletions remoting/host/client_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ static const int64 kRemoteBlockTimeoutMillis = 2000;

namespace remoting {

using protocol::KeyEvent;

ClientSession::ClientSession(
EventHandler* event_handler,
UserAuthenticator* user_authenticator,
Expand Down Expand Up @@ -71,8 +73,7 @@ void ClientSession::OnAuthorizationComplete(bool success) {
}
}

void ClientSession::InjectKeyEvent(const protocol::KeyEvent* event,
Task* done) {
void ClientSession::InjectKeyEvent(const KeyEvent* event, Task* done) {
base::ScopedTaskRunner done_runner(done);
if (authenticated_ && !ShouldIgnoreRemoteKeyboardInput(event)) {
RecordKeyEvent(event);
Expand Down Expand Up @@ -155,7 +156,7 @@ bool ClientSession::ShouldIgnoreRemoteMouseInput(
}

bool ClientSession::ShouldIgnoreRemoteKeyboardInput(
const protocol::KeyEvent* event) const {
const KeyEvent* event) const {
// 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.
Expand All @@ -166,7 +167,7 @@ bool ClientSession::ShouldIgnoreRemoteKeyboardInput(
return false;
}

void ClientSession::RecordKeyEvent(const protocol::KeyEvent* event) {
void ClientSession::RecordKeyEvent(const KeyEvent* event) {
if (event->pressed()) {
pressed_keys_.insert(event->keycode());
} else {
Expand All @@ -177,10 +178,10 @@ void ClientSession::RecordKeyEvent(const protocol::KeyEvent* event) {
void ClientSession::UnpressKeys() {
std::set<int>::iterator i;
for (i = pressed_keys_.begin(); i != pressed_keys_.end(); ++i) {
protocol::KeyEvent key;
key.set_keycode(*i);
key.set_pressed(false);
input_stub_->InjectKeyEvent(&key, NULL);
KeyEvent* key = new KeyEvent();
key->set_keycode(*i);
key->set_pressed(false);
input_stub_->InjectKeyEvent(key, new DeleteTask<KeyEvent>(key));
}
pressed_keys_.clear();
}
Expand Down
6 changes: 5 additions & 1 deletion remoting/protocol/input_sender.cc
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -28,13 +28,17 @@ InputSender::~InputSender() {
}

void InputSender::InjectKeyEvent(const KeyEvent* event, Task* done) {
DCHECK(done);

EventMessage message;
message.set_sequence_number(base::Time::Now().ToInternalValue());
message.mutable_key_event()->CopyFrom(*event);
buffered_writer_->Write(SerializeAndFrameMessage(message), done);
}

void InputSender::InjectMouseEvent(const MouseEvent* event, Task* done) {
DCHECK(done);

EventMessage message;
message.set_sequence_number(base::Time::Now().ToInternalValue());
message.mutable_mouse_event()->CopyFrom(*event);
Expand Down

0 comments on commit 42f5c7e

Please sign in to comment.