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

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

Issue 6594138: Block event processing on host/client until the client has authenticated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 9 years, 9 months 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/callback.h" 7 #include "base/callback.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "remoting/base/constants.h" 9 #include "remoting/base/constants.h"
10 #include "remoting/jingle_glue/jingle_thread.h" 10 #include "remoting/jingle_glue/jingle_thread.h"
11 #include "remoting/proto/auth.pb.h" 11 #include "remoting/proto/auth.pb.h"
12 #include "remoting/protocol/client_message_dispatcher.h" 12 #include "remoting/protocol/client_message_dispatcher.h"
13 #include "remoting/protocol/client_stub.h" 13 #include "remoting/protocol/client_stub.h"
14 #include "remoting/protocol/host_control_sender.h" 14 #include "remoting/protocol/host_control_sender.h"
15 #include "remoting/protocol/input_sender.h" 15 #include "remoting/protocol/input_sender.h"
16 #include "remoting/protocol/jingle_session_manager.h" 16 #include "remoting/protocol/jingle_session_manager.h"
17 #include "remoting/protocol/video_reader.h" 17 #include "remoting/protocol/video_reader.h"
18 #include "remoting/protocol/video_stub.h" 18 #include "remoting/protocol/video_stub.h"
19 #include "remoting/protocol/util.h" 19 #include "remoting/protocol/util.h"
20 20
21 namespace remoting { 21 namespace remoting {
22 namespace protocol { 22 namespace protocol {
23 23
24 ConnectionToHost::ConnectionToHost(JingleThread* thread) 24 ConnectionToHost::ConnectionToHost(JingleThread* thread)
25 : thread_(thread), 25 : client_authenticated_(false),
26 thread_(thread),
26 event_callback_(NULL), 27 event_callback_(NULL),
27 dispatcher_(new ClientMessageDispatcher()) { 28 dispatcher_(new ClientMessageDispatcher()) {
28 } 29 }
29 30
30 ConnectionToHost::~ConnectionToHost() { 31 ConnectionToHost::~ConnectionToHost() {
31 } 32 }
32 33
33 InputStub* ConnectionToHost::input_stub() { 34 InputStub* ConnectionToHost::input_stub() {
34 return input_stub_.get(); 35 return input_stub_.get();
35 } 36 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 break; 178 break;
178 179
179 case Session::CLOSED: 180 case Session::CLOSED:
180 event_callback_->OnConnectionClosed(this); 181 event_callback_->OnConnectionClosed(this);
181 break; 182 break;
182 183
183 case Session::CONNECTED: 184 case Session::CONNECTED:
184 // Initialize reader and writer. 185 // Initialize reader and writer.
185 video_reader_.reset(VideoReader::Create(session_->config())); 186 video_reader_.reset(VideoReader::Create(session_->config()));
186 video_reader_->Init(session_, video_stub_); 187 video_reader_->Init(session_, video_stub_);
187 input_stub_.reset(new InputSender(session_->event_channel()));
188 host_stub_.reset(new HostControlSender(session_->control_channel())); 188 host_stub_.reset(new HostControlSender(session_->control_channel()));
189 dispatcher_->Initialize(session_.get(), client_stub_); 189 dispatcher_->Initialize(session_.get(), client_stub_);
190 event_callback_->OnConnectionOpened(this); 190 event_callback_->OnConnectionOpened(this);
191 break; 191 break;
192 192
193 default: 193 default:
194 // Ignore the other states by default. 194 // Ignore the other states by default.
195 break; 195 break;
196 } 196 }
197 } 197 }
198 198
199 void ConnectionToHost::OnClientAuthenticated() {
200 client_authenticated_ = true;
201
202 // Create and enable the input stub now that we're authenticated.
203 input_stub_.reset(new InputSender(session_->event_channel()));
204 input_stub_->OnAuthenticated();
205
206 // Enable control channel stubs.
207 if (host_stub_.get())
208 host_stub_->OnAuthenticated();
209 if (client_stub_)
210 client_stub_->OnAuthenticated();
211 }
212
199 } // namespace protocol 213 } // namespace protocol
200 } // namespace remoting 214 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698