summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 21:20:01 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 21:20:01 +0000
commit94b2c17468b276f873a74293459553cf9bf019a4 (patch)
tree26914f93770697043704c85a159c89662b825c64 /remoting
parent0d7dad6df2d9d6d9676ca7adb02e3c92beaa8a79 (diff)
downloadchromium_src-94b2c17468b276f873a74293459553cf9bf019a4.zip
chromium_src-94b2c17468b276f873a74293459553cf9bf019a4.tar.gz
chromium_src-94b2c17468b276f873a74293459553cf9bf019a4.tar.bz2
HostMessageDispatcher to dispatch messages received on a chromoting connection
Adding HostMessageDispatcher to be used by ChromotingHost. BUG=None TEST=None Review URL: http://codereview.chromium.org/3852002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63111 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/proto/control.proto22
-rw-r--r--remoting/proto/event.proto36
-rw-r--r--remoting/proto/internal.proto1
-rw-r--r--remoting/protocol/host_control_message_handler.h27
-rw-r--r--remoting/protocol/host_event_message_handler.h30
-rw-r--r--remoting/protocol/host_message_dispatcher.cc28
-rw-r--r--remoting/protocol/host_message_dispatcher.h73
-rw-r--r--remoting/protocol/stream_reader.h2
-rw-r--r--remoting/remoting.gyp4
9 files changed, 220 insertions, 3 deletions
diff --git a/remoting/proto/control.proto b/remoting/proto/control.proto
index df0787c..299d8cc 100644
--- a/remoting/proto/control.proto
+++ b/remoting/proto/control.proto
@@ -10,4 +10,24 @@ option optimize_for = LITE_RUNTIME;
package remoting;
-// TODO(hclam): Define control messages. \ No newline at end of file
+message SuggestScreenResolutionRequest {
+ required int32 width = 1;
+ required int32 height = 2;
+};
+
+// Represents a control message that sent from the client to the host.
+// This message is transmitted on the control channel.
+message ClientControlMessage {
+ optional SuggestScreenResolutionRequest suggestScreenResolutionRequest = 1;
+}
+
+message SetScreenResolutionRequest {
+ required int32 width = 1;
+ required int32 height = 2;
+};
+
+// Represents a control message that sent from host to the client.
+// This message is transmitted on the control channel.
+message HostControlMessage {
+ optional SetScreenResolutionRequest setScreenResolutionRequest = 1;
+}
diff --git a/remoting/proto/event.proto b/remoting/proto/event.proto
index b961335..96c8fce 100644
--- a/remoting/proto/event.proto
+++ b/remoting/proto/event.proto
@@ -200,3 +200,39 @@ message MouseDownEvent {
message MouseUpEvent {
required MouseButton button = 1;
}
+
+// Defines a mouse event message on the event channel.
+message MouseEvent {
+ // Mouse position information.
+ optional int32 mouse_x = 1;
+ optional int32 mouse_y = 2;
+
+ // Mouse wheel information.
+ optional int32 wheel_offset_x = 3;
+ optional int32 wheel_offset_y = 4;
+
+ // Mouse button information.
+ optional MouseButton button = 5;
+ optional bool button_down = 6;
+}
+
+// Defines an event message on the event channel.
+message Event {
+ required int32 timestamp = 1; // Client timestamp for event
+ optional bool dummy = 2; // Is this a dummy event?
+
+ optional KeyEvent key = 3;
+ optional MouseEvent mouse = 4;
+}
+
+// Defines the message that is sent from client to host.
+// Only one of the optional messages should be present.
+message ClientEventMessage {
+ repeated Event events = 1;
+}
+
+// Defines the message that is sent from host to client.
+// Only one of the optional messages should be present.
+message HostEventMessage {
+ // TODO(hclam): Define the message.
+}
diff --git a/remoting/proto/internal.proto b/remoting/proto/internal.proto
index b98b696..2e74501 100644
--- a/remoting/proto/internal.proto
+++ b/remoting/proto/internal.proto
@@ -21,7 +21,6 @@ message ChromotingHostMessage {
optional BeginUpdateStreamMessage begin_update_stream = 2;
optional EndUpdateStreamMessage end_update_stream = 3;
optional UpdateStreamPacketMessage update_stream_packet = 4;
-
optional RectangleUpdatePacket rectangle_update = 5;
}
diff --git a/remoting/protocol/host_control_message_handler.h b/remoting/protocol/host_control_message_handler.h
new file mode 100644
index 0000000..8bb60cd
--- /dev/null
+++ b/remoting/protocol/host_control_message_handler.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2010 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.
+
+#ifndef REMOTING_PROTOCOL_HOST_CONTROL_MESSAGE_HANDLER_H_
+#define REMOTING_PROTOCOL_HOST_CONTROL_MESSAGE_HANDLER_H_
+
+#include "remoting/proto/control.pb.h"
+
+class Task;
+
+namespace remoting {
+
+// The interface for handling control messages sent to the host.
+// For all methods of this interface. |task| needs to be called when
+// receiver is done processing the event.
+class HostControlMessageHandler {
+ public:
+ virtual ~HostControlMessageHandler() {}
+
+ virtual void OnSuggestScreenResolutionRequest(
+ const SuggestScreenResolutionRequest& request, Task* task) = 0;
+};
+
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_HOST_CONTROL_MESSAGE_HANDLER_H_
diff --git a/remoting/protocol/host_event_message_handler.h b/remoting/protocol/host_event_message_handler.h
new file mode 100644
index 0000000..0d01357
--- /dev/null
+++ b/remoting/protocol/host_event_message_handler.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2010 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.
+
+#ifndef REMOTING_PROTOCOL_HOST_EVENT_MESSAGE_HANDLER_H_
+#define REMOTING_PROTOCOL_HOST_EVENT_MESSAGE_HANDLER_H_
+
+#include "base/basictypes.h"
+#include "remoting/proto/event.pb.h"
+
+class Task;
+
+namespace remoting {
+
+// The interface for handling event messages sent to the host.
+// For all methods of this interface. |task| needs to be called when
+// receiver is done processing the event.
+class HostEventMessageHandler {
+ public:
+ virtual ~HostEventMessageHandler() {}
+
+ virtual void OnKeyEvent(int32 timestamp,
+ const KeyEvent& event, Task* task) = 0;
+ virtual void OnMouseEvent(int32 timestamp, const MouseEvent& event,
+ Task* task) = 0;
+};
+
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_HOST_EVENT_MESSAGE_HANDLER_H_
diff --git a/remoting/protocol/host_message_dispatcher.cc b/remoting/protocol/host_message_dispatcher.cc
new file mode 100644
index 0000000..834b5f8
--- /dev/null
+++ b/remoting/protocol/host_message_dispatcher.cc
@@ -0,0 +1,28 @@
+// Copyright (c) 2010 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.
+
+#include "base/message_loop_proxy.h"
+#include "remoting/proto/control.pb.h"
+#include "remoting/proto/event.pb.h"
+#include "remoting/protocol/host_message_dispatcher.h"
+#include "remoting/protocol/host_control_message_handler.h"
+#include "remoting/protocol/host_event_message_handler.h"
+#include "remoting/protocol/stream_reader.h"
+
+namespace remoting {
+
+HostMessageDispatcher::HostMessageDispatcher(
+ base::MessageLoopProxy* message_loop_proxy,
+ ChromotingConnection* connection,
+ HostControlMessageHandler* control_message_handler,
+ HostEventMessageHandler* event_message_handler)
+ : message_loop_proxy_(message_loop_proxy),
+ control_message_handler_(control_message_handler),
+ event_message_handler_(event_message_handler) {
+}
+
+HostMessageDispatcher::~HostMessageDispatcher() {
+}
+
+} // namespace remoting
diff --git a/remoting/protocol/host_message_dispatcher.h b/remoting/protocol/host_message_dispatcher.h
new file mode 100644
index 0000000..3d1ac1b
--- /dev/null
+++ b/remoting/protocol/host_message_dispatcher.h
@@ -0,0 +1,73 @@
+// Copyright (c) 2010 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.
+
+#ifndef REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_
+#define REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_
+
+#include "base/basictypes.h"
+#include "base/ref_counted.h"
+#include "base/scoped_ptr.h"
+
+namespace base {
+class MessageLoopProxy;
+} // namespace base
+
+namespace remoting {
+
+class ChromotingClientMessage;
+class ChromotingConnection;
+class EventsStreamReader;
+class HostControlMessageHandler;
+class HostEventMessageHandler;
+
+// A message dispatcher used to listen for messages received in
+// ChromotingConnection. It dispatches messages to the corresponding
+// handler.
+//
+// Internally it contains an EventsStreamReader that decodes data on
+// communications channels into protocol buffer messages.
+// EventStreamReader is registered with ChromotingConnection given to it.
+//
+// Object of this class is owned by ChromotingHost to dispatch messages
+// to itself.
+class HostMessageDispatcher {
+ public:
+ // Construct a message dispatcher that dispatches messages received
+ // in ChromotingConnection.
+ HostMessageDispatcher(base::MessageLoopProxy* message_loop_proxy,
+ ChromotingConnection* connection,
+ HostControlMessageHandler* control_message_handler,
+ HostEventMessageHandler* event_message_handler);
+
+ virtual ~HostMessageDispatcher();
+
+ private:
+ // This method is called by |control_channel_reader_| when a control
+ // message is received.
+ void OnControlMessageReceived(ChromotingClientMessage* message);
+
+ // This method is called by |event_channel_reader_| when a event
+ // message is received.
+ void OnEventMessageReceived(ChromotingClientMessage* message);
+
+ // Message loop to dispatch the messages.
+ scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
+
+ // EventsStreamReader that runs on the control channel. It runs a loop
+ // that parses data on the channel and then delegate the message to this
+ // class.
+ scoped_ptr<EventsStreamReader> control_channel_reader_;
+
+ // EventsStreamReader that runs on the event channel.
+ scoped_ptr<EventsStreamReader> event_channel_reader_;
+
+ // Event handlers for control channel and event channel respectively.
+ // Method calls to these objects are made on the message loop given.
+ scoped_ptr<HostControlMessageHandler> control_message_handler_;
+ scoped_ptr<HostEventMessageHandler> event_message_handler_;
+};
+
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_
diff --git a/remoting/protocol/stream_reader.h b/remoting/protocol/stream_reader.h
index b71f4b0..6eac586 100644
--- a/remoting/protocol/stream_reader.h
+++ b/remoting/protocol/stream_reader.h
@@ -67,7 +67,7 @@ class EventsStreamReader : public StreamReaderBase {
DISALLOW_COPY_AND_ASSIGN(EventsStreamReader);
};
-class VideoStreamReader : public StreamReaderBase {
+class VideoStreamReader : public StreamReaderBase {
public:
VideoStreamReader();
~VideoStreamReader();
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index c1112a1..916fb93 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -351,6 +351,10 @@
'protocol/buffered_socket_writer.h',
'protocol/chromoting_connection.h',
'protocol/chromoting_server.h',
+ 'protocol/host_message_dispatcher.cc',
+ 'protocol/host_message_dispatcher.h',
+ 'protocol/host_control_message_handler.h',
+ 'protocol/host_event_message_handler.h',
'protocol/jingle_chromoting_connection.cc',
'protocol/jingle_chromoting_connection.h',
'protocol/jingle_chromoting_server.cc',