diff options
author | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-31 01:28:38 +0000 |
---|---|---|
committer | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-31 01:28:38 +0000 |
commit | ba6d1c2d2645b0d54b4479a0762757978242ca9b (patch) | |
tree | 399ff9fc9e4f9623ff16713f7fdd5e7555b98e14 /remoting | |
parent | e67453f129181c86617010686f5f096adb25664f (diff) | |
download | chromium_src-ba6d1c2d2645b0d54b4479a0762757978242ca9b.zip chromium_src-ba6d1c2d2645b0d54b4479a0762757978242ca9b.tar.gz chromium_src-ba6d1c2d2645b0d54b4479a0762757978242ca9b.tar.bz2 |
[Chromoting] Add plumbing to carry clipboard events from the host to the client.
BUG=117473
Review URL: http://codereview.chromium.org/9921034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130023 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/client/chromoting_client.cc | 8 | ||||
-rw-r--r-- | remoting/client/chromoting_client.h | 6 | ||||
-rw-r--r-- | remoting/protocol/client_control_dispatcher.cc | 9 | ||||
-rw-r--r-- | remoting/protocol/client_control_dispatcher.h | 16 | ||||
-rw-r--r-- | remoting/protocol/connection_to_host.cc | 5 | ||||
-rw-r--r-- | remoting/protocol/connection_to_host.h | 3 | ||||
-rw-r--r-- | remoting/protocol/host_control_dispatcher.cc | 6 | ||||
-rw-r--r-- | remoting/protocol/host_control_dispatcher.h | 20 |
8 files changed, 57 insertions, 16 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc index 74f6313..f37a2cd 100644 --- a/remoting/client/chromoting_client.cc +++ b/remoting/client/chromoting_client.cc @@ -61,7 +61,7 @@ void ChromotingClient::Start(scoped_refptr<XmppProxy> xmpp_proxy) { connection_->Connect(xmpp_proxy, config_.local_jid, config_.host_jid, config_.host_public_key, authenticator.Pass(), - this, this, this); + this, this, this, this); if (!view_->Initialize()) { ClientDone(); @@ -104,6 +104,12 @@ ChromotingStats* ChromotingClient::GetStats() { return &stats_; } +void ChromotingClient::InjectClipboardEvent( + const protocol::ClipboardEvent& event) { + // TODO(simonmorris): Pass the clipboard event to the webapp. + return; +} + void ChromotingClient::ProcessVideoPacket(scoped_ptr<VideoPacket> packet, const base::Closure& done) { DCHECK(message_loop()->BelongsToCurrentThread()); diff --git a/remoting/client/chromoting_client.h b/remoting/client/chromoting_client.h index c71475e..7df0816 100644 --- a/remoting/client/chromoting_client.h +++ b/remoting/client/chromoting_client.h @@ -16,6 +16,7 @@ #include "remoting/client/chromoting_stats.h" #include "remoting/client/chromoting_view.h" #include "remoting/protocol/client_stub.h" +#include "remoting/protocol/clipboard_stub.h" #include "remoting/protocol/connection_to_host.h" #include "remoting/protocol/input_stub.h" #include "remoting/protocol/video_stub.h" @@ -31,6 +32,7 @@ class RectangleUpdateDecoder; // TODO(sergeyu): Move VideoStub implementation to RectangleUpdateDecoder. class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, public protocol::ClientStub, + public protocol::ClipboardStub, public protocol::VideoStub { public: // Objects passed in are not owned by this class. @@ -49,6 +51,10 @@ class ChromotingClient : public protocol::ConnectionToHost::HostEventCallback, // Return the stats recorded by this client. ChromotingStats* GetStats(); + // ClipboardStub implementation. + virtual void InjectClipboardEvent(const protocol::ClipboardEvent& event) + OVERRIDE; + // ConnectionToHost::HostEventCallback implementation. virtual void OnConnectionState( protocol::ConnectionToHost::State state, diff --git a/remoting/protocol/client_control_dispatcher.cc b/remoting/protocol/client_control_dispatcher.cc index b1aefc2..b6e8250 100644 --- a/remoting/protocol/client_control_dispatcher.cc +++ b/remoting/protocol/client_control_dispatcher.cc @@ -21,6 +21,7 @@ namespace protocol { ClientControlDispatcher::ClientControlDispatcher() : ChannelDispatcherBase(kControlChannelName), client_stub_(NULL), + clipboard_stub_(NULL), writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { } @@ -45,8 +46,14 @@ void ClientControlDispatcher::InjectClipboardEvent( void ClientControlDispatcher::OnMessageReceived( scoped_ptr<ControlMessage> message, const base::Closure& done_task) { DCHECK(client_stub_); + DCHECK(clipboard_stub_); base::ScopedClosureRunner done_runner(done_task); - LOG(WARNING) << "Unknown control message received."; + + if (message->has_clipboard_event()) { + clipboard_stub_->InjectClipboardEvent(message->clipboard_event()); + } else { + LOG(WARNING) << "Unknown control message received."; + } } } // namespace protocol diff --git a/remoting/protocol/client_control_dispatcher.h b/remoting/protocol/client_control_dispatcher.h index d7acac1..3f3c134 100644 --- a/remoting/protocol/client_control_dispatcher.h +++ b/remoting/protocol/client_control_dispatcher.h @@ -20,8 +20,8 @@ class BufferedSocketWriter; class Session; // ClientControlDispatcher dispatches incoming messages on the control -// channel to ClientStub, and also implements ClipboardStub and HostStub for -// outgoing messages. +// channel to ClientStub or ClipboardStub, and also implements ClipboardStub +// and HostStub for outgoing messages. class ClientControlDispatcher : public ChannelDispatcherBase, public ClipboardStub, public HostStub { @@ -32,11 +32,16 @@ class ClientControlDispatcher : public ChannelDispatcherBase, // ClipboardStub implementation. virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; - // Sets ClientStub that will be called for each incoming control - // message. Doesn't take ownership of |client_stub|. It must outlive - // this dispatcher. + // Sets the ClientStub that will be called for each incoming control + // message. |client_stub| must outlive this object. void set_client_stub(ClientStub* client_stub) { client_stub_ = client_stub; } + // Sets the ClipboardStub that will be called for each incoming clipboard + // message. |clipboard_stub| must outlive this object. + void set_clipboard_stub(ClipboardStub* clipboard_stub) { + clipboard_stub_ = clipboard_stub; + } + protected: // ChannelDispatcherBase overrides. virtual void OnInitialized() OVERRIDE; @@ -46,6 +51,7 @@ class ClientControlDispatcher : public ChannelDispatcherBase, const base::Closure& done_task); ClientStub* client_stub_; + ClipboardStub* clipboard_stub_; ProtobufMessageReader<ControlMessage> reader_; scoped_refptr<BufferedSocketWriter> writer_; diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc index 457cf78..6fcdfa5 100644 --- a/remoting/protocol/connection_to_host.cc +++ b/remoting/protocol/connection_to_host.cc @@ -16,6 +16,7 @@ #include "remoting/protocol/client_control_dispatcher.h" #include "remoting/protocol/client_event_dispatcher.h" #include "remoting/protocol/client_stub.h" +#include "remoting/protocol/clipboard_stub.h" #include "remoting/protocol/errors.h" #include "remoting/protocol/jingle_session_manager.h" #include "remoting/protocol/pepper_transport_factory.h" @@ -35,6 +36,7 @@ ConnectionToHost::ConnectionToHost( allow_nat_traversal_(allow_nat_traversal), event_callback_(NULL), client_stub_(NULL), + clipboard_stub_(NULL), video_stub_(NULL), state_(CONNECTING), error_(OK) { @@ -54,9 +56,11 @@ void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, scoped_ptr<Authenticator> authenticator, HostEventCallback* event_callback, ClientStub* client_stub, + ClipboardStub* clipboard_stub, VideoStub* video_stub) { event_callback_ = event_callback; client_stub_ = client_stub; + clipboard_stub_ = clipboard_stub; video_stub_ = video_stub; authenticator_ = authenticator.Pass(); @@ -165,6 +169,7 @@ void ConnectionToHost::OnSessionStateChange( control_dispatcher_->Init(session_.get(), base::Bind( &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); control_dispatcher_->set_client_stub(client_stub_); + control_dispatcher_->set_clipboard_stub(clipboard_stub_); event_dispatcher_.reset(new ClientEventDispatcher()); event_dispatcher_->Init(session_.get(), base::Bind( diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h index cc8b691..9aae099 100644 --- a/remoting/protocol/connection_to_host.h +++ b/remoting/protocol/connection_to_host.h @@ -37,6 +37,7 @@ class Authenticator; class ClientControlDispatcher; class ClientEventDispatcher; class ClientStub; +class ClipboardStub; class HostStub; class InputStub; class SessionConfig; @@ -73,6 +74,7 @@ class ConnectionToHost : public SignalStrategy::Listener, scoped_ptr<Authenticator> authenticator, HostEventCallback* event_callback, ClientStub* client_stub, + ClipboardStub* clipboard_stub, VideoStub* video_stub); virtual void Disconnect(const base::Closure& shutdown_task); @@ -128,6 +130,7 @@ class ConnectionToHost : public SignalStrategy::Listener, // Stub for incoming messages. ClientStub* client_stub_; + ClipboardStub* clipboard_stub_; VideoStub* video_stub_; scoped_ptr<SignalStrategy> signal_strategy_; diff --git a/remoting/protocol/host_control_dispatcher.cc b/remoting/protocol/host_control_dispatcher.cc index 2dc4364..4a78d0e 100644 --- a/remoting/protocol/host_control_dispatcher.cc +++ b/remoting/protocol/host_control_dispatcher.cc @@ -34,6 +34,12 @@ void HostControlDispatcher::OnInitialized() { writer_->Init(channel(), BufferedSocketWriter::WriteFailedCallback()); } +void HostControlDispatcher::InjectClipboardEvent(const ClipboardEvent& event) { + ControlMessage message; + message.mutable_clipboard_event()->CopyFrom(event); + writer_->Write(SerializeAndFrameMessage(message), base::Closure()); +} + void HostControlDispatcher::OnMessageReceived( scoped_ptr<ControlMessage> message, const base::Closure& done_task) { DCHECK(clipboard_stub_); diff --git a/remoting/protocol/host_control_dispatcher.h b/remoting/protocol/host_control_dispatcher.h index f1e271c..0e36ce4 100644 --- a/remoting/protocol/host_control_dispatcher.h +++ b/remoting/protocol/host_control_dispatcher.h @@ -8,6 +8,7 @@ #include "base/memory/ref_counted.h" #include "remoting/protocol/channel_dispatcher_base.h" #include "remoting/protocol/client_stub.h" +#include "remoting/protocol/clipboard_stub.h" #include "remoting/protocol/message_reader.h" namespace net { @@ -18,29 +19,30 @@ namespace remoting { namespace protocol { class BufferedSocketWriter; -class ClipboardStub; class ControlMessage; class HostStub; class Session; // HostControlDispatcher dispatches incoming messages on the control -// channel to HostStub or ClipboardStub, and also implements ClientStub for -// outgoing messages. -class HostControlDispatcher : public ChannelDispatcherBase, public ClientStub { +// channel to HostStub or ClipboardStub, and also implements ClientStub and +// ClipboardStub for outgoing messages. +class HostControlDispatcher : public ChannelDispatcherBase, public ClientStub, + public ClipboardStub { public: HostControlDispatcher(); virtual ~HostControlDispatcher(); + // ClipboardStub implementation. + virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; + // Sets the ClipboardStub that will be called for each incoming clipboard - // message. Doesn't take ownership of |clipboard_stub|, which must outlive - // the dispatcher. + // message. |clipboard_stub| must outlive this object. void set_clipboard_stub(ClipboardStub* clipboard_stub) { clipboard_stub_ = clipboard_stub; } - // Sets HostStub that will be called for each incoming control - // message. Doesn't take ownership of |host_stub|. It must outlive - // this dispatcher. + // Sets the HostStub that will be called for each incoming control + // message. |host_stub| must outlive this object. void set_host_stub(HostStub* host_stub) { host_stub_ = host_stub; } protected: |