| OLD | NEW |
| 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 clipboard_stub_(NULL), |
| 25 cursor_shape_stub_(NULL), |
| 25 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { | 26 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { |
| 26 } | 27 } |
| 27 | 28 |
| 28 ClientControlDispatcher::~ClientControlDispatcher() { | 29 ClientControlDispatcher::~ClientControlDispatcher() { |
| 29 writer_->Close(); | 30 writer_->Close(); |
| 30 } | 31 } |
| 31 | 32 |
| 32 void ClientControlDispatcher::OnInitialized() { | 33 void ClientControlDispatcher::OnInitialized() { |
| 33 // TODO(garykac): Set write failed callback. | 34 // TODO(garykac): Set write failed callback. |
| 34 writer_->Init(channel(), BufferedSocketWriter::WriteFailedCallback()); | 35 writer_->Init(channel(), BufferedSocketWriter::WriteFailedCallback()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 57 } | 58 } |
| 58 | 59 |
| 59 void ClientControlDispatcher::OnMessageReceived( | 60 void ClientControlDispatcher::OnMessageReceived( |
| 60 scoped_ptr<ControlMessage> message, const base::Closure& done_task) { | 61 scoped_ptr<ControlMessage> message, const base::Closure& done_task) { |
| 61 DCHECK(client_stub_); | 62 DCHECK(client_stub_); |
| 62 DCHECK(clipboard_stub_); | 63 DCHECK(clipboard_stub_); |
| 63 base::ScopedClosureRunner done_runner(done_task); | 64 base::ScopedClosureRunner done_runner(done_task); |
| 64 | 65 |
| 65 if (message->has_clipboard_event()) { | 66 if (message->has_clipboard_event()) { |
| 66 clipboard_stub_->InjectClipboardEvent(message->clipboard_event()); | 67 clipboard_stub_->InjectClipboardEvent(message->clipboard_event()); |
| 68 } else if (message->has_cursor_shape()) { |
| 69 cursor_shape_stub_->SetCursorShape(message->cursor_shape()); |
| 67 } else { | 70 } else { |
| 68 LOG(WARNING) << "Unknown control message received."; | 71 LOG(WARNING) << "Unknown control message received."; |
| 69 } | 72 } |
| 70 } | 73 } |
| 71 | 74 |
| 72 } // namespace protocol | 75 } // namespace protocol |
| 73 } // namespace remoting | 76 } // namespace remoting |
| OLD | NEW |