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

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

Issue 8587053: Remove event_channel() and control_channel() from Session interface. (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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/protocol/client_control_dispatcher.h" 5 #include "remoting/protocol/client_control_dispatcher.h"
6 6
7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
9 #include "net/base/io_buffer.h" 8 #include "net/socket/stream_socket.h"
9 #include "remoting/base/constants.h"
10 #include "remoting/proto/control.pb.h" 10 #include "remoting/proto/control.pb.h"
11 #include "remoting/proto/event.pb.h"
12 #include "remoting/proto/internal.pb.h" 11 #include "remoting/proto/internal.pb.h"
12 #include "remoting/protocol/buffered_socket_writer.h"
13 #include "remoting/protocol/client_stub.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 14
18 namespace remoting { 15 namespace remoting {
19 namespace protocol { 16 namespace protocol {
20 17
21 ClientControlDispatcher::ClientControlDispatcher() 18 ClientControlDispatcher::ClientControlDispatcher()
22 : client_stub_(NULL), 19 : ChannelDispatcherBase(kControlChannelName),
20 client_stub_(NULL),
23 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { 21 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) {
24 } 22 }
25 23
26 ClientControlDispatcher::~ClientControlDispatcher() { 24 ClientControlDispatcher::~ClientControlDispatcher() {
27 writer_->Close(); 25 writer_->Close();
28 } 26 }
29 27
30 void ClientControlDispatcher::Init(protocol::Session* session) { 28 void ClientControlDispatcher::OnInitialized() {
31 DCHECK(session);
32
33 // TODO(garykac): Set write failed callback. 29 // TODO(garykac): Set write failed callback.
34 writer_->Init(session->control_channel(), 30 writer_->Init(channel(), BufferedSocketWriter::WriteFailedCallback());
35 BufferedSocketWriter::WriteFailedCallback()); 31 reader_.Init(channel(), base::Bind(
36 reader_.Init(session->control_channel(), base::Bind(
37 &ClientControlDispatcher::OnMessageReceived, base::Unretained(this))); 32 &ClientControlDispatcher::OnMessageReceived, base::Unretained(this)));
38 } 33 }
39 34
40 void ClientControlDispatcher::OnMessageReceived( 35 void ClientControlDispatcher::OnMessageReceived(
41 ControlMessage* message, const base::Closure& done_task) { 36 ControlMessage* message, const base::Closure& done_task) {
42 DCHECK(client_stub_); 37 DCHECK(client_stub_);
43 38
44 base::ScopedClosureRunner done_runner(done_task); 39 base::ScopedClosureRunner done_runner(done_task);
45 40
46 if (message->has_begin_session_deprecated()) { 41 if (message->has_begin_session_deprecated()) {
47 // Host sends legacy BeginSession message for compatibility with 42 // Host sends legacy BeginSession message for compatibility with
48 // older clients. Ignore it without warning. 43 // older clients. Ignore it without warning.
49 } else { 44 } else {
50 LOG(WARNING) << "Unknown control message received."; 45 LOG(WARNING) << "Unknown control message received.";
51 } 46 }
52 } 47 }
53 48
54 } // namespace protocol 49 } // namespace protocol
55 } // namespace remoting 50 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698