Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: remoting/protocol/client_control_dispatcher.cc

Issue 9921034: [Chromoting] Add plumbing to carry clipboard events from the host to the client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/client_control_dispatcher.h ('k') | remoting/protocol/connection_to_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/protocol/client_control_dispatcher.h" 5 #include "remoting/protocol/client_control_dispatcher.h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "net/socket/stream_socket.h" 10 #include "net/socket/stream_socket.h"
11 #include "remoting/base/constants.h" 11 #include "remoting/base/constants.h"
12 #include "remoting/proto/control.pb.h" 12 #include "remoting/proto/control.pb.h"
13 #include "remoting/proto/internal.pb.h" 13 #include "remoting/proto/internal.pb.h"
14 #include "remoting/protocol/buffered_socket_writer.h" 14 #include "remoting/protocol/buffered_socket_writer.h"
15 #include "remoting/protocol/client_stub.h" 15 #include "remoting/protocol/client_stub.h"
16 #include "remoting/protocol/util.h" 16 #include "remoting/protocol/util.h"
17 17
18 namespace remoting { 18 namespace remoting {
19 namespace protocol { 19 namespace protocol {
20 20
21 ClientControlDispatcher::ClientControlDispatcher() 21 ClientControlDispatcher::ClientControlDispatcher()
22 : ChannelDispatcherBase(kControlChannelName), 22 : ChannelDispatcherBase(kControlChannelName),
23 client_stub_(NULL), 23 client_stub_(NULL),
24 clipboard_stub_(NULL),
24 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { 25 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) {
25 } 26 }
26 27
27 ClientControlDispatcher::~ClientControlDispatcher() { 28 ClientControlDispatcher::~ClientControlDispatcher() {
28 writer_->Close(); 29 writer_->Close();
29 } 30 }
30 31
31 void ClientControlDispatcher::OnInitialized() { 32 void ClientControlDispatcher::OnInitialized() {
32 // TODO(garykac): Set write failed callback. 33 // TODO(garykac): Set write failed callback.
33 writer_->Init(channel(), BufferedSocketWriter::WriteFailedCallback()); 34 writer_->Init(channel(), BufferedSocketWriter::WriteFailedCallback());
34 reader_.Init(channel(), base::Bind( 35 reader_.Init(channel(), base::Bind(
35 &ClientControlDispatcher::OnMessageReceived, base::Unretained(this))); 36 &ClientControlDispatcher::OnMessageReceived, base::Unretained(this)));
36 } 37 }
37 38
38 void ClientControlDispatcher::InjectClipboardEvent( 39 void ClientControlDispatcher::InjectClipboardEvent(
39 const ClipboardEvent& event) { 40 const ClipboardEvent& event) {
40 ControlMessage message; 41 ControlMessage message;
41 message.mutable_clipboard_event()->CopyFrom(event); 42 message.mutable_clipboard_event()->CopyFrom(event);
42 writer_->Write(SerializeAndFrameMessage(message), base::Closure()); 43 writer_->Write(SerializeAndFrameMessage(message), base::Closure());
43 } 44 }
44 45
45 void ClientControlDispatcher::OnMessageReceived( 46 void ClientControlDispatcher::OnMessageReceived(
46 scoped_ptr<ControlMessage> message, const base::Closure& done_task) { 47 scoped_ptr<ControlMessage> message, const base::Closure& done_task) {
47 DCHECK(client_stub_); 48 DCHECK(client_stub_);
49 DCHECK(clipboard_stub_);
48 base::ScopedClosureRunner done_runner(done_task); 50 base::ScopedClosureRunner done_runner(done_task);
49 LOG(WARNING) << "Unknown control message received."; 51
52 if (message->has_clipboard_event()) {
53 clipboard_stub_->InjectClipboardEvent(message->clipboard_event());
54 } else {
55 LOG(WARNING) << "Unknown control message received.";
56 }
50 } 57 }
51 58
52 } // namespace protocol 59 } // namespace protocol
53 } // namespace remoting 60 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/client_control_dispatcher.h ('k') | remoting/protocol/connection_to_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698