forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HostMessageDispatcher to dispatch messages received on a chromoting c…
…onnection 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
- Loading branch information
hclam@chromium.org
committed
Oct 19, 2010
1 parent
0d7dad6
commit 94b2c17
Showing
9 changed files
with
220 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters