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 "remoting/protocol/buffered_socket_writer.h" | |
|
Wez
2011/11/17 02:03:40
This belongs after the remoting/proto/ includes?
Sergey Ulanov
2011/11/17 18:38:14
Done.
| |
| 8 #include "remoting/proto/control.pb.h" | |
| 9 #include "remoting/proto/internal.pb.h" | |
| 10 #include "remoting/protocol/host_stub.h" | |
| 11 #include "remoting/protocol/session.h" | |
| 12 #include "remoting/protocol/util.h" | |
| 13 | |
| 14 namespace remoting { | |
| 15 namespace protocol { | |
| 16 | |
| 17 HostControlDispatcher::HostControlDispatcher( | |
| 18 base::MessageLoopProxy* message_loop) | |
| 19 : host_stub_(NULL), | |
| 20 writer_(new BufferedSocketWriter(message_loop)) { | |
| 21 } | |
| 22 | |
| 23 HostControlDispatcher::~HostControlDispatcher() { | |
| 24 Close(); | |
| 25 } | |
| 26 | |
| 27 void HostControlDispatcher::Init(Session* session, HostStub* host_stub) { | |
| 28 DCHECK(session); | |
| 29 DCHECK(host_stub); | |
| 30 | |
| 31 host_stub_ = host_stub; | |
| 32 | |
| 33 reader_.Init(session->control_channel(), base::Bind( | |
| 34 &HostControlDispatcher::OnMessageReceived, base::Unretained(this))); | |
| 35 writer_->Init(session->control_channel(), | |
| 36 BufferedSocketWriter::WriteFailedCallback()); | |
| 37 | |
| 38 // Write legacy BeginSession message. | |
| 39 protocol::ControlMessage message; | |
| 40 message.mutable_begin_session_deprecated()->mutable_login_status()-> | |
| 41 set_success(true); | |
| 42 writer_->Write(SerializeAndFrameMessage(message), base::Closure()); | |
|
Wez
2011/11/17 02:03:40
Is it really the dispatcher's responsibility to do
Sergey Ulanov
2011/11/17 18:38:14
I'd like to hide version-dependent details inside
| |
| 43 } | |
| 44 | |
| 45 void HostControlDispatcher::OnMessageReceived( | |
| 46 ControlMessage* message, const base::Closure& done_task) { | |
| 47 LOG(WARNING) << "Invalid control message received."; | |
|
Wez
2011/11/17 02:03:40
nit: Not "invalid", just "unknown"!
Sergey Ulanov
2011/11/17 18:38:14
Done.
| |
| 48 done_task.Run(); | |
| 49 } | |
| 50 | |
| 51 void HostControlDispatcher::Close() { | |
| 52 writer_->Close(); | |
| 53 } | |
| 54 | |
| 55 } // namespace protocol | |
| 56 } // namespace remoting | |
| OLD | NEW |