Chromium Code Reviews| 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 video_stub_(NULL), | 38 video_stub_(NULL), |
|
Wez
2012/05/23 00:01:57
Wot no initializer?
garykac
2012/05/26 01:58:01
Done.
| |
| 39 state_(CONNECTING), | 39 state_(CONNECTING), |
| 40 error_(OK) { | 40 error_(OK) { |
| 41 } | 41 } |
| 42 | 42 |
| 43 ConnectionToHost::~ConnectionToHost() { | 43 ConnectionToHost::~ConnectionToHost() { |
| 44 } | 44 } |
| 45 | 45 |
| 46 ClipboardStub* ConnectionToHost::clipboard_stub() { | 46 ClipboardStub* ConnectionToHost::clipboard_stub() { |
| 47 return &clipboard_forwarder_; | 47 return &clipboard_forwarder_; |
| 48 } | 48 } |
| 49 | 49 |
| 50 HostStub* ConnectionToHost::host_stub() { | 50 HostStub* ConnectionToHost::host_stub() { |
| 51 // TODO(wez): Add a HostFilter class, equivalent to input filter. | 51 // TODO(wez): Add a HostFilter class, equivalent to input filter. |
| 52 return control_dispatcher_.get(); | 52 return control_dispatcher_.get(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 InputStub* ConnectionToHost::input_stub() { | 55 InputStub* ConnectionToHost::input_stub() { |
| 56 return &event_forwarder_; | 56 return &event_forwarder_; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, | 59 void ConnectionToHost::Connect(scoped_refptr<XmppProxy> xmpp_proxy, |
| 60 const std::string& local_jid, | 60 const std::string& local_jid, |
| 61 const std::string& host_jid, | 61 const std::string& host_jid, |
| 62 const std::string& host_public_key, | 62 const std::string& host_public_key, |
| 63 scoped_ptr<TransportFactory> transport_factory, | 63 scoped_ptr<TransportFactory> transport_factory, |
| 64 scoped_ptr<Authenticator> authenticator, | 64 scoped_ptr<Authenticator> authenticator, |
| 65 HostEventCallback* event_callback, | 65 HostEventCallback* event_callback, |
| 66 ClientStub* client_stub, | 66 ClientStub* client_stub, |
| 67 ClipboardStub* clipboard_stub, | 67 ClipboardStub* clipboard_stub, |
| 68 CursorShapeStub* cursor_shape_stub, | |
| 68 VideoStub* video_stub) { | 69 VideoStub* video_stub) { |
| 69 event_callback_ = event_callback; | 70 event_callback_ = event_callback; |
| 70 client_stub_ = client_stub; | 71 client_stub_ = client_stub; |
| 71 clipboard_stub_ = clipboard_stub; | 72 clipboard_stub_ = clipboard_stub; |
| 73 cursor_shape_stub_ = cursor_shape_stub; | |
| 72 video_stub_ = video_stub; | 74 video_stub_ = video_stub; |
| 73 authenticator_ = authenticator.Pass(); | 75 authenticator_ = authenticator.Pass(); |
| 74 | 76 |
| 75 // Save jid of the host. The actual connection is created later after | 77 // Save jid of the host. The actual connection is created later after |
| 76 // |signal_strategy_| is connected. | 78 // |signal_strategy_| is connected. |
| 77 host_jid_ = host_jid; | 79 host_jid_ = host_jid; |
| 78 host_public_key_ = host_public_key; | 80 host_public_key_ = host_public_key; |
| 79 | 81 |
| 80 JavascriptSignalStrategy* strategy = new JavascriptSignalStrategy(local_jid); | 82 JavascriptSignalStrategy* strategy = new JavascriptSignalStrategy(local_jid); |
| 81 strategy->AttachXmppProxy(xmpp_proxy); | 83 strategy->AttachXmppProxy(xmpp_proxy); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 video_reader_.reset(VideoReader::Create( | 171 video_reader_.reset(VideoReader::Create( |
| 170 message_loop_, session_->config())); | 172 message_loop_, session_->config())); |
| 171 video_reader_->Init(session_.get(), video_stub_, base::Bind( | 173 video_reader_->Init(session_.get(), video_stub_, base::Bind( |
| 172 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); | 174 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
| 173 | 175 |
| 174 control_dispatcher_.reset(new ClientControlDispatcher()); | 176 control_dispatcher_.reset(new ClientControlDispatcher()); |
| 175 control_dispatcher_->Init(session_.get(), base::Bind( | 177 control_dispatcher_->Init(session_.get(), base::Bind( |
| 176 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); | 178 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
| 177 control_dispatcher_->set_client_stub(client_stub_); | 179 control_dispatcher_->set_client_stub(client_stub_); |
| 178 control_dispatcher_->set_clipboard_stub(clipboard_stub_); | 180 control_dispatcher_->set_clipboard_stub(clipboard_stub_); |
| 181 control_dispatcher_->set_cursor_shape_stub(cursor_shape_stub_); | |
| 179 | 182 |
| 180 event_dispatcher_.reset(new ClientEventDispatcher()); | 183 event_dispatcher_.reset(new ClientEventDispatcher()); |
| 181 event_dispatcher_->Init(session_.get(), base::Bind( | 184 event_dispatcher_->Init(session_.get(), base::Bind( |
| 182 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); | 185 &ConnectionToHost::OnChannelInitialized, base::Unretained(this))); |
| 183 break; | 186 break; |
| 184 | 187 |
| 185 case Session::CLOSED: | 188 case Session::CLOSED: |
| 186 CloseChannels(); | 189 CloseChannels(); |
| 187 SetState(CLOSED, OK); | 190 SetState(CLOSED, OK); |
| 188 break; | 191 break; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 | 251 |
| 249 if (state != state_) { | 252 if (state != state_) { |
| 250 state_ = state; | 253 state_ = state; |
| 251 error_ = error; | 254 error_ = error; |
| 252 event_callback_->OnConnectionState(state_, error_); | 255 event_callback_->OnConnectionState(state_, error_); |
| 253 } | 256 } |
| 254 } | 257 } |
| 255 | 258 |
| 256 } // namespace protocol | 259 } // namespace protocol |
| 257 } // namespace remoting | 260 } // namespace remoting |
| OLD | NEW |