OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "remoting/protocol/host_control_dispatcher.h" |
| 6 |
| 7 #include "base/message_loop_proxy.h" |
| 8 #include "remoting/proto/control.pb.h" |
| 9 #include "remoting/proto/internal.pb.h" |
| 10 #include "remoting/protocol/buffered_socket_writer.h" |
| 11 #include "remoting/protocol/host_stub.h" |
| 12 #include "remoting/protocol/session.h" |
| 13 #include "remoting/protocol/util.h" |
| 14 |
| 15 namespace remoting { |
| 16 namespace protocol { |
| 17 |
| 18 HostControlDispatcher::HostControlDispatcher() |
| 19 : host_stub_(NULL), |
| 20 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { |
| 21 } |
| 22 |
| 23 HostControlDispatcher::~HostControlDispatcher() { |
| 24 writer_->Close(); |
| 25 } |
| 26 |
| 27 void HostControlDispatcher::Init(Session* session) { |
| 28 DCHECK(session); |
| 29 |
| 30 reader_.Init(session->control_channel(), base::Bind( |
| 31 &HostControlDispatcher::OnMessageReceived, base::Unretained(this))); |
| 32 writer_->Init(session->control_channel(), |
| 33 BufferedSocketWriter::WriteFailedCallback()); |
| 34 |
| 35 // Write legacy BeginSession message. |
| 36 // TODO(sergeyu): Remove it. See http://crbug.com/104670 . |
| 37 protocol::ControlMessage message; |
| 38 message.mutable_begin_session_deprecated()->mutable_login_status()-> |
| 39 set_success(true); |
| 40 writer_->Write(SerializeAndFrameMessage(message), base::Closure()); |
| 41 } |
| 42 |
| 43 void HostControlDispatcher::OnMessageReceived( |
| 44 ControlMessage* message, const base::Closure& done_task) { |
| 45 DCHECK(host_stub_); |
| 46 LOG(WARNING) << "Unknown control message received."; |
| 47 done_task.Run(); |
| 48 } |
| 49 |
| 50 } // namespace protocol |
| 51 } // namespace remoting |
OLD | NEW |