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

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

Issue 8468022: Refactor channel dispatchers on the host side. (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
« no previous file with comments | « remoting/protocol/connection_to_client.h ('k') | remoting/protocol/host_control_dispatcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/connection_to_client.h" 5 #include "remoting/protocol/connection_to_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "google/protobuf/message.h" 10 #include "google/protobuf/message.h"
11 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
12 #include "remoting/protocol/client_control_sender.h" 12 #include "remoting/protocol/host_control_dispatcher.h"
13 #include "remoting/protocol/host_message_dispatcher.h" 13 #include "remoting/protocol/host_event_dispatcher.h"
14 #include "remoting/protocol/host_stub.h" 14 #include "remoting/protocol/host_stub.h"
15 #include "remoting/protocol/input_stub.h" 15 #include "remoting/protocol/input_stub.h"
16 16
17 namespace remoting { 17 namespace remoting {
18 namespace protocol { 18 namespace protocol {
19 19
20 ConnectionToClient::ConnectionToClient(protocol::Session* session) 20 ConnectionToClient::ConnectionToClient(protocol::Session* session)
21 : handler_(NULL), 21 : handler_(NULL),
22 host_stub_(NULL), 22 host_stub_(NULL),
23 input_stub_(NULL), 23 input_stub_(NULL),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 72
73 VideoStub* ConnectionToClient::video_stub() { 73 VideoStub* ConnectionToClient::video_stub() {
74 DCHECK(CalledOnValidThread()); 74 DCHECK(CalledOnValidThread());
75 return video_writer_.get(); 75 return video_writer_.get();
76 } 76 }
77 77
78 // Return pointer to ClientStub. 78 // Return pointer to ClientStub.
79 ClientStub* ConnectionToClient::client_stub() { 79 ClientStub* ConnectionToClient::client_stub() {
80 DCHECK(CalledOnValidThread()); 80 DCHECK(CalledOnValidThread());
81 return client_control_sender_.get(); 81 return control_dispatcher_.get();
82 } 82 }
83 83
84 void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) { 84 void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) {
85 DCHECK(CalledOnValidThread()); 85 DCHECK(CalledOnValidThread());
86 host_stub_ = host_stub; 86 host_stub_ = host_stub;
87 } 87 }
88 88
89 void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) { 89 void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) {
90 DCHECK(CalledOnValidThread()); 90 DCHECK(CalledOnValidThread());
91 input_stub_ = input_stub; 91 input_stub_ = input_stub;
(...skipping 11 matching lines...) Expand all
103 case protocol::Session::CONNECTED: 103 case protocol::Session::CONNECTED:
104 video_writer_.reset( 104 video_writer_.reset(
105 VideoWriter::Create(base::MessageLoopProxy::current(), 105 VideoWriter::Create(base::MessageLoopProxy::current(),
106 session_->config())); 106 session_->config()));
107 video_writer_->Init( 107 video_writer_->Init(
108 session_.get(), base::Bind(&ConnectionToClient::OnVideoInitialized, 108 session_.get(), base::Bind(&ConnectionToClient::OnVideoInitialized,
109 base::Unretained(this))); 109 base::Unretained(this)));
110 break; 110 break;
111 111
112 case protocol::Session::CONNECTED_CHANNELS: 112 case protocol::Session::CONNECTED_CHANNELS:
113 client_control_sender_.reset( 113 control_dispatcher_.reset(new HostControlDispatcher());
114 new ClientControlSender(base::MessageLoopProxy::current(), 114 control_dispatcher_->Init(session_.get());
115 session_->control_channel())); 115 control_dispatcher_->set_host_stub(host_stub_);
116 dispatcher_.reset(new HostMessageDispatcher()); 116 input_dispatcher_.reset(new HostEventDispatcher());
117 dispatcher_->Initialize(this, host_stub_, input_stub_); 117 input_dispatcher_->Init(session_.get());
118 input_dispatcher_->set_input_stub(input_stub_);
119 input_dispatcher_->set_sequence_number_callback(base::Bind(
120 &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this)));
118 121
119 control_connected_ = true; 122 control_connected_ = true;
120 input_connected_ = true; 123 input_connected_ = true;
121 NotifyIfChannelsReady(); 124 NotifyIfChannelsReady();
122 break; 125 break;
123 126
124 case protocol::Session::CLOSED: 127 case protocol::Session::CLOSED:
125 CloseChannels(); 128 CloseChannels();
126 handler_->OnConnectionClosed(this); 129 handler_->OnConnectionClosed(this);
127 break; 130 break;
(...skipping 27 matching lines...) Expand all
155 if (control_connected_ && input_connected_ && video_connected_) 158 if (control_connected_ && input_connected_ && video_connected_)
156 handler_->OnConnectionOpened(this); 159 handler_->OnConnectionOpened(this);
157 } 160 }
158 161
159 void ConnectionToClient::CloseOnError() { 162 void ConnectionToClient::CloseOnError() {
160 CloseChannels(); 163 CloseChannels();
161 handler_->OnConnectionFailed(this); 164 handler_->OnConnectionFailed(this);
162 } 165 }
163 166
164 void ConnectionToClient::CloseChannels() { 167 void ConnectionToClient::CloseChannels() {
168 control_dispatcher_.reset();
169 input_dispatcher_.reset();
165 video_writer_.reset(); 170 video_writer_.reset();
166 client_control_sender_.reset();
167 dispatcher_.reset();
168 } 171 }
169 172
170 } // namespace protocol 173 } // namespace protocol
171 } // namespace remoting 174 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/connection_to_client.h ('k') | remoting/protocol/host_control_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698