| 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" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "remoting/protocol/pepper_transport_factory.h" | 22 #include "remoting/protocol/pepper_transport_factory.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 #include "remoting/protocol/util.h" | 25 #include "remoting/protocol/util.h" |
| 26 | 26 |
| 27 namespace remoting { | 27 namespace remoting { |
| 28 namespace protocol { | 28 namespace protocol { |
| 29 | 29 |
| 30 ConnectionToHost::ConnectionToHost( | 30 ConnectionToHost::ConnectionToHost( |
| 31 base::MessageLoopProxy* message_loop, | 31 base::MessageLoopProxy* message_loop, |
| 32 pp::Instance* pp_instance, | |
| 33 bool allow_nat_traversal) | 32 bool allow_nat_traversal) |
| 34 : message_loop_(message_loop), | 33 : message_loop_(message_loop), |
| 35 pp_instance_(pp_instance), | |
| 36 allow_nat_traversal_(allow_nat_traversal), | 34 allow_nat_traversal_(allow_nat_traversal), |
| 37 event_callback_(NULL), | 35 event_callback_(NULL), |
| 38 client_stub_(NULL), | 36 client_stub_(NULL), |
| 39 clipboard_stub_(NULL), | 37 clipboard_stub_(NULL), |
| 40 video_stub_(NULL), | 38 video_stub_(NULL), |
| 41 state_(CONNECTING), | 39 state_(CONNECTING), |
| 42 error_(OK) { | 40 error_(OK) { |
| 43 } | 41 } |
| 44 | 42 |
| 45 ConnectionToHost::~ConnectionToHost() { | 43 ConnectionToHost::~ConnectionToHost() { |
| 46 } | 44 } |
| 47 | 45 |
| 48 ClipboardStub* ConnectionToHost::clipboard_stub() { | 46 ClipboardStub* ConnectionToHost::clipboard_stub() { |
| 49 return &clipboard_forwarder_; | 47 return &clipboard_forwarder_; |
| 50 } | 48 } |
| 51 | 49 |
| 52 HostStub* ConnectionToHost::host_stub() { | 50 HostStub* ConnectionToHost::host_stub() { |
| 53 // TODO(wez): Add a HostFilter class, equivalent to input filter. | 51 // TODO(wez): Add a HostFilter class, equivalent to input filter. |
| 54 return control_dispatcher_.get(); | 52 return control_dispatcher_.get(); |
| 55 } | 53 } |
| 56 | 54 |
| 57 InputStub* ConnectionToHost::input_stub() { | 55 InputStub* ConnectionToHost::input_stub() { |
| 58 return &event_forwarder_; | 56 return &event_forwarder_; |
| 59 } | 57 } |
| 60 | 58 |
| 61 void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, | 59 void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, |
| 62 const std::string& local_jid, | 60 const std::string& local_jid, |
| 63 const std::string& host_jid, | 61 const std::string& host_jid, |
| 64 const std::string& host_public_key, | 62 const std::string& host_public_key, |
| 63 scoped_ptr<TransportFactory> transport_factory, |
| 65 scoped_ptr<Authenticator> authenticator, | 64 scoped_ptr<Authenticator> authenticator, |
| 66 HostEventCallback* event_callback, | 65 HostEventCallback* event_callback, |
| 67 ClientStub* client_stub, | 66 ClientStub* client_stub, |
| 68 ClipboardStub* clipboard_stub, | 67 ClipboardStub* clipboard_stub, |
| 69 VideoStub* video_stub) { | 68 VideoStub* video_stub) { |
| 70 event_callback_ = event_callback; | 69 event_callback_ = event_callback; |
| 71 client_stub_ = client_stub; | 70 client_stub_ = client_stub; |
| 72 clipboard_stub_ = clipboard_stub; | 71 clipboard_stub_ = clipboard_stub; |
| 73 video_stub_ = video_stub; | 72 video_stub_ = video_stub; |
| 74 authenticator_ = authenticator.Pass(); | 73 authenticator_ = authenticator.Pass(); |
| 75 | 74 |
| 76 // Save jid of the host. The actual connection is created later after | 75 // Save jid of the host. The actual connection is created later after |
| 77 // |signal_strategy_| is connected. | 76 // |signal_strategy_| is connected. |
| 78 host_jid_ = host_jid; | 77 host_jid_ = host_jid; |
| 79 host_public_key_ = host_public_key; | 78 host_public_key_ = host_public_key; |
| 80 | 79 |
| 81 JavascriptSignalStrategy* strategy = new JavascriptSignalStrategy(local_jid); | 80 JavascriptSignalStrategy* strategy = new JavascriptSignalStrategy(local_jid); |
| 82 strategy->AttachXmppProxy(xmpp_proxy); | 81 strategy->AttachXmppProxy(xmpp_proxy); |
| 83 signal_strategy_.reset(strategy); | 82 signal_strategy_.reset(strategy); |
| 84 signal_strategy_->AddListener(this); | 83 signal_strategy_->AddListener(this); |
| 85 signal_strategy_->Connect(); | 84 signal_strategy_->Connect(); |
| 86 | 85 |
| 87 scoped_ptr<TransportFactory> transport_factory( | |
| 88 new PepperTransportFactory(pp_instance_)); | |
| 89 session_manager_.reset(new JingleSessionManager( | 86 session_manager_.reset(new JingleSessionManager( |
| 90 transport_factory.Pass(), true)); | 87 transport_factory.Pass(), allow_nat_traversal_)); |
| 91 session_manager_->Init(signal_strategy_.get(), this); | 88 session_manager_->Init(signal_strategy_.get(), this); |
| 92 } | 89 } |
| 93 | 90 |
| 94 void ConnectionToHost::Disconnect(const base::Closure& shutdown_task) { | 91 void ConnectionToHost::Disconnect(const base::Closure& shutdown_task) { |
| 95 if (!message_loop_->BelongsToCurrentThread()) { | 92 if (!message_loop_->BelongsToCurrentThread()) { |
| 96 message_loop_->PostTask( | 93 message_loop_->PostTask( |
| 97 FROM_HERE, base::Bind(&ConnectionToHost::Disconnect, | 94 FROM_HERE, base::Bind(&ConnectionToHost::Disconnect, |
| 98 base::Unretained(this), shutdown_task)); | 95 base::Unretained(this), shutdown_task)); |
| 99 return; | 96 return; |
| 100 } | 97 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 248 |
| 252 if (state != state_) { | 249 if (state != state_) { |
| 253 state_ = state; | 250 state_ = state; |
| 254 error_ = error; | 251 error_ = error; |
| 255 event_callback_->OnConnectionState(state_, error_); | 252 event_callback_->OnConnectionState(state_, error_); |
| 256 } | 253 } |
| 257 } | 254 } |
| 258 | 255 |
| 259 } // namespace protocol | 256 } // namespace protocol |
| 260 } // namespace remoting | 257 } // namespace remoting |
| OLD | NEW |