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 17 matching lines...) Expand all Loading... |
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 bool allow_nat_traversal) | 32 bool allow_nat_traversal) |
33 : message_loop_(message_loop), | 33 : message_loop_(message_loop), |
34 allow_nat_traversal_(allow_nat_traversal), | 34 allow_nat_traversal_(allow_nat_traversal), |
35 event_callback_(NULL), | 35 event_callback_(NULL), |
36 client_stub_(NULL), | 36 client_stub_(NULL), |
37 clipboard_stub_(NULL), | 37 clipboard_stub_(NULL), |
| 38 cursor_shape_stub_(NULL), |
38 video_stub_(NULL), | 39 video_stub_(NULL), |
39 state_(CONNECTING), | 40 state_(CONNECTING), |
40 error_(OK) { | 41 error_(OK) { |
41 } | 42 } |
42 | 43 |
43 ConnectionToHost::~ConnectionToHost() { | 44 ConnectionToHost::~ConnectionToHost() { |
44 } | 45 } |
45 | 46 |
46 ClipboardStub* ConnectionToHost::clipboard_stub() { | 47 ClipboardStub* ConnectionToHost::clipboard_stub() { |
47 return &clipboard_forwarder_; | 48 return &clipboard_forwarder_; |
(...skipping 10 matching lines...) Expand all Loading... |
58 | 59 |
59 void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, | 60 void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, |
60 const std::string& local_jid, | 61 const std::string& local_jid, |
61 const std::string& host_jid, | 62 const std::string& host_jid, |
62 const std::string& host_public_key, | 63 const std::string& host_public_key, |
63 scoped_ptr<TransportFactory> transport_factory, | 64 scoped_ptr<TransportFactory> transport_factory, |
64 scoped_ptr<Authenticator> authenticator, | 65 scoped_ptr<Authenticator> authenticator, |
65 HostEventCallback* event_callback, | 66 HostEventCallback* event_callback, |
66 ClientStub* client_stub, | 67 ClientStub* client_stub, |
67 ClipboardStub* clipboard_stub, | 68 ClipboardStub* clipboard_stub, |
| 69 CursorShapeStub* cursor_shape_stub, |
68 VideoStub* video_stub) { | 70 VideoStub* video_stub) { |
69 event_callback_ = event_callback; | 71 event_callback_ = event_callback; |
70 client_stub_ = client_stub; | 72 client_stub_ = client_stub; |
71 clipboard_stub_ = clipboard_stub; | 73 clipboard_stub_ = clipboard_stub; |
| 74 cursor_shape_stub_ = cursor_shape_stub; |
72 video_stub_ = video_stub; | 75 video_stub_ = video_stub; |
73 authenticator_ = authenticator.Pass(); | 76 authenticator_ = authenticator.Pass(); |
74 | 77 |
75 // Save jid of the host. The actual connection is created later after | 78 // Save jid of the host. The actual connection is created later after |
76 // |signal_strategy_| is connected. | 79 // |signal_strategy_| is connected. |
77 host_jid_ = host_jid; | 80 host_jid_ = host_jid; |
78 host_public_key_ = host_public_key; | 81 host_public_key_ = host_public_key; |
79 | 82 |
80 JavascriptSignalStrategy* strategy = new JavascriptSignalStrategy(local_jid); | 83 JavascriptSignalStrategy* strategy = new JavascriptSignalStrategy(local_jid); |
81 strategy->AttachXmppProxy(xmpp_proxy); | 84 strategy->AttachXmppProxy(xmpp_proxy); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 video_reader_.reset(VideoReader::Create( | 172 video_reader_.reset(VideoReader::Create( |
170 message_loop_, session_->config())); | 173 message_loop_, session_->config())); |
171 video_reader_->Init(session_.get(), video_stub_, base::Bind( | 174 video_reader_->Init(session_.get(), video_stub_, base::Bind( |
172 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); | 175 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
173 | 176 |
174 control_dispatcher_.reset(new ClientControlDispatcher()); | 177 control_dispatcher_.reset(new ClientControlDispatcher()); |
175 control_dispatcher_->Init(session_.get(), base::Bind( | 178 control_dispatcher_->Init(session_.get(), base::Bind( |
176 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); | 179 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
177 control_dispatcher_->set_client_stub(client_stub_); | 180 control_dispatcher_->set_client_stub(client_stub_); |
178 control_dispatcher_->set_clipboard_stub(clipboard_stub_); | 181 control_dispatcher_->set_clipboard_stub(clipboard_stub_); |
| 182 control_dispatcher_->set_cursor_shape_stub(cursor_shape_stub_); |
179 | 183 |
180 event_dispatcher_.reset(new ClientEventDispatcher()); | 184 event_dispatcher_.reset(new ClientEventDispatcher()); |
181 event_dispatcher_->Init(session_.get(), base::Bind( | 185 event_dispatcher_->Init(session_.get(), base::Bind( |
182 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); | 186 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
183 break; | 187 break; |
184 | 188 |
185 case Session::CLOSED: | 189 case Session::CLOSED: |
186 CloseChannels(); | 190 CloseChannels(); |
187 SetState(CLOSED, OK); | 191 SetState(CLOSED, OK); |
188 break; | 192 break; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 252 |
249 if (state != state_) { | 253 if (state != state_) { |
250 state_ = state; | 254 state_ = state; |
251 error_ = error; | 255 error_ = error; |
252 event_callback_->OnConnectionState(state_, error_); | 256 event_callback_->OnConnectionState(state_, error_); |
253 } | 257 } |
254 } | 258 } |
255 | 259 |
256 } // namespace protocol | 260 } // namespace protocol |
257 } // namespace remoting | 261 } // namespace remoting |
OLD | NEW |