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

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

Issue 8351084: Remove old Authentication code that we don't use or need. (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/connection_to_host.h" 5 #include "remoting/protocol/connection_to_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 void ConnectionToHost::OnIncomingSession( 150 void ConnectionToHost::OnIncomingSession(
151 Session* session, 151 Session* session,
152 SessionManager::IncomingSessionResponse* response) { 152 SessionManager::IncomingSessionResponse* response) {
153 DCHECK(message_loop_->BelongsToCurrentThread()); 153 DCHECK(message_loop_->BelongsToCurrentThread());
154 // Client always rejects incoming sessions. 154 // Client always rejects incoming sessions.
155 *response = SessionManager::DECLINE; 155 *response = SessionManager::DECLINE;
156 } 156 }
157 157
158 void ConnectionToHost::OnClientAuthenticated() {
159 // TODO(hclam): Don't send anything except authentication request if it is
160 // not authenticated.
161 SetState(AUTHENTICATED, OK);
162
163 // Create and enable the input stub now that we're authenticated.
164 input_sender_.reset(
165 new InputSender(message_loop_, session_->event_channel()));
166 }
167
168 ConnectionToHost::State ConnectionToHost::state() const { 158 ConnectionToHost::State ConnectionToHost::state() const {
169 return state_; 159 return state_;
170 } 160 }
171 161
172 void ConnectionToHost::OnSessionStateChange( 162 void ConnectionToHost::OnSessionStateChange(
173 Session::State state) { 163 Session::State state) {
174 DCHECK(message_loop_->BelongsToCurrentThread()); 164 DCHECK(message_loop_->BelongsToCurrentThread());
175 DCHECK(event_callback_); 165 DCHECK(event_callback_);
176 166
177 switch (state) { 167 switch (state) {
(...skipping 27 matching lines...) Expand all
205 VideoReader::Create(message_loop_, session_->config())); 195 VideoReader::Create(message_loop_, session_->config()));
206 video_reader_->Init( 196 video_reader_->Init(
207 session_.get(), video_stub_, 197 session_.get(), video_stub_,
208 base::Bind(&ConnectionToHost::OnVideoChannelInitialized, 198 base::Bind(&ConnectionToHost::OnVideoChannelInitialized,
209 base::Unretained(this))); 199 base::Unretained(this)));
210 break; 200 break;
211 201
212 case Session::CONNECTED_CHANNELS: 202 case Session::CONNECTED_CHANNELS:
213 host_control_sender_.reset( 203 host_control_sender_.reset(
214 new HostControlSender(message_loop_, session_->control_channel())); 204 new HostControlSender(message_loop_, session_->control_channel()));
205 input_sender_.reset(
206 new InputSender(message_loop_, session_->event_channel()));
215 dispatcher_.reset(new ClientMessageDispatcher()); 207 dispatcher_.reset(new ClientMessageDispatcher());
216 dispatcher_->Initialize(session_.get(), client_stub_); 208 dispatcher_->Initialize(session_.get(), client_stub_);
217 209
218 control_connected_ = true; 210 control_connected_ = true;
219 input_connected_ = true; 211 input_connected_ = true;
220 NotifyIfChannelsReady(); 212 NotifyIfChannelsReady();
221 break; 213 break;
222 214
223 default: 215 default:
224 // Ignore the other states by default. 216 // Ignore the other states by default.
225 break; 217 break;
226 } 218 }
227 } 219 }
228 220
229 void ConnectionToHost::OnVideoChannelInitialized(bool successful) { 221 void ConnectionToHost::OnVideoChannelInitialized(bool successful) {
230 if (!successful) { 222 if (!successful) {
231 LOG(ERROR) << "Failed to connect video channel"; 223 LOG(ERROR) << "Failed to connect video channel";
232 CloseOnError(NETWORK_FAILURE); 224 CloseOnError(NETWORK_FAILURE);
233 return; 225 return;
234 } 226 }
235 227
236 video_connected_ = true; 228 video_connected_ = true;
237 NotifyIfChannelsReady(); 229 NotifyIfChannelsReady();
238 } 230 }
239 231
240 void ConnectionToHost::NotifyIfChannelsReady() { 232 void ConnectionToHost::NotifyIfChannelsReady() {
241 if (control_connected_ && input_connected_ && video_connected_ && 233 if (control_connected_ && input_connected_ && video_connected_ &&
242 state_ == CONNECTING) { 234 state_ == CONNECTING) {
243 SetState(CONNECTED, OK); 235 SetState(CONNECTED, OK);
236 SetState(AUTHENTICATED, OK);
244 } 237 }
245 } 238 }
246 239
247 void ConnectionToHost::CloseOnError(Error error) { 240 void ConnectionToHost::CloseOnError(Error error) {
248 CloseChannels(); 241 CloseChannels();
249 SetState(FAILED, error); 242 SetState(FAILED, error);
250 } 243 }
251 244
252 void ConnectionToHost::CloseChannels() { 245 void ConnectionToHost::CloseChannels() {
253 if (input_sender_.get()) 246 if (input_sender_.get())
(...skipping 12 matching lines...) Expand all
266 259
267 if (state != state_) { 260 if (state != state_) {
268 state_ = state; 261 state_ = state;
269 error_ = error; 262 error_ = error;
270 event_callback_->OnConnectionState(state_, error_); 263 event_callback_->OnConnectionState(state_, error_);
271 } 264 }
272 } 265 }
273 266
274 } // namespace protocol 267 } // namespace protocol
275 } // namespace remoting 268 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698