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

Side by Side Diff: remoting/protocol/connection_to_client.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: fix mock objects for unittests 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_client.h" 5 #include "remoting/protocol/connection_to_client.h"
6 6
7 #include "google/protobuf/message.h" 7 #include "google/protobuf/message.h"
8 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 #include "remoting/protocol/client_control_sender.h" 9 #include "remoting/protocol/client_control_sender.h"
10 #include "remoting/protocol/host_message_dispatcher.h" 10 #include "remoting/protocol/host_message_dispatcher.h"
11 #include "remoting/protocol/host_stub.h"
12 #include "remoting/protocol/input_stub.h"
11 13
12 // TODO(hclam): Remove this header once MessageDispatcher is used. 14 // TODO(hclam): Remove this header once MessageDispatcher is used.
13 #include "remoting/base/compound_buffer.h" 15 #include "remoting/base/compound_buffer.h"
14 16
15 namespace remoting { 17 namespace remoting {
16 namespace protocol { 18 namespace protocol {
17 19
18 // Determine how many update streams we should count to find the size of 20 // Determine how many update streams we should count to find the size of
19 // average update stream. 21 // average update stream.
20 static const size_t kAverageUpdateStream = 10; 22 static const size_t kAverageUpdateStream = 10;
21 23
22 ConnectionToClient::ConnectionToClient(MessageLoop* message_loop, 24 ConnectionToClient::ConnectionToClient(MessageLoop* message_loop,
23 EventHandler* handler, 25 EventHandler* handler,
24 HostStub* host_stub, 26 HostStub* host_stub,
25 InputStub* input_stub) 27 InputStub* input_stub)
26 : loop_(message_loop), 28 : client_authenticated_(false),
29 loop_(message_loop),
27 handler_(handler), 30 handler_(handler),
28 host_stub_(host_stub), 31 host_stub_(host_stub),
29 input_stub_(input_stub) { 32 input_stub_(input_stub) {
30 DCHECK(loop_); 33 DCHECK(loop_);
31 DCHECK(handler_); 34 DCHECK(handler_);
32 } 35 }
33 36
34 ConnectionToClient::~ConnectionToClient() { 37 ConnectionToClient::~ConnectionToClient() {
35 // TODO(hclam): When we shut down the viewer we may have to close the 38 // TODO(hclam): When we shut down the viewer we may have to close the
36 // connection. 39 // connection.
(...skipping 29 matching lines...) Expand all
66 69
67 VideoStub* ConnectionToClient::video_stub() { 70 VideoStub* ConnectionToClient::video_stub() {
68 return video_writer_.get(); 71 return video_writer_.get();
69 } 72 }
70 73
71 // Return pointer to ClientStub. 74 // Return pointer to ClientStub.
72 ClientStub* ConnectionToClient::client_stub() { 75 ClientStub* ConnectionToClient::client_stub() {
73 return client_stub_.get(); 76 return client_stub_.get();
74 } 77 }
75 78
76 ConnectionToClient::ConnectionToClient() { 79 //ConnectionToClient::ConnectionToClient() {
dmac 2011/03/04 01:36:27 get rid of this then?
garykac 2011/03/04 05:33:24 oops
77 } 80 //}
78 81
79 void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) { 82 void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) {
80 if (state == protocol::Session::CONNECTED) { 83 if (state == protocol::Session::CONNECTED) {
81 client_stub_.reset(new ClientControlSender(session_->control_channel())); 84 client_stub_.reset(new ClientControlSender(session_->control_channel()));
82 video_writer_.reset(VideoWriter::Create(session_->config())); 85 video_writer_.reset(VideoWriter::Create(session_->config()));
83 video_writer_->Init(session_); 86 video_writer_->Init(session_);
84 87
85 dispatcher_.reset(new HostMessageDispatcher()); 88 dispatcher_.reset(new HostMessageDispatcher());
86 dispatcher_->Initialize(session_.get(), host_stub_, input_stub_); 89 dispatcher_->Initialize(session_.get(), host_stub_, input_stub_);
87 } 90 }
(...skipping 28 matching lines...) Expand all
116 default: 119 default:
117 // We shouldn't receive other states. 120 // We shouldn't receive other states.
118 NOTREACHED(); 121 NOTREACHED();
119 } 122 }
120 } 123 }
121 124
122 // OnClosed() is used as a callback for protocol::Session::Close(). 125 // OnClosed() is used as a callback for protocol::Session::Close().
123 void ConnectionToClient::OnClosed() { 126 void ConnectionToClient::OnClosed() {
124 } 127 }
125 128
129 void ConnectionToClient::SetClientAuthenticated(bool auth) {
130 client_authenticated_ = auth;
131
132 // Enable/disable each of the channels.
133 if (input_stub_)
134 input_stub_->SetEnable(auth);
135 if (host_stub_)
136 host_stub_->SetEnable(auth);
137 if(client_stub_.get())
138 client_stub_->SetEnable(auth);
139 }
140
126 } // namespace protocol 141 } // namespace protocol
127 } // namespace remoting 142 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698