| 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/host_control_dispatcher.h" | 5 #include "remoting/protocol/host_control_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
| 8 #include "net/socket/stream_socket.h" | 8 #include "net/socket/stream_socket.h" |
| 9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
| 10 #include "remoting/proto/control.pb.h" | 10 #include "remoting/proto/control.pb.h" |
| 11 #include "remoting/proto/internal.pb.h" | 11 #include "remoting/proto/internal.pb.h" |
| 12 #include "remoting/protocol/buffered_socket_writer.h" | 12 #include "remoting/protocol/buffered_socket_writer.h" |
| 13 #include "remoting/protocol/clipboard_stub.h" |
| 13 #include "remoting/protocol/host_stub.h" | 14 #include "remoting/protocol/host_stub.h" |
| 14 #include "remoting/protocol/util.h" | 15 #include "remoting/protocol/util.h" |
| 15 | 16 |
| 16 namespace remoting { | 17 namespace remoting { |
| 17 namespace protocol { | 18 namespace protocol { |
| 18 | 19 |
| 19 HostControlDispatcher::HostControlDispatcher() | 20 HostControlDispatcher::HostControlDispatcher() |
| 20 : ChannelDispatcherBase(kControlChannelName), | 21 : ChannelDispatcherBase(kControlChannelName), |
| 22 clipboard_stub_(NULL), |
| 21 host_stub_(NULL), | 23 host_stub_(NULL), |
| 22 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { | 24 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { |
| 23 } | 25 } |
| 24 | 26 |
| 25 HostControlDispatcher::~HostControlDispatcher() { | 27 HostControlDispatcher::~HostControlDispatcher() { |
| 26 writer_->Close(); | 28 writer_->Close(); |
| 27 } | 29 } |
| 28 | 30 |
| 29 void HostControlDispatcher::OnInitialized() { | 31 void HostControlDispatcher::OnInitialized() { |
| 30 reader_.Init(channel(), base::Bind( | 32 reader_.Init(channel(), base::Bind( |
| 31 &HostControlDispatcher::OnMessageReceived, base::Unretained(this))); | 33 &HostControlDispatcher::OnMessageReceived, base::Unretained(this))); |
| 32 writer_->Init(channel(), BufferedSocketWriter::WriteFailedCallback()); | 34 writer_->Init(channel(), BufferedSocketWriter::WriteFailedCallback()); |
| 33 } | 35 } |
| 34 | 36 |
| 35 void HostControlDispatcher::OnMessageReceived( | 37 void HostControlDispatcher::OnMessageReceived( |
| 36 ControlMessage* message, const base::Closure& done_task) { | 38 ControlMessage* message, const base::Closure& done_task) { |
| 39 DCHECK(clipboard_stub_); |
| 37 DCHECK(host_stub_); | 40 DCHECK(host_stub_); |
| 38 LOG(WARNING) << "Unknown control message received."; | 41 |
| 39 done_task.Run(); | 42 base::ScopedClosureRunner done_runner(done_task); |
| 43 |
| 44 if (message->has_clipboard_event()) { |
| 45 clipboard_stub_->InjectClipboardEvent(message->clipboard_event()); |
| 46 } else { |
| 47 LOG(WARNING) << "Unknown control message received."; |
| 48 } |
| 40 } | 49 } |
| 41 | 50 |
| 42 } // namespace protocol | 51 } // namespace protocol |
| 43 } // namespace remoting | 52 } // namespace remoting |
| OLD | NEW |