Chromium Code Reviews| 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_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "remoting/protocol/video_reader.h" | 22 #include "remoting/protocol/video_reader.h" |
| 23 #include "remoting/protocol/video_stub.h" | 23 #include "remoting/protocol/video_stub.h" |
| 24 #include "remoting/protocol/util.h" | 24 #include "remoting/protocol/util.h" |
| 25 | 25 |
| 26 namespace remoting { | 26 namespace remoting { |
| 27 namespace protocol { | 27 namespace protocol { |
| 28 | 28 |
| 29 ConnectionToHost::ConnectionToHost( | 29 ConnectionToHost::ConnectionToHost( |
| 30 base::MessageLoopProxy* message_loop, | 30 base::MessageLoopProxy* message_loop, |
| 31 pp::Instance* pp_instance, | 31 pp::Instance* pp_instance, |
| 32 talk_base::NetworkManager* network_manager, | |
| 33 talk_base::PacketSocketFactory* socket_factory, | |
| 34 HostResolverFactory* host_resolver_factory, | |
| 35 PortAllocatorSessionFactory* session_factory, | |
| 36 bool allow_nat_traversal) | 32 bool allow_nat_traversal) |
| 37 : message_loop_(message_loop), | 33 : message_loop_(message_loop), |
| 38 pp_instance_(pp_instance), | 34 pp_instance_(pp_instance), |
| 39 network_manager_(network_manager), | |
| 40 socket_factory_(socket_factory), | |
| 41 host_resolver_factory_(host_resolver_factory), | |
| 42 port_allocator_session_factory_(session_factory), | |
| 43 allow_nat_traversal_(allow_nat_traversal), | 35 allow_nat_traversal_(allow_nat_traversal), |
| 44 event_callback_(NULL), | 36 event_callback_(NULL), |
| 45 client_stub_(NULL), | 37 client_stub_(NULL), |
| 46 video_stub_(NULL), | 38 video_stub_(NULL), |
| 47 state_(STATE_EMPTY), | 39 state_(STATE_EMPTY), |
| 48 control_connected_(false), | 40 control_connected_(false), |
| 49 input_connected_(false), | 41 input_connected_(false), |
| 50 video_connected_(false) { | 42 video_connected_(false) { |
| 51 } | 43 } |
| 52 | 44 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 | 96 |
| 105 if (signal_strategy_.get()) | 97 if (signal_strategy_.get()) |
| 106 signal_strategy_.reset(); | 98 signal_strategy_.reset(); |
| 107 | 99 |
| 108 shutdown_task.Run(); | 100 shutdown_task.Run(); |
| 109 } | 101 } |
| 110 | 102 |
| 111 void ConnectionToHost::InitSession() { | 103 void ConnectionToHost::InitSession() { |
| 112 DCHECK(message_loop_->BelongsToCurrentThread()); | 104 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 113 | 105 |
| 114 // Initialize |session_manager_|. | 106 // Initialize |session_manager_|. |
|
Wez
2011/09/22 13:49:45
nit: This code is now so beautifully simple that t
Sergey Ulanov
2011/09/22 18:12:00
Done.
| |
| 115 if (pp_instance_) { | 107 session_manager_.reset(new PepperSessionManager(pp_instance_)); |
| 116 session_manager_.reset(new PepperSessionManager(pp_instance_)); | |
| 117 } else { | |
| 118 JingleSessionManager* session_manager = | |
| 119 JingleSessionManager::CreateSandboxed( | |
| 120 message_loop_, network_manager_.release(), | |
| 121 socket_factory_.release(), host_resolver_factory_.release(), | |
| 122 port_allocator_session_factory_.release()); | |
| 123 | |
| 124 // TODO(ajwong): Make this a command switch when we're more stable. | |
| 125 session_manager->set_allow_local_ips(true); | |
| 126 | |
| 127 session_manager_.reset(session_manager); | |
| 128 } | |
| 129 | 108 |
| 130 session_manager_->Init( | 109 session_manager_->Init( |
| 131 local_jid_, signal_strategy_.get(), this, NULL, "", allow_nat_traversal_); | 110 local_jid_, signal_strategy_.get(), this, NULL, "", allow_nat_traversal_); |
| 132 } | 111 } |
| 133 | 112 |
| 134 const SessionConfig& ConnectionToHost::config() { | 113 const SessionConfig& ConnectionToHost::config() { |
| 135 return session_->config(); | 114 return session_->config(); |
| 136 } | 115 } |
| 137 | 116 |
| 138 void ConnectionToHost::OnStateChange( | 117 void ConnectionToHost::OnStateChange( |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 input_sender_.reset( | 242 input_sender_.reset( |
| 264 new InputSender(message_loop_, session_->event_channel())); | 243 new InputSender(message_loop_, session_->event_channel())); |
| 265 } | 244 } |
| 266 | 245 |
| 267 ConnectionToHost::State ConnectionToHost::state() const { | 246 ConnectionToHost::State ConnectionToHost::state() const { |
| 268 return state_; | 247 return state_; |
| 269 } | 248 } |
| 270 | 249 |
| 271 } // namespace protocol | 250 } // namespace protocol |
| 272 } // namespace remoting | 251 } // namespace remoting |
| OLD | NEW |