| 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 "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "remoting/base/constants.h" | 11 #include "remoting/base/constants.h" |
| 12 #include "remoting/jingle_glue/javascript_signal_strategy.h" | 12 #include "remoting/jingle_glue/javascript_signal_strategy.h" |
| 13 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 13 #include "remoting/jingle_glue/xmpp_signal_strategy.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/errors.h" | 20 #include "remoting/protocol/errors.h" |
| 20 #include "remoting/protocol/jingle_session_manager.h" | 21 #include "remoting/protocol/jingle_session_manager.h" |
| 21 #include "remoting/protocol/pepper_transport_factory.h" | 22 #include "remoting/protocol/pepper_transport_factory.h" |
| 22 #include "remoting/protocol/video_reader.h" | 23 #include "remoting/protocol/video_reader.h" |
| 23 #include "remoting/protocol/video_stub.h" | 24 #include "remoting/protocol/video_stub.h" |
| 24 #include "remoting/protocol/util.h" | 25 #include "remoting/protocol/util.h" |
| 25 | 26 |
| 26 namespace remoting { | 27 namespace remoting { |
| 27 namespace protocol { | 28 namespace protocol { |
| 28 | 29 |
| 29 ConnectionToHost::ConnectionToHost( | 30 ConnectionToHost::ConnectionToHost( |
| 30 base::MessageLoopProxy* message_loop, | 31 base::MessageLoopProxy* message_loop, |
| 31 pp::Instance* pp_instance, | 32 pp::Instance* pp_instance, |
| 32 bool allow_nat_traversal) | 33 bool allow_nat_traversal) |
| 33 : message_loop_(message_loop), | 34 : message_loop_(message_loop), |
| 34 pp_instance_(pp_instance), | 35 pp_instance_(pp_instance), |
| 35 allow_nat_traversal_(allow_nat_traversal), | 36 allow_nat_traversal_(allow_nat_traversal), |
| 36 event_callback_(NULL), | 37 event_callback_(NULL), |
| 37 client_stub_(NULL), | 38 client_stub_(NULL), |
| 39 clipboard_stub_(NULL), |
| 38 video_stub_(NULL), | 40 video_stub_(NULL), |
| 39 state_(CONNECTING), | 41 state_(CONNECTING), |
| 40 error_(OK) { | 42 error_(OK) { |
| 41 } | 43 } |
| 42 | 44 |
| 43 ConnectionToHost::~ConnectionToHost() { | 45 ConnectionToHost::~ConnectionToHost() { |
| 44 } | 46 } |
| 45 | 47 |
| 46 InputStub* ConnectionToHost::input_stub() { | 48 InputStub* ConnectionToHost::input_stub() { |
| 47 return &event_forwarder_; | 49 return &event_forwarder_; |
| 48 } | 50 } |
| 49 | 51 |
| 50 void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, | 52 void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, |
| 51 const std::string& local_jid, | 53 const std::string& local_jid, |
| 52 const std::string& host_jid, | 54 const std::string& host_jid, |
| 53 const std::string& host_public_key, | 55 const std::string& host_public_key, |
| 54 scoped_ptr<Authenticator> authenticator, | 56 scoped_ptr<Authenticator> authenticator, |
| 55 HostEventCallback* event_callback, | 57 HostEventCallback* event_callback, |
| 56 ClientStub* client_stub, | 58 ClientStub* client_stub, |
| 59 ClipboardStub* clipboard_stub, |
| 57 VideoStub* video_stub) { | 60 VideoStub* video_stub) { |
| 58 event_callback_ = event_callback; | 61 event_callback_ = event_callback; |
| 59 client_stub_ = client_stub; | 62 client_stub_ = client_stub; |
| 63 clipboard_stub_ = clipboard_stub; |
| 60 video_stub_ = video_stub; | 64 video_stub_ = video_stub; |
| 61 authenticator_ = authenticator.Pass(); | 65 authenticator_ = authenticator.Pass(); |
| 62 | 66 |
| 63 // Save jid of the host. The actual connection is created later after | 67 // Save jid of the host. The actual connection is created later after |
| 64 // |signal_strategy_| is connected. | 68 // |signal_strategy_| is connected. |
| 65 host_jid_ = host_jid; | 69 host_jid_ = host_jid; |
| 66 host_public_key_ = host_public_key; | 70 host_public_key_ = host_public_key; |
| 67 | 71 |
| 68 JavascriptSignalStrategy* strategy = new JavascriptSignalStrategy(local_jid); | 72 JavascriptSignalStrategy* strategy = new JavascriptSignalStrategy(local_jid); |
| 69 strategy->AttachXmppProxy(xmpp_proxy); | 73 strategy->AttachXmppProxy(xmpp_proxy); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 case Session::AUTHENTICATED: | 162 case Session::AUTHENTICATED: |
| 159 video_reader_.reset(VideoReader::Create( | 163 video_reader_.reset(VideoReader::Create( |
| 160 message_loop_, session_->config())); | 164 message_loop_, session_->config())); |
| 161 video_reader_->Init(session_.get(), video_stub_, base::Bind( | 165 video_reader_->Init(session_.get(), video_stub_, base::Bind( |
| 162 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); | 166 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
| 163 | 167 |
| 164 control_dispatcher_.reset(new ClientControlDispatcher()); | 168 control_dispatcher_.reset(new ClientControlDispatcher()); |
| 165 control_dispatcher_->Init(session_.get(), base::Bind( | 169 control_dispatcher_->Init(session_.get(), base::Bind( |
| 166 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); | 170 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
| 167 control_dispatcher_->set_client_stub(client_stub_); | 171 control_dispatcher_->set_client_stub(client_stub_); |
| 172 control_dispatcher_->set_clipboard_stub(clipboard_stub_); |
| 168 | 173 |
| 169 event_dispatcher_.reset(new ClientEventDispatcher()); | 174 event_dispatcher_.reset(new ClientEventDispatcher()); |
| 170 event_dispatcher_->Init(session_.get(), base::Bind( | 175 event_dispatcher_->Init(session_.get(), base::Bind( |
| 171 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); | 176 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
| 172 break; | 177 break; |
| 173 | 178 |
| 174 case Session::CLOSED: | 179 case Session::CLOSED: |
| 175 CloseChannels(); | 180 CloseChannels(); |
| 176 SetState(CLOSED, OK); | 181 SetState(CLOSED, OK); |
| 177 break; | 182 break; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 240 |
| 236 if (state != state_) { | 241 if (state != state_) { |
| 237 state_ = state; | 242 state_ = state; |
| 238 error_ = error; | 243 error_ = error; |
| 239 event_callback_->OnConnectionState(state_, error_); | 244 event_callback_->OnConnectionState(state_, error_); |
| 240 } | 245 } |
| 241 } | 246 } |
| 242 | 247 |
| 243 } // namespace protocol | 248 } // namespace protocol |
| 244 } // namespace remoting | 249 } // namespace remoting |
| OLD | NEW |