| 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/jingle_glue/signal_strategy.h" | 11 #include "remoting/jingle_glue/signal_strategy.h" |
| 12 #include "remoting/protocol/audio_reader.h" | 12 #include "remoting/protocol/audio_reader.h" |
| 13 #include "remoting/protocol/audio_stub.h" | 13 #include "remoting/protocol/audio_stub.h" |
| 14 #include "remoting/protocol/auth_util.h" | 14 #include "remoting/protocol/auth_util.h" |
| 15 #include "remoting/protocol/authenticator.h" | 15 #include "remoting/protocol/authenticator.h" |
| 16 #include "remoting/protocol/client_control_dispatcher.h" | 16 #include "remoting/protocol/client_control_dispatcher.h" |
| 17 #include "remoting/protocol/client_event_dispatcher.h" | 17 #include "remoting/protocol/client_event_dispatcher.h" |
| 18 #include "remoting/protocol/client_stub.h" | 18 #include "remoting/protocol/client_stub.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_reader.h" | 23 #include "remoting/protocol/video_reader.h" |
| 24 #include "remoting/protocol/video_stub.h" | 24 #include "remoting/protocol/video_stub.h" |
| 25 | 25 |
| 26 namespace remoting { | 26 namespace remoting { |
| 27 namespace protocol { | 27 namespace protocol { |
| 28 | 28 |
| 29 ConnectionToHost::ConnectionToHost( | 29 ConnectionToHost::ConnectionToHost() |
| 30 bool allow_nat_traversal) | 30 : event_callback_(NULL), |
| 31 : allow_nat_traversal_(allow_nat_traversal), | |
| 32 event_callback_(NULL), | |
| 33 client_stub_(NULL), | 31 client_stub_(NULL), |
| 34 clipboard_stub_(NULL), | 32 clipboard_stub_(NULL), |
| 35 audio_stub_(NULL), | 33 audio_stub_(NULL), |
| 36 signal_strategy_(NULL), | 34 signal_strategy_(NULL), |
| 37 state_(INITIALIZING), | 35 state_(INITIALIZING), |
| 38 error_(OK) { | 36 error_(OK) { |
| 39 } | 37 } |
| 40 | 38 |
| 41 ConnectionToHost::~ConnectionToHost() { | 39 ConnectionToHost::~ConnectionToHost() { |
| 42 CloseChannels(); | 40 CloseChannels(); |
| 43 | 41 |
| 44 if (session_.get()) | 42 if (session_.get()) |
| 45 session_.reset(); | 43 session_.reset(); |
| 46 | 44 |
| 47 if (session_manager_.get()) | 45 if (session_manager_.get()) |
| 48 session_manager_.reset(); | 46 session_manager_.reset(); |
| 49 | 47 |
| 50 if (signal_strategy_) | 48 if (signal_strategy_) |
| 51 signal_strategy_->RemoveListener(this); | 49 signal_strategy_->RemoveListener(this); |
| 52 } | 50 } |
| 53 | 51 |
| 54 void ConnectionToHost::Connect(SignalStrategy* signal_strategy, | 52 void ConnectionToHost::Connect(SignalStrategy* signal_strategy, |
| 55 scoped_ptr<TransportFactory> transport_factory, | 53 scoped_ptr<TransportFactory> transport_factory, |
| 56 scoped_ptr<Authenticator> authenticator, | 54 scoped_ptr<Authenticator> authenticator, |
| 57 const std::string& host_jid, | 55 const std::string& host_jid, |
| 58 const std::string& host_public_key, | |
| 59 HostEventCallback* event_callback) { | 56 HostEventCallback* event_callback) { |
| 60 DCHECK(client_stub_); | 57 DCHECK(client_stub_); |
| 61 DCHECK(clipboard_stub_); | 58 DCHECK(clipboard_stub_); |
| 62 DCHECK(monitored_video_stub_); | 59 DCHECK(monitored_video_stub_); |
| 63 | 60 |
| 64 signal_strategy_ = signal_strategy; | 61 signal_strategy_ = signal_strategy; |
| 65 event_callback_ = event_callback; | 62 event_callback_ = event_callback; |
| 66 authenticator_ = authenticator.Pass(); | 63 authenticator_ = authenticator.Pass(); |
| 67 | 64 |
| 68 // Save jid of the host. The actual connection is created later after | 65 // Save jid of the host. The actual connection is created later after |
| 69 // |signal_strategy_| is connected. | 66 // |signal_strategy_| is connected. |
| 70 host_jid_ = host_jid; | 67 host_jid_ = host_jid; |
| 71 host_public_key_ = host_public_key; | |
| 72 | 68 |
| 73 signal_strategy_->AddListener(this); | 69 signal_strategy_->AddListener(this); |
| 74 signal_strategy_->Connect(); | 70 signal_strategy_->Connect(); |
| 75 | 71 |
| 76 session_manager_.reset(new JingleSessionManager(transport_factory.Pass())); | 72 session_manager_.reset(new JingleSessionManager(transport_factory.Pass())); |
| 77 session_manager_->Init(signal_strategy_, this); | 73 session_manager_->Init(signal_strategy_, this); |
| 78 | 74 |
| 79 SetState(CONNECTING, OK); | 75 SetState(CONNECTING, OK); |
| 80 } | 76 } |
| 81 | 77 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 289 |
| 294 if (state != state_) { | 290 if (state != state_) { |
| 295 state_ = state; | 291 state_ = state; |
| 296 error_ = error; | 292 error_ = error; |
| 297 event_callback_->OnConnectionState(state_, error_); | 293 event_callback_->OnConnectionState(state_, error_); |
| 298 } | 294 } |
| 299 } | 295 } |
| 300 | 296 |
| 301 } // namespace protocol | 297 } // namespace protocol |
| 302 } // namespace remoting | 298 } // namespace remoting |
| OLD | NEW |