| 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" |
| 11 #include "remoting/protocol/audio_reader.h" | 11 #include "remoting/protocol/audio_reader.h" |
| 12 #include "remoting/protocol/audio_stub.h" | 12 #include "remoting/protocol/audio_stub.h" |
| 13 #include "remoting/protocol/auth_util.h" | 13 #include "remoting/protocol/auth_util.h" |
| 14 #include "remoting/protocol/authenticator.h" | 14 #include "remoting/protocol/authenticator.h" |
| 15 #include "remoting/protocol/client_control_dispatcher.h" | 15 #include "remoting/protocol/client_control_dispatcher.h" |
| 16 #include "remoting/protocol/client_event_dispatcher.h" | 16 #include "remoting/protocol/client_event_dispatcher.h" |
| 17 #include "remoting/protocol/client_stub.h" | 17 #include "remoting/protocol/client_stub.h" |
| 18 #include "remoting/protocol/client_video_dispatcher.h" | 18 #include "remoting/protocol/client_video_dispatcher.h" |
| 19 #include "remoting/protocol/clipboard_stub.h" | 19 #include "remoting/protocol/clipboard_stub.h" |
| 20 #include "remoting/protocol/errors.h" | 20 #include "remoting/protocol/errors.h" |
| 21 #include "remoting/protocol/jingle_session_manager.h" | 21 #include "remoting/protocol/jingle_session_manager.h" |
| 22 #include "remoting/protocol/transport.h" | 22 #include "remoting/protocol/transport.h" |
| 23 #include "remoting/protocol/video_stub.h" | 23 #include "remoting/protocol/video_stub.h" |
| 24 | 24 |
| 25 namespace remoting { | 25 namespace remoting { |
| 26 namespace protocol { | 26 namespace protocol { |
| 27 | 27 |
| 28 ConnectionToHost::ConnectionToHost() | 28 ConnectionToHost::ConnectionToHost() |
| 29 : event_callback_(NULL), | 29 : event_callback_(nullptr), |
| 30 client_stub_(NULL), | 30 client_stub_(nullptr), |
| 31 clipboard_stub_(NULL), | 31 clipboard_stub_(nullptr), |
| 32 audio_stub_(NULL), | 32 audio_stub_(nullptr), |
| 33 signal_strategy_(NULL), | 33 signal_strategy_(nullptr), |
| 34 state_(INITIALIZING), | 34 state_(INITIALIZING), |
| 35 error_(OK) { | 35 error_(OK) { |
| 36 } | 36 } |
| 37 | 37 |
| 38 ConnectionToHost::~ConnectionToHost() { | 38 ConnectionToHost::~ConnectionToHost() { |
| 39 CloseChannels(); | 39 CloseChannels(); |
| 40 | 40 |
| 41 if (session_.get()) | 41 if (session_.get()) |
| 42 session_.reset(); | 42 session_.reset(); |
| 43 | 43 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 280 } |
| 281 | 281 |
| 282 void ConnectionToHost::CloseOnError(ErrorCode error) { | 282 void ConnectionToHost::CloseOnError(ErrorCode error) { |
| 283 CloseChannels(); | 283 CloseChannels(); |
| 284 SetState(FAILED, error); | 284 SetState(FAILED, error); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void ConnectionToHost::CloseChannels() { | 287 void ConnectionToHost::CloseChannels() { |
| 288 control_dispatcher_.reset(); | 288 control_dispatcher_.reset(); |
| 289 event_dispatcher_.reset(); | 289 event_dispatcher_.reset(); |
| 290 clipboard_forwarder_.set_clipboard_stub(NULL); | 290 clipboard_forwarder_.set_clipboard_stub(nullptr); |
| 291 event_forwarder_.set_input_stub(NULL); | 291 event_forwarder_.set_input_stub(nullptr); |
| 292 video_dispatcher_.reset(); | 292 video_dispatcher_.reset(); |
| 293 audio_reader_.reset(); | 293 audio_reader_.reset(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 void ConnectionToHost::SetState(State state, ErrorCode error) { | 296 void ConnectionToHost::SetState(State state, ErrorCode error) { |
| 297 DCHECK(CalledOnValidThread()); | 297 DCHECK(CalledOnValidThread()); |
| 298 // |error| should be specified only when |state| is set to FAILED. | 298 // |error| should be specified only when |state| is set to FAILED. |
| 299 DCHECK(state == FAILED || error == OK); | 299 DCHECK(state == FAILED || error == OK); |
| 300 | 300 |
| 301 if (state != state_) { | 301 if (state != state_) { |
| 302 state_ = state; | 302 state_ = state; |
| 303 error_ = error; | 303 error_ = error; |
| 304 event_callback_->OnConnectionState(state_, error_); | 304 event_callback_->OnConnectionState(state_, error_); |
| 305 } | 305 } |
| 306 } | 306 } |
| 307 | 307 |
| 308 } // namespace protocol | 308 } // namespace protocol |
| 309 } // namespace remoting | 309 } // namespace remoting |
| OLD | NEW |