Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: remoting/protocol/client_control_dispatcher.cc

Issue 8574025: Refactor client channel dispatchers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 base::ScopedClosureRunner done_runner(done_task);
45
46 if (message->has_begin_session_deprecated()) {
47 // Host sends legacy BeginSession message for compatibility with
48 // older clients. Ignore it without warning.
49 } else {
50 LOG(WARNING) << "Unknown control message received.";
51 }
52 }
53
54 } // namespace protocol
55 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/client_control_dispatcher.h ('k') | remoting/protocol/client_event_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698