summaryrefslogtreecommitdiffstats
path: root/remoting/protocol
diff options
context:
space:
mode:
authorlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-13 18:17:30 +0000
committerlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-13 18:17:30 +0000
commitb25ff3b40b859a512f38106bd04010dac9412bd6 (patch)
treed14ef420f85b380bd99756ce5d5d6668237477fd /remoting/protocol
parentd4fe2317514900f7a70cb61da28bc3fced7da974 (diff)
downloadchromium_src-b25ff3b40b859a512f38106bd04010dac9412bd6.zip
chromium_src-b25ff3b40b859a512f38106bd04010dac9412bd6.tar.gz
chromium_src-b25ff3b40b859a512f38106bd04010dac9412bd6.tar.bz2
Refactor InputStub interface to pass events by value (const reference).
This will make it much easier to inject modified key/mouse events, for example, restricting mouse-coordinates to the screen area. BUG=None TEST=Manual Review URL: http://codereview.chromium.org/7803004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100939 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol')
-rw-r--r--remoting/protocol/host_message_dispatcher.cc10
-rw-r--r--remoting/protocol/input_sender.cc18
-rw-r--r--remoting/protocol/input_sender.h4
-rw-r--r--remoting/protocol/input_stub.h4
-rw-r--r--remoting/protocol/protocol_mock_objects.h4
5 files changed, 18 insertions, 22 deletions
diff --git a/remoting/protocol/host_message_dispatcher.cc b/remoting/protocol/host_message_dispatcher.cc
index c2b6423..1e395da 100644
--- a/remoting/protocol/host_message_dispatcher.cc
+++ b/remoting/protocol/host_message_dispatcher.cc
@@ -67,22 +67,22 @@ void HostMessageDispatcher::OnControlMessageReceived(
void HostMessageDispatcher::OnEventMessageReceived(
EventMessage* message, Task* done_task) {
+ base::ScopedTaskRunner done_runner(done_task);
+
connection_->UpdateSequenceNumber(message->sequence_number());
if (message->has_key_event()) {
const KeyEvent& event = message->key_event();
if (event.has_keycode() && event.has_pressed()) {
- input_stub_->InjectKeyEvent(&event, done_task);
+ input_stub_->InjectKeyEvent(event);
return;
}
} else if (message->has_mouse_event()) {
- input_stub_->InjectMouseEvent(&message->mouse_event(), done_task);
+ input_stub_->InjectMouseEvent(message->mouse_event());
return;
}
- LOG(WARNING) << "Invalid event message received.";
- done_task->Run();
- delete done_task;
+ LOG(WARNING) << "Unknown event message received.";
}
} // namespace protocol
diff --git a/remoting/protocol/input_sender.cc b/remoting/protocol/input_sender.cc
index ff45ce2..2d725c6 100644
--- a/remoting/protocol/input_sender.cc
+++ b/remoting/protocol/input_sender.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
// This stub is thread safe because of the use of BufferedSocketWriter.
-// BufferedSocketWriter buffers messages and send them on them right thread.
+// BufferedSocketWriter buffers messages and send them on the right thread.
#include "remoting/protocol/input_sender.h"
@@ -27,22 +27,18 @@ InputSender::InputSender(base::MessageLoopProxy* message_loop,
InputSender::~InputSender() {
}
-void InputSender::InjectKeyEvent(const KeyEvent* event, Task* done) {
- DCHECK(done);
-
+void InputSender::InjectKeyEvent(const KeyEvent& event) {
EventMessage message;
message.set_sequence_number(base::Time::Now().ToInternalValue());
- message.mutable_key_event()->CopyFrom(*event);
- buffered_writer_->Write(SerializeAndFrameMessage(message), done);
+ message.mutable_key_event()->CopyFrom(event);
+ buffered_writer_->Write(SerializeAndFrameMessage(message), NULL);
}
-void InputSender::InjectMouseEvent(const MouseEvent* event, Task* done) {
- DCHECK(done);
-
+void InputSender::InjectMouseEvent(const MouseEvent& event) {
EventMessage message;
message.set_sequence_number(base::Time::Now().ToInternalValue());
- message.mutable_mouse_event()->CopyFrom(*event);
- buffered_writer_->Write(SerializeAndFrameMessage(message), done);
+ message.mutable_mouse_event()->CopyFrom(event);
+ buffered_writer_->Write(SerializeAndFrameMessage(message), NULL);
}
void InputSender::Close() {
diff --git a/remoting/protocol/input_sender.h b/remoting/protocol/input_sender.h
index 464237f..1733b11 100644
--- a/remoting/protocol/input_sender.h
+++ b/remoting/protocol/input_sender.h
@@ -43,8 +43,8 @@ class InputSender : public InputStub {
virtual ~InputSender();
// InputStub implementation.
- virtual void InjectKeyEvent(const KeyEvent* event, Task* done);
- virtual void InjectMouseEvent(const MouseEvent* event, Task* done);
+ virtual void InjectKeyEvent(const KeyEvent& event);
+ virtual void InjectMouseEvent(const MouseEvent& event);
// Stop writing. Must be called on the network thread when the
// underlying socket is being destroyed.
diff --git a/remoting/protocol/input_stub.h b/remoting/protocol/input_stub.h
index 464454f..5db53ee 100644
--- a/remoting/protocol/input_stub.h
+++ b/remoting/protocol/input_stub.h
@@ -23,8 +23,8 @@ class InputStub {
InputStub() {};
virtual ~InputStub() {};
- virtual void InjectKeyEvent(const KeyEvent* event, Task* done) = 0;
- virtual void InjectMouseEvent(const MouseEvent* event, Task* done) = 0;
+ virtual void InjectKeyEvent(const KeyEvent& event) = 0;
+ virtual void InjectMouseEvent(const MouseEvent& event) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(InputStub);
diff --git a/remoting/protocol/protocol_mock_objects.h b/remoting/protocol/protocol_mock_objects.h
index 7186467..4af7584 100644
--- a/remoting/protocol/protocol_mock_objects.h
+++ b/remoting/protocol/protocol_mock_objects.h
@@ -57,8 +57,8 @@ class MockInputStub : public InputStub {
MockInputStub();
virtual ~MockInputStub();
- MOCK_METHOD2(InjectKeyEvent, void(const KeyEvent* event, Task* done));
- MOCK_METHOD2(InjectMouseEvent, void(const MouseEvent* event, Task* done));
+ MOCK_METHOD1(InjectKeyEvent, void(const KeyEvent& event));
+ MOCK_METHOD1(InjectMouseEvent, void(const MouseEvent& event));
private:
DISALLOW_COPY_AND_ASSIGN(MockInputStub);