OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_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 "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 switch (state) { | 160 switch (state) { |
161 case Session::INITIALIZING: | 161 case Session::INITIALIZING: |
162 case Session::CONNECTING: | 162 case Session::CONNECTING: |
163 case Session::ACCEPTING: | 163 case Session::ACCEPTING: |
164 case Session::CONNECTED: | 164 case Session::CONNECTED: |
165 // Don't care about these events. | 165 // Don't care about these events. |
166 break; | 166 break; |
167 | 167 |
168 case Session::AUTHENTICATED: | 168 case Session::AUTHENTICATED: |
| 169 SetState(AUTHENTICATED, OK); |
| 170 |
169 control_dispatcher_.reset(new ClientControlDispatcher()); | 171 control_dispatcher_.reset(new ClientControlDispatcher()); |
170 control_dispatcher_->Init( | 172 control_dispatcher_->Init( |
171 session_.get(), session_->config().control_config(), | 173 session_.get(), session_->config().control_config(), |
172 base::Bind(&ConnectionToHost::OnChannelInitialized, | 174 base::Bind(&ConnectionToHost::OnChannelInitialized, |
173 base::Unretained(this))); | 175 base::Unretained(this))); |
174 control_dispatcher_->set_client_stub(client_stub_); | 176 control_dispatcher_->set_client_stub(client_stub_); |
175 control_dispatcher_->set_clipboard_stub(clipboard_stub_); | 177 control_dispatcher_->set_clipboard_stub(clipboard_stub_); |
176 | 178 |
177 event_dispatcher_.reset(new ClientEventDispatcher()); | 179 event_dispatcher_.reset(new ClientEventDispatcher()); |
178 event_dispatcher_->Init( | 180 event_dispatcher_->Init( |
179 session_.get(), session_->config().event_config(), | 181 session_.get(), session_->config().event_config(), |
180 base::Bind(&ConnectionToHost::OnChannelInitialized, | 182 base::Bind(&ConnectionToHost::OnChannelInitialized, |
181 base::Unretained(this))); | 183 base::Unretained(this))); |
182 | 184 |
183 video_reader_ = VideoReader::Create(session_->config()); | 185 video_reader_ = VideoReader::Create(session_->config()); |
184 video_reader_->Init(session_.get(), video_stub_, base::Bind( | 186 video_reader_->Init(session_.get(), video_stub_, base::Bind( |
185 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); | 187 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
186 | 188 |
187 audio_reader_ = AudioReader::Create(session_->config()); | 189 audio_reader_ = AudioReader::Create(session_->config()); |
188 if (audio_reader_.get()) { | 190 if (audio_reader_.get()) { |
189 audio_reader_->Init( | 191 audio_reader_->Init( |
190 session_.get(), session_->config().audio_config(), | 192 session_.get(), session_->config().audio_config(), |
191 base::Bind(&ConnectionToHost::OnChannelInitialized, | 193 base::Bind(&ConnectionToHost::OnChannelInitialized, |
192 base::Unretained(this))); | 194 base::Unretained(this))); |
193 audio_reader_->set_audio_stub(audio_stub_); | 195 audio_reader_->set_audio_stub(audio_stub_); |
194 } | 196 } |
195 | |
196 SetState(AUTHENTICATED, OK); | |
197 break; | 197 break; |
198 | 198 |
199 case Session::CLOSED: | 199 case Session::CLOSED: |
200 CloseChannels(); | 200 CloseChannels(); |
201 SetState(CLOSED, OK); | 201 SetState(CLOSED, OK); |
202 break; | 202 break; |
203 | 203 |
204 case Session::FAILED: | 204 case Session::FAILED: |
205 // If we were connected then treat signaling timeout error as if | 205 // If we were connected then treat signaling timeout error as if |
206 // the connection was closed by the peer. | 206 // the connection was closed by the peer. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 if (!control_dispatcher_.get() || !control_dispatcher_->is_connected()) | 253 if (!control_dispatcher_.get() || !control_dispatcher_->is_connected()) |
254 return; | 254 return; |
255 if (!event_dispatcher_.get() || !event_dispatcher_->is_connected()) | 255 if (!event_dispatcher_.get() || !event_dispatcher_->is_connected()) |
256 return; | 256 return; |
257 if (!video_reader_.get() || !video_reader_->is_connected()) | 257 if (!video_reader_.get() || !video_reader_->is_connected()) |
258 return; | 258 return; |
259 if ((!audio_reader_.get() || !audio_reader_->is_connected()) && | 259 if ((!audio_reader_.get() || !audio_reader_->is_connected()) && |
260 session_->config().is_audio_enabled()) { | 260 session_->config().is_audio_enabled()) { |
261 return; | 261 return; |
262 } | 262 } |
263 if (state_ != CONNECTING) | 263 if (state_ != AUTHENTICATED) |
264 return; | 264 return; |
265 | 265 |
266 // Start forwarding clipboard and input events. | 266 // Start forwarding clipboard and input events. |
267 clipboard_forwarder_.set_clipboard_stub(control_dispatcher_.get()); | 267 clipboard_forwarder_.set_clipboard_stub(control_dispatcher_.get()); |
268 event_forwarder_.set_input_stub(event_dispatcher_.get()); | 268 event_forwarder_.set_input_stub(event_dispatcher_.get()); |
269 SetState(CONNECTED, OK); | 269 SetState(CONNECTED, OK); |
270 } | 270 } |
271 | 271 |
272 void ConnectionToHost::CloseOnError(ErrorCode error) { | 272 void ConnectionToHost::CloseOnError(ErrorCode error) { |
273 CloseChannels(); | 273 CloseChannels(); |
(...skipping 16 matching lines...) Expand all Loading... |
290 | 290 |
291 if (state != state_) { | 291 if (state != state_) { |
292 state_ = state; | 292 state_ = state; |
293 error_ = error; | 293 error_ = error; |
294 event_callback_->OnConnectionState(state_, error_); | 294 event_callback_->OnConnectionState(state_, error_); |
295 } | 295 } |
296 } | 296 } |
297 | 297 |
298 } // namespace protocol | 298 } // namespace protocol |
299 } // namespace remoting | 299 } // namespace remoting |
OLD | NEW |