| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_impl.h" | 5 #include "remoting/protocol/connection_to_host_impl.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/ice_transport.h" |
| 21 #include "remoting/protocol/jingle_session_manager.h" | 22 #include "remoting/protocol/jingle_session_manager.h" |
| 22 #include "remoting/protocol/transport.h" | 23 #include "remoting/protocol/transport.h" |
| 24 #include "remoting/protocol/transport_context.h" |
| 23 #include "remoting/protocol/video_stub.h" | 25 #include "remoting/protocol/video_stub.h" |
| 24 | 26 |
| 25 namespace remoting { | 27 namespace remoting { |
| 26 namespace protocol { | 28 namespace protocol { |
| 27 | 29 |
| 28 ConnectionToHostImpl::ConnectionToHostImpl() | 30 ConnectionToHostImpl::ConnectionToHostImpl() |
| 29 : event_callback_(nullptr), | 31 : event_callback_(nullptr), |
| 30 client_stub_(nullptr), | 32 client_stub_(nullptr), |
| 31 clipboard_stub_(nullptr), | 33 clipboard_stub_(nullptr), |
| 32 audio_stub_(nullptr), | 34 audio_stub_(nullptr), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 59 RETURN_STRING_LITERAL(CONNECTED); | 61 RETURN_STRING_LITERAL(CONNECTED); |
| 60 RETURN_STRING_LITERAL(CLOSED); | 62 RETURN_STRING_LITERAL(CLOSED); |
| 61 RETURN_STRING_LITERAL(FAILED); | 63 RETURN_STRING_LITERAL(FAILED); |
| 62 } | 64 } |
| 63 NOTREACHED(); | 65 NOTREACHED(); |
| 64 return nullptr; | 66 return nullptr; |
| 65 } | 67 } |
| 66 | 68 |
| 67 void ConnectionToHostImpl::Connect( | 69 void ConnectionToHostImpl::Connect( |
| 68 SignalStrategy* signal_strategy, | 70 SignalStrategy* signal_strategy, |
| 69 scoped_ptr<TransportFactory> transport_factory, | 71 scoped_refptr<TransportContext> transport_context, |
| 70 scoped_ptr<Authenticator> authenticator, | 72 scoped_ptr<Authenticator> authenticator, |
| 71 const std::string& host_jid, | 73 const std::string& host_jid, |
| 72 HostEventCallback* event_callback) { | 74 HostEventCallback* event_callback) { |
| 73 DCHECK(client_stub_); | 75 DCHECK(client_stub_); |
| 74 DCHECK(clipboard_stub_); | 76 DCHECK(clipboard_stub_); |
| 75 DCHECK(monitored_video_stub_); | 77 DCHECK(monitored_video_stub_); |
| 76 | 78 |
| 77 // Initialize default |candidate_config_| if set_candidate_config() wasn't | 79 // Initialize default |candidate_config_| if set_candidate_config() wasn't |
| 78 // called. | 80 // called. |
| 79 if (!candidate_config_) | 81 if (!candidate_config_) |
| 80 candidate_config_ = CandidateSessionConfig::CreateDefault(); | 82 candidate_config_ = CandidateSessionConfig::CreateDefault(); |
| 81 if (!audio_stub_) | 83 if (!audio_stub_) |
| 82 candidate_config_->DisableAudioChannel(); | 84 candidate_config_->DisableAudioChannel(); |
| 83 | 85 |
| 84 signal_strategy_ = signal_strategy; | 86 signal_strategy_ = signal_strategy; |
| 85 event_callback_ = event_callback; | 87 event_callback_ = event_callback; |
| 86 authenticator_ = authenticator.Pass(); | 88 authenticator_ = authenticator.Pass(); |
| 87 | 89 |
| 88 // Save jid of the host. The actual connection is created later after | 90 // Save jid of the host. The actual connection is created later after |
| 89 // |signal_strategy_| is connected. | 91 // |signal_strategy_| is connected. |
| 90 host_jid_ = host_jid; | 92 host_jid_ = host_jid; |
| 91 | 93 |
| 92 signal_strategy_->AddListener(this); | 94 signal_strategy_->AddListener(this); |
| 93 | 95 |
| 94 session_manager_.reset(new JingleSessionManager(transport_factory.Pass())); | 96 session_manager_.reset(new JingleSessionManager( |
| 97 make_scoped_ptr(new IceTransportFactory(transport_context)))); |
| 95 session_manager_->set_protocol_config(candidate_config_->Clone()); | 98 session_manager_->set_protocol_config(candidate_config_->Clone()); |
| 96 session_manager_->Init(signal_strategy_, this); | 99 session_manager_->Init(signal_strategy_, this); |
| 97 | 100 |
| 98 SetState(CONNECTING, OK); | 101 SetState(CONNECTING, OK); |
| 99 | 102 |
| 100 switch (signal_strategy_->GetState()) { | 103 switch (signal_strategy_->GetState()) { |
| 101 case SignalStrategy::CONNECTING: | 104 case SignalStrategy::CONNECTING: |
| 102 // Nothing to do here. Just need to wait until |signal_strategy_| becomes | 105 // Nothing to do here. Just need to wait until |signal_strategy_| becomes |
| 103 // connected. | 106 // connected. |
| 104 break; | 107 break; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 326 |
| 324 if (state != state_) { | 327 if (state != state_) { |
| 325 state_ = state; | 328 state_ = state; |
| 326 error_ = error; | 329 error_ = error; |
| 327 event_callback_->OnConnectionState(state_, error_); | 330 event_callback_->OnConnectionState(state_, error_); |
| 328 } | 331 } |
| 329 } | 332 } |
| 330 | 333 |
| 331 } // namespace protocol | 334 } // namespace protocol |
| 332 } // namespace remoting | 335 } // namespace remoting |
| OLD | NEW |