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/client_control_dispatcher.h" | |
6 | |
7 #include "base/memory/ref_counted.h" | |
8 #include "base/message_loop_proxy.h" | |
9 #include "net/base/io_buffer.h" | |
10 #include "remoting/proto/control.pb.h" | |
11 #include "remoting/proto/event.pb.h" | |
12 #include "remoting/proto/internal.pb.h" | |
13 #include "remoting/protocol/client_stub.h" | |
14 #include "remoting/protocol/input_stub.h" | |
15 #include "remoting/protocol/message_reader.h" | |
16 #include "remoting/protocol/session.h" | |
17 | |
18 namespace remoting { | |
19 namespace protocol { | |
20 | |
21 ClientControlDispatcher::ClientControlDispatcher() | |
22 : client_stub_(NULL), | |
23 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { | |
24 } | |
25 | |
26 ClientControlDispatcher::~ClientControlDispatcher() { | |
27 writer_->Close(); | |
28 } | |
29 | |
30 void ClientControlDispatcher::Init(protocol::Session* session) { | |
31 DCHECK(session); | |
32 | |
33 // TODO(garykac): Set write failed callback. | |
34 writer_->Init(session->control_channel(), | |
35 BufferedSocketWriter::WriteFailedCallback()); | |
36 reader_.Init(session->control_channel(), base::Bind( | |
37 &ClientControlDispatcher::OnMessageReceived, base::Unretained(this))); | |
38 } | |
39 | |
40 void ClientControlDispatcher::OnMessageReceived( | |
41 ControlMessage* message, const base::Closure& done_task) { | |
42 DCHECK(client_stub_); | |
43 | |
44 if (message->has_begin_session_deprecated()) { | |
45 // Host sends legacy BeginSession message for compatibility with | |
46 // older clients. Ignore it. | |
Wez
2011/11/17 22:30:22
nit: Ignore it without warning.
Sergey Ulanov
2011/11/17 22:48:08
Done.
| |
47 } else { | |
48 LOG(WARNING) << "Unknown control message received."; | |
49 } | |
50 done_task.Run(); | |
Wez
2011/11/17 22:30:22
nit: Use a ScopedClosureRunner so that future chan
Sergey Ulanov
2011/11/17 22:48:08
Done.
| |
51 } | |
52 | |
53 } // namespace protocol | |
54 } // namespace remoting | |
OLD | NEW |