| 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/jingle_session_manager.h" | 5 #include "remoting/protocol/jingle_session_manager.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/task.h" | 12 #include "base/task.h" |
| 13 #include "remoting/base/constants.h" | 13 #include "remoting/base/constants.h" |
| 14 #include "remoting/jingle_glue/host_address_resolver.h" |
| 14 #include "remoting/jingle_glue/http_port_allocator.h" | 15 #include "remoting/jingle_glue/http_port_allocator.h" |
| 15 #include "remoting/jingle_glue/jingle_info_request.h" | 16 #include "remoting/jingle_glue/jingle_info_request.h" |
| 16 #include "remoting/jingle_glue/jingle_signaling_connector.h" | 17 #include "remoting/jingle_glue/jingle_signaling_connector.h" |
| 17 #include "remoting/jingle_glue/signal_strategy.h" | 18 #include "remoting/jingle_glue/signal_strategy.h" |
| 18 #include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h" | 19 #include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h" |
| 19 #include "third_party/libjingle/source/talk/p2p/base/sessionmanager.h" | 20 #include "third_party/libjingle/source/talk/p2p/base/sessionmanager.h" |
| 20 #include "third_party/libjingle/source/talk/p2p/base/transport.h" | 21 #include "third_party/libjingle/source/talk/p2p/base/transport.h" |
| 21 #include "third_party/libjingle/source/talk/p2p/base/constants.h" | 22 #include "third_party/libjingle/source/talk/p2p/base/constants.h" |
| 22 #include "third_party/libjingle/source/talk/p2p/base/transport.h" | 23 #include "third_party/libjingle/source/talk/p2p/base/transport.h" |
| 23 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 24 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
| 24 | 25 |
| 25 using buzz::XmlElement; | 26 using buzz::XmlElement; |
| 26 | 27 |
| 27 namespace remoting { | 28 namespace remoting { |
| 28 namespace protocol { | 29 namespace protocol { |
| 29 | 30 |
| 30 // static | 31 // static |
| 31 JingleSessionManager* JingleSessionManager::CreateNotSandboxed() { | 32 JingleSessionManager* JingleSessionManager::CreateNotSandboxed() { |
| 32 return new JingleSessionManager(NULL, NULL, NULL); | 33 return new JingleSessionManager(NULL, NULL, NULL, NULL); |
| 33 } | 34 } |
| 34 | 35 |
| 35 // static | 36 // static |
| 36 JingleSessionManager* JingleSessionManager::CreateSandboxed( | 37 JingleSessionManager* JingleSessionManager::CreateSandboxed( |
| 37 talk_base::NetworkManager* network_manager, | 38 talk_base::NetworkManager* network_manager, |
| 38 talk_base::PacketSocketFactory* socket_factory, | 39 talk_base::PacketSocketFactory* socket_factory, |
| 40 HostAddressResolver* host_address_resolver, |
| 39 PortAllocatorSessionFactory* port_allocator_session_factory) { | 41 PortAllocatorSessionFactory* port_allocator_session_factory) { |
| 40 return new JingleSessionManager(network_manager, socket_factory, | 42 return new JingleSessionManager(network_manager, socket_factory, |
| 43 host_address_resolver, |
| 41 port_allocator_session_factory); | 44 port_allocator_session_factory); |
| 42 } | 45 } |
| 43 | 46 |
| 44 JingleSessionManager::JingleSessionManager( | 47 JingleSessionManager::JingleSessionManager( |
| 45 talk_base::NetworkManager* network_manager, | 48 talk_base::NetworkManager* network_manager, |
| 46 talk_base::PacketSocketFactory* socket_factory, | 49 talk_base::PacketSocketFactory* socket_factory, |
| 50 HostAddressResolver* host_address_resolver, |
| 47 PortAllocatorSessionFactory* port_allocator_session_factory) | 51 PortAllocatorSessionFactory* port_allocator_session_factory) |
| 48 : network_manager_(network_manager), | 52 : network_manager_(network_manager), |
| 49 socket_factory_(socket_factory), | 53 socket_factory_(socket_factory), |
| 54 host_address_resolver_(host_address_resolver), |
| 50 port_allocator_session_factory_(port_allocator_session_factory), | 55 port_allocator_session_factory_(port_allocator_session_factory), |
| 51 signal_strategy_(NULL), | 56 signal_strategy_(NULL), |
| 52 allow_nat_traversal_(false), | 57 allow_nat_traversal_(false), |
| 53 allow_local_ips_(false), | 58 allow_local_ips_(false), |
| 54 http_port_allocator_(NULL), | 59 http_port_allocator_(NULL), |
| 55 closed_(false), | 60 closed_(false), |
| 56 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { | 61 ALLOW_THIS_IN_INITIALIZER_LIST(task_factory_(this)) { |
| 57 } | 62 } |
| 58 | 63 |
| 59 JingleSessionManager::~JingleSessionManager() { | 64 JingleSessionManager::~JingleSessionManager() { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 cricket_session_manager_.reset( | 119 cricket_session_manager_.reset( |
| 115 new cricket::SessionManager(port_allocator_.get())); | 120 new cricket::SessionManager(port_allocator_.get())); |
| 116 cricket_session_manager_->AddClient(kChromotingXmlNamespace, this); | 121 cricket_session_manager_->AddClient(kChromotingXmlNamespace, this); |
| 117 | 122 |
| 118 jingle_signaling_connector_.reset(new JingleSignalingConnector( | 123 jingle_signaling_connector_.reset(new JingleSignalingConnector( |
| 119 signal_strategy_, cricket_session_manager_.get())); | 124 signal_strategy_, cricket_session_manager_.get())); |
| 120 | 125 |
| 121 // If NAT traversal is enabled then we need to request STUN/Relay info. | 126 // If NAT traversal is enabled then we need to request STUN/Relay info. |
| 122 if (allow_nat_traversal) { | 127 if (allow_nat_traversal) { |
| 123 jingle_info_request_.reset( | 128 jingle_info_request_.reset( |
| 124 new JingleInfoRequest(signal_strategy_->CreateIqRequest())); | 129 new JingleInfoRequest(signal_strategy_->CreateIqRequest(), |
| 130 host_address_resolver_.get())); |
| 125 jingle_info_request_->Send(base::Bind( | 131 jingle_info_request_->Send(base::Bind( |
| 126 &JingleSessionManager::OnJingleInfo, base::Unretained(this))); | 132 &JingleSessionManager::OnJingleInfo, base::Unretained(this))); |
| 127 } else { | 133 } else { |
| 128 listener_->OnSessionManagerInitialized(); | 134 listener_->OnSessionManagerInitialized(); |
| 129 } | 135 } |
| 130 } | 136 } |
| 131 | 137 |
| 132 void JingleSessionManager::Close() { | 138 void JingleSessionManager::Close() { |
| 133 DCHECK(CalledOnValidThread()); | 139 DCHECK(CalledOnValidThread()); |
| 134 | 140 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 const std::string& certificate) { | 347 const std::string& certificate) { |
| 342 cricket::SessionDescription* desc = new cricket::SessionDescription(); | 348 cricket::SessionDescription* desc = new cricket::SessionDescription(); |
| 343 desc->AddContent( | 349 desc->AddContent( |
| 344 JingleSession::kChromotingContentName, kChromotingXmlNamespace, | 350 JingleSession::kChromotingContentName, kChromotingXmlNamespace, |
| 345 new ContentDescription(config, "", "", certificate)); | 351 new ContentDescription(config, "", "", certificate)); |
| 346 return desc; | 352 return desc; |
| 347 } | 353 } |
| 348 | 354 |
| 349 } // namespace protocol | 355 } // namespace protocol |
| 350 } // namespace remoting | 356 } // namespace remoting |
| OLD | NEW |