OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
| 11 #include "remoting/jingle_glue/host_resolver.h" |
11 #include "remoting/jingle_glue/http_port_allocator.h" | 12 #include "remoting/jingle_glue/http_port_allocator.h" |
12 #include "remoting/jingle_glue/javascript_signal_strategy.h" | 13 #include "remoting/jingle_glue/javascript_signal_strategy.h" |
13 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 14 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
14 #include "remoting/protocol/auth_token_utils.h" | 15 #include "remoting/protocol/auth_token_utils.h" |
15 #include "remoting/protocol/client_message_dispatcher.h" | 16 #include "remoting/protocol/client_message_dispatcher.h" |
16 #include "remoting/protocol/client_stub.h" | 17 #include "remoting/protocol/client_stub.h" |
17 #include "remoting/protocol/host_control_sender.h" | 18 #include "remoting/protocol/host_control_sender.h" |
18 #include "remoting/protocol/input_sender.h" | 19 #include "remoting/protocol/input_sender.h" |
19 #include "remoting/protocol/jingle_session_manager.h" | 20 #include "remoting/protocol/jingle_session_manager.h" |
20 #include "remoting/protocol/video_reader.h" | 21 #include "remoting/protocol/video_reader.h" |
21 #include "remoting/protocol/video_stub.h" | 22 #include "remoting/protocol/video_stub.h" |
22 #include "remoting/protocol/util.h" | 23 #include "remoting/protocol/util.h" |
23 | 24 |
24 namespace remoting { | 25 namespace remoting { |
25 namespace protocol { | 26 namespace protocol { |
26 | 27 |
27 ConnectionToHost::ConnectionToHost( | 28 ConnectionToHost::ConnectionToHost( |
28 MessageLoop* message_loop, | 29 MessageLoop* message_loop, |
29 talk_base::NetworkManager* network_manager, | 30 talk_base::NetworkManager* network_manager, |
30 talk_base::PacketSocketFactory* socket_factory, | 31 talk_base::PacketSocketFactory* socket_factory, |
| 32 HostResolverFactory* host_resolver_factory, |
31 PortAllocatorSessionFactory* session_factory, | 33 PortAllocatorSessionFactory* session_factory, |
32 bool allow_nat_traversal) | 34 bool allow_nat_traversal) |
33 : message_loop_(message_loop), | 35 : message_loop_(message_loop), |
34 network_manager_(network_manager), | 36 network_manager_(network_manager), |
35 socket_factory_(socket_factory), | 37 socket_factory_(socket_factory), |
| 38 host_resolver_factory_(host_resolver_factory), |
36 port_allocator_session_factory_(session_factory), | 39 port_allocator_session_factory_(session_factory), |
37 allow_nat_traversal_(allow_nat_traversal), | 40 allow_nat_traversal_(allow_nat_traversal), |
38 state_(STATE_EMPTY), | 41 state_(STATE_EMPTY), |
39 event_callback_(NULL), | 42 event_callback_(NULL), |
40 dispatcher_(new ClientMessageDispatcher()), | 43 dispatcher_(new ClientMessageDispatcher()), |
41 client_stub_(NULL), | 44 client_stub_(NULL), |
42 video_stub_(NULL) { | 45 video_stub_(NULL) { |
43 } | 46 } |
44 | 47 |
45 ConnectionToHost::~ConnectionToHost() { | 48 ConnectionToHost::~ConnectionToHost() { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 shutdown_task.Run(); | 103 shutdown_task.Run(); |
101 } | 104 } |
102 | 105 |
103 void ConnectionToHost::InitSession() { | 106 void ConnectionToHost::InitSession() { |
104 DCHECK_EQ(message_loop_, MessageLoop::current()); | 107 DCHECK_EQ(message_loop_, MessageLoop::current()); |
105 | 108 |
106 // Initialize chromotocol |session_manager_|. | 109 // Initialize chromotocol |session_manager_|. |
107 JingleSessionManager* session_manager = | 110 JingleSessionManager* session_manager = |
108 JingleSessionManager::CreateSandboxed( | 111 JingleSessionManager::CreateSandboxed( |
109 network_manager_.release(), socket_factory_.release(), | 112 network_manager_.release(), socket_factory_.release(), |
| 113 host_resolver_factory_.release(), |
110 port_allocator_session_factory_.release()); | 114 port_allocator_session_factory_.release()); |
111 | 115 |
112 // TODO(ajwong): Make this a command switch when we're more stable. | 116 // TODO(ajwong): Make this a command switch when we're more stable. |
113 session_manager->set_allow_local_ips(true); | 117 session_manager->set_allow_local_ips(true); |
114 | 118 |
115 session_manager_.reset(session_manager); | 119 session_manager_.reset(session_manager); |
116 session_manager_->Init( | 120 session_manager_->Init( |
117 local_jid_, signal_strategy_.get(), this, NULL, "", allow_nat_traversal_); | 121 local_jid_, signal_strategy_.get(), this, NULL, "", allow_nat_traversal_); |
118 } | 122 } |
119 | 123 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // Create and enable the input stub now that we're authenticated. | 219 // Create and enable the input stub now that we're authenticated. |
216 input_sender_.reset(new InputSender(session_->event_channel())); | 220 input_sender_.reset(new InputSender(session_->event_channel())); |
217 } | 221 } |
218 | 222 |
219 ConnectionToHost::State ConnectionToHost::state() const { | 223 ConnectionToHost::State ConnectionToHost::state() const { |
220 return state_; | 224 return state_; |
221 } | 225 } |
222 | 226 |
223 } // namespace protocol | 227 } // namespace protocol |
224 } // namespace remoting | 228 } // namespace remoting |
OLD | NEW |