| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 17 |
| 17 namespace remoting { | 18 namespace remoting { |
| 18 namespace protocol { | 19 namespace protocol { |
| 19 | 20 |
| 20 ClientControlDispatcher::ClientControlDispatcher() | 21 ClientControlDispatcher::ClientControlDispatcher() |
| 21 : ChannelDispatcherBase(kControlChannelName), | 22 : ChannelDispatcherBase(kControlChannelName), |
| 22 client_stub_(NULL), | 23 client_stub_(NULL), |
| 23 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { | 24 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { |
| 24 } | 25 } |
| 25 | 26 |
| 26 ClientControlDispatcher::~ClientControlDispatcher() { | 27 ClientControlDispatcher::~ClientControlDispatcher() { |
| 27 writer_->Close(); | 28 writer_->Close(); |
| 28 } | 29 } |
| 29 | 30 |
| 30 void ClientControlDispatcher::OnInitialized() { | 31 void ClientControlDispatcher::OnInitialized() { |
| 31 // TODO(garykac): Set write failed callback. | 32 // TODO(garykac): Set write failed callback. |
| 32 writer_->Init(channel(), BufferedSocketWriter::WriteFailedCallback()); | 33 writer_->Init(channel(), BufferedSocketWriter::WriteFailedCallback()); |
| 33 reader_.Init(channel(), base::Bind( | 34 reader_.Init(channel(), base::Bind( |
| 34 &ClientControlDispatcher::OnMessageReceived, base::Unretained(this))); | 35 &ClientControlDispatcher::OnMessageReceived, base::Unretained(this))); |
| 35 } | 36 } |
| 36 | 37 |
| 38 void ClientControlDispatcher::InjectClipboardEvent( |
| 39 const ClipboardEvent& event) { |
| 40 ControlMessage message; |
| 41 message.mutable_clipboard_event()->CopyFrom(event); |
| 42 writer_->Write(SerializeAndFrameMessage(message), base::Closure()); |
| 43 } |
| 44 |
| 37 void ClientControlDispatcher::OnMessageReceived( | 45 void ClientControlDispatcher::OnMessageReceived( |
| 38 ControlMessage* message, const base::Closure& done_task) { | 46 ControlMessage* message, const base::Closure& done_task) { |
| 39 DCHECK(client_stub_); | 47 DCHECK(client_stub_); |
| 40 base::ScopedClosureRunner done_runner(done_task); | 48 base::ScopedClosureRunner done_runner(done_task); |
| 41 LOG(WARNING) << "Unknown control message received."; | 49 LOG(WARNING) << "Unknown control message received."; |
| 42 } | 50 } |
| 43 | 51 |
| 44 } // namespace protocol | 52 } // namespace protocol |
| 45 } // namespace remoting | 53 } // namespace remoting |
| OLD | NEW |