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

Side by Side Diff: remoting/protocol/host_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/host_control_dispatcher.h" 5 #include "remoting/protocol/host_control_dispatcher.h"
6 6
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "net/socket/stream_socket.h"
9 #include "remoting/base/constants.h"
8 #include "remoting/proto/control.pb.h" 10 #include "remoting/proto/control.pb.h"
9 #include "remoting/proto/internal.pb.h" 11 #include "remoting/proto/internal.pb.h"
10 #include "remoting/protocol/buffered_socket_writer.h" 12 #include "remoting/protocol/buffered_socket_writer.h"
11 #include "remoting/protocol/host_stub.h" 13 #include "remoting/protocol/host_stub.h"
12 #include "remoting/protocol/session.h"
13 #include "remoting/protocol/util.h" 14 #include "remoting/protocol/util.h"
14 15
15 namespace remoting { 16 namespace remoting {
16 namespace protocol { 17 namespace protocol {
17 18
18 HostControlDispatcher::HostControlDispatcher() 19 HostControlDispatcher::HostControlDispatcher()
19 : host_stub_(NULL), 20 : ChannelDispatcherBase(kControlChannelName),
21 host_stub_(NULL),
20 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) { 22 writer_(new BufferedSocketWriter(base::MessageLoopProxy::current())) {
21 } 23 }
22 24
23 HostControlDispatcher::~HostControlDispatcher() { 25 HostControlDispatcher::~HostControlDispatcher() {
24 writer_->Close(); 26 writer_->Close();
25 } 27 }
26 28
27 void HostControlDispatcher::Init(Session* session) { 29 void HostControlDispatcher::OnInitialized() {
28 DCHECK(session); 30 reader_.Init(channel(), base::Bind(
29
30 reader_.Init(session->control_channel(), base::Bind(
31 &HostControlDispatcher::OnMessageReceived, base::Unretained(this))); 31 &HostControlDispatcher::OnMessageReceived, base::Unretained(this)));
32 writer_->Init(session->control_channel(), 32 writer_->Init(channel(), BufferedSocketWriter::WriteFailedCallback());
33 BufferedSocketWriter::WriteFailedCallback());
34 33
35 // Write legacy BeginSession message. 34 // Write legacy BeginSession message.
36 protocol::ControlMessage message; 35 protocol::ControlMessage message;
37 message.mutable_begin_session_deprecated()->mutable_login_status()-> 36 message.mutable_begin_session_deprecated()->mutable_login_status()->
38 set_success(true); 37 set_success(true);
39 writer_->Write(SerializeAndFrameMessage(message), base::Closure()); 38 writer_->Write(SerializeAndFrameMessage(message), base::Closure());
40 } 39 }
41 40
42 void HostControlDispatcher::OnMessageReceived( 41 void HostControlDispatcher::OnMessageReceived(
43 ControlMessage* message, const base::Closure& done_task) { 42 ControlMessage* message, const base::Closure& done_task) {
44 DCHECK(host_stub_); 43 DCHECK(host_stub_);
45 LOG(WARNING) << "Unknown control message received."; 44 LOG(WARNING) << "Unknown control message received.";
46 done_task.Run(); 45 done_task.Run();
47 } 46 }
48 47
49 } // namespace protocol 48 } // namespace protocol
50 } // namespace remoting 49 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698