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

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

Issue 902613004: Fix ConnectionToClient to connect stubs only after authentication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@audio_pump
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
11 #include "remoting/protocol/clipboard_stub.h" 11 #include "remoting/protocol/clipboard_stub.h"
12 #include "remoting/protocol/host_control_dispatcher.h" 12 #include "remoting/protocol/host_control_dispatcher.h"
13 #include "remoting/protocol/host_event_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/host_video_dispatcher.h" 15 #include "remoting/protocol/host_video_dispatcher.h"
16 #include "remoting/protocol/input_stub.h" 16 #include "remoting/protocol/input_stub.h"
17 17
18 namespace remoting { 18 namespace remoting {
19 namespace protocol { 19 namespace protocol {
20 20
21 ConnectionToClient::ConnectionToClient(protocol::Session* session) 21 ConnectionToClient::ConnectionToClient(protocol::Session* session)
22 : handler_(nullptr), 22 : handler_(nullptr),
23 clipboard_stub_(nullptr),
24 host_stub_(nullptr),
25 input_stub_(nullptr),
26 session_(session) { 23 session_(session) {
27 session_->SetEventHandler(this); 24 session_->SetEventHandler(this);
28 } 25 }
29 26
30 ConnectionToClient::~ConnectionToClient() { 27 ConnectionToClient::~ConnectionToClient() {
31 } 28 }
32 29
33 void ConnectionToClient::SetEventHandler(EventHandler* event_handler) { 30 void ConnectionToClient::SetEventHandler(EventHandler* event_handler) {
34 DCHECK(CalledOnValidThread()); 31 DCHECK(CalledOnValidThread());
35 handler_ = event_handler; 32 handler_ = event_handler;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 64
68 // Return pointer to ClientStub. 65 // Return pointer to ClientStub.
69 ClientStub* ConnectionToClient::client_stub() { 66 ClientStub* ConnectionToClient::client_stub() {
70 DCHECK(CalledOnValidThread()); 67 DCHECK(CalledOnValidThread());
71 return control_dispatcher_.get(); 68 return control_dispatcher_.get();
72 } 69 }
73 70
74 void ConnectionToClient::set_clipboard_stub( 71 void ConnectionToClient::set_clipboard_stub(
75 protocol::ClipboardStub* clipboard_stub) { 72 protocol::ClipboardStub* clipboard_stub) {
76 DCHECK(CalledOnValidThread()); 73 DCHECK(CalledOnValidThread());
77 clipboard_stub_ = clipboard_stub; 74 control_dispatcher_->set_clipboard_stub(clipboard_stub);
78 }
79
80 ClipboardStub* ConnectionToClient::clipboard_stub() {
81 DCHECK(CalledOnValidThread());
82 return clipboard_stub_;
83 } 75 }
84 76
85 void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) { 77 void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) {
86 DCHECK(CalledOnValidThread()); 78 DCHECK(CalledOnValidThread());
87 host_stub_ = host_stub; 79 control_dispatcher_->set_host_stub(host_stub);
88 }
89
90 HostStub* ConnectionToClient::host_stub() {
91 DCHECK(CalledOnValidThread());
92 return host_stub_;
93 } 80 }
94 81
95 void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) { 82 void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) {
96 DCHECK(CalledOnValidThread()); 83 DCHECK(CalledOnValidThread());
97 input_stub_ = input_stub; 84 event_dispatcher_->set_input_stub(input_stub);
98 }
99
100 InputStub* ConnectionToClient::input_stub() {
101 DCHECK(CalledOnValidThread());
102 return input_stub_;
103 } 85 }
104 86
105 void ConnectionToClient::OnSessionStateChange(Session::State state) { 87 void ConnectionToClient::OnSessionStateChange(Session::State state) {
106 DCHECK(CalledOnValidThread()); 88 DCHECK(CalledOnValidThread());
107 89
108 DCHECK(handler_); 90 DCHECK(handler_);
109 switch(state) { 91 switch(state) {
110 case Session::INITIALIZING: 92 case Session::INITIALIZING:
111 case Session::CONNECTING: 93 case Session::CONNECTING:
112 case Session::ACCEPTING: 94 case Session::ACCEPTING:
113 case Session::CONNECTED: 95 case Session::CONNECTED:
114 // Don't care about these events. 96 // Don't care about these events.
115 break; 97 break;
116 case Session::AUTHENTICATING: 98 case Session::AUTHENTICATING:
117 handler_->OnConnectionAuthenticating(this); 99 handler_->OnConnectionAuthenticating(this);
118 break; 100 break;
119 case Session::AUTHENTICATED: 101 case Session::AUTHENTICATED:
120 // Initialize channels. 102 // Initialize channels.
121 control_dispatcher_.reset(new HostControlDispatcher()); 103 control_dispatcher_.reset(new HostControlDispatcher());
122 control_dispatcher_->Init(session_.get(), 104 control_dispatcher_->Init(session_.get(),
123 session_->config().control_config(), this); 105 session_->config().control_config(), this);
124 control_dispatcher_->set_clipboard_stub(clipboard_stub_);
125 control_dispatcher_->set_host_stub(host_stub_);
126 106
127 event_dispatcher_.reset(new HostEventDispatcher()); 107 event_dispatcher_.reset(new HostEventDispatcher());
128 event_dispatcher_->Init(session_.get(), session_->config().event_config(), 108 event_dispatcher_->Init(session_.get(), session_->config().event_config(),
129 this); 109 this);
130 event_dispatcher_->set_input_stub(input_stub_);
131 event_dispatcher_->set_event_timestamp_callback(base::Bind( 110 event_dispatcher_->set_event_timestamp_callback(base::Bind(
132 &ConnectionToClient::OnEventTimestamp, base::Unretained(this))); 111 &ConnectionToClient::OnEventTimestamp, base::Unretained(this)));
133 112
134 video_dispatcher_.reset(new HostVideoDispatcher()); 113 video_dispatcher_.reset(new HostVideoDispatcher());
135 video_dispatcher_->Init(session_.get(), session_->config().video_config(), 114 video_dispatcher_->Init(session_.get(), session_->config().video_config(),
136 this); 115 this);
137 116
138 audio_writer_ = AudioWriter::Create(session_->config()); 117 audio_writer_ = AudioWriter::Create(session_->config());
139 if (audio_writer_.get()) { 118 if (audio_writer_.get()) {
140 audio_writer_->Init(session_.get(), session_->config().audio_config(), 119 audio_writer_->Init(session_.get(), session_->config().audio_config(),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 181
203 void ConnectionToClient::CloseChannels() { 182 void ConnectionToClient::CloseChannels() {
204 control_dispatcher_.reset(); 183 control_dispatcher_.reset();
205 event_dispatcher_.reset(); 184 event_dispatcher_.reset();
206 video_dispatcher_.reset(); 185 video_dispatcher_.reset();
207 audio_writer_.reset(); 186 audio_writer_.reset();
208 } 187 }
209 188
210 } // namespace protocol 189 } // namespace protocol
211 } // namespace remoting 190 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698