Chromium Code Reviews| 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. | |
|
Wez
2011/11/17 22:25:16
We should remove this once clients can reasonably
Sergey Ulanov
2011/11/17 22:41:39
Done.
| |
| 36 protocol::ControlMessage message; | |
| 37 message.mutable_begin_session_deprecated()->mutable_login_status()-> | |
| 38 set_success(true); | |
| 39 writer_->Write(SerializeAndFrameMessage(message), base::Closure()); | |
| 40 } | |
| 41 | |
| 42 void HostControlDispatcher::OnMessageReceived( | |
| 43 ControlMessage* message, const base::Closure& done_task) { | |
| 44 DCHECK(host_stub_); | |
| 45 LOG(WARNING) << "Unknown control message received."; | |
| 46 done_task.Run(); | |
| 47 } | |
| 48 | |
| 49 } // namespace protocol | |
| 50 } // namespace remoting | |
| OLD | NEW |