From 3623ef76ca3a58a41be3c8e2d76f3ac1e4b9a1b5 Mon Sep 17 00:00:00 2001 From: "sergeyu@chromium.org" Date: Fri, 23 Sep 2011 19:11:34 +0000 Subject: Remove old sandboxing-related code. 1. Remove sandboxing code from JingleSessionManager 2. Remove custom port allocator used by chromoting. 3. Remove code for STUN server address resolution from JingleInfoRequest and HostResolver interface. BUG=None TEST=compiles. Review URL: http://codereview.chromium.org/7969019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102545 0039d316-1c4b-4281-b951-d872f2087c98 --- remoting/jingle_glue/host_resolver.cc | 13 ------ remoting/jingle_glue/host_resolver.h | 45 --------------------- remoting/jingle_glue/http_port_allocator.cc | 38 ------------------ remoting/jingle_glue/http_port_allocator.h | 61 ----------------------------- remoting/jingle_glue/jingle_info_request.cc | 44 +++++---------------- remoting/jingle_glue/jingle_info_request.h | 14 +------ 6 files changed, 10 insertions(+), 205 deletions(-) delete mode 100644 remoting/jingle_glue/host_resolver.cc delete mode 100644 remoting/jingle_glue/host_resolver.h delete mode 100644 remoting/jingle_glue/http_port_allocator.cc delete mode 100644 remoting/jingle_glue/http_port_allocator.h (limited to 'remoting/jingle_glue') diff --git a/remoting/jingle_glue/host_resolver.cc b/remoting/jingle_glue/host_resolver.cc deleted file mode 100644 index 5ad3316..0000000 --- a/remoting/jingle_glue/host_resolver.cc +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "remoting/jingle_glue/host_resolver.h" - -namespace remoting { - -HostResolver::HostResolver() { } - -HostResolver::~HostResolver() { } - -} // namespace remoting diff --git a/remoting/jingle_glue/host_resolver.h b/remoting/jingle_glue/host_resolver.h deleted file mode 100644 index d74ae2b..0000000 --- a/remoting/jingle_glue/host_resolver.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef REMOTING_JINGLE_GLUE_HOST_RESOLVER_H_ -#define REMOTING_JINGLE_GLUE_HOST_RESOLVER_H_ - -#include - -#include "base/basictypes.h" -#include "third_party/libjingle/source/talk/base/sigslot.h" -#include "third_party/libjingle/source/talk/base/socketaddress.h" - -namespace remoting { - -// TODO(sergeyu): Move HostResolver and HostResolverFactory to -// libjingle and use them in StunPort. - -class HostResolver { - public: - HostResolver(); - virtual ~HostResolver(); - - virtual void Resolve(const talk_base::SocketAddress& address) = 0; - - sigslot::signal2 SignalDone; - - private: - DISALLOW_COPY_AND_ASSIGN(HostResolver); -}; - -class HostResolverFactory { - public: - HostResolverFactory() { } - virtual ~HostResolverFactory() { } - - virtual HostResolver* CreateHostResolver() = 0; - - private: - DISALLOW_COPY_AND_ASSIGN(HostResolverFactory); -}; - -} // namespace remoting - -#endif // REMOTING_JINGLE_GLUE_HOST_RESOLVER_H_ diff --git a/remoting/jingle_glue/http_port_allocator.cc b/remoting/jingle_glue/http_port_allocator.cc deleted file mode 100644 index 06639da..0000000 --- a/remoting/jingle_glue/http_port_allocator.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "remoting/jingle_glue/http_port_allocator.h" - -namespace remoting { - -PortAllocatorSessionFactory::~PortAllocatorSessionFactory() { -} - -HttpPortAllocator::HttpPortAllocator( - talk_base::NetworkManager* network_manager, - talk_base::PacketSocketFactory* socket_factory, - PortAllocatorSessionFactory* session_factory, - const std::string &user_agent) - : cricket::HttpPortAllocator(network_manager, - socket_factory, - user_agent), - session_factory_(session_factory) { -} - -HttpPortAllocator::~HttpPortAllocator() { -} - -cricket::PortAllocatorSession *HttpPortAllocator::CreateSession( - const std::string& name, const std::string& session_type) { - if (session_factory_) { - return session_factory_->CreateSession( - this, name, session_type, stun_hosts(), relay_hosts(), relay_token(), - user_agent()); - } - return new cricket::HttpPortAllocatorSession( - this, name, session_type, stun_hosts(), relay_hosts(), relay_token(), - user_agent()); -} - -} // namespace remoting diff --git a/remoting/jingle_glue/http_port_allocator.h b/remoting/jingle_glue/http_port_allocator.h deleted file mode 100644 index 07aa830..0000000 --- a/remoting/jingle_glue/http_port_allocator.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This file overrides HttpPortAllocator defined in -// third_party/libjingle/talk/p2p/client/httpportallocator.h to inject a -// custom HTTP client. - -#ifndef REMOTING_JINGLE_GLUE_HTTP_PORT_ALLOCATOR_H_ -#define REMOTING_JINGLE_GLUE_HTTP_PORT_ALLOCATOR_H_ - -#include -#include - -#include "base/memory/scoped_ptr.h" -#include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h" - -namespace remoting { - -// A factory class to generate cricket::PortAllocatorSession. -class PortAllocatorSessionFactory { - public: - PortAllocatorSessionFactory() { - } - - virtual ~PortAllocatorSessionFactory(); - - virtual cricket::PortAllocatorSession* CreateSession( - cricket::BasicPortAllocator* allocator, - const std::string& name, - const std::string& session_type, - const std::vector& stun_hosts, - const std::vector& relay_hosts, - const std::string& relay, - const std::string& agent) = 0; - - private: - DISALLOW_COPY_AND_ASSIGN(PortAllocatorSessionFactory); -}; - -class HttpPortAllocator : public cricket::HttpPortAllocator { - public: - HttpPortAllocator(talk_base::NetworkManager* network_manager, - talk_base::PacketSocketFactory* socket_factory, - PortAllocatorSessionFactory* session_factory, - const std::string& user_agent); - virtual ~HttpPortAllocator(); - - // Override CreateSession() to inject a custom HTTP session. - virtual cricket::PortAllocatorSession* CreateSession( - const std::string& name, const std::string& session_type); - - private: - PortAllocatorSessionFactory* session_factory_; - - DISALLOW_COPY_AND_ASSIGN(HttpPortAllocator); -}; - -} // namespace remoting - -#endif // REMOTING_JINGLE_GLUE_HTTP_PORT_ALLOCATOR_H_ diff --git a/remoting/jingle_glue/jingle_info_request.cc b/remoting/jingle_glue/jingle_info_request.cc index 9a5d16d..148a65f 100644 --- a/remoting/jingle_glue/jingle_info_request.cc +++ b/remoting/jingle_glue/jingle_info_request.cc @@ -10,7 +10,6 @@ #include "base/stl_util.h" #include "base/string_number_conversions.h" #include "net/base/net_util.h" -#include "remoting/jingle_glue/host_resolver.h" #include "remoting/jingle_glue/iq_request.h" #include "third_party/libjingle/source/talk/base/socketaddress.h" #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" @@ -19,17 +18,13 @@ namespace remoting { -JingleInfoRequest::JingleInfoRequest(IqRequest* request, - HostResolverFactory* host_resolver_factory) - : host_resolver_factory_(host_resolver_factory), - request_(request) { +JingleInfoRequest::JingleInfoRequest(IqRequest* request) + : request_(request) { request_->set_callback(base::Bind(&JingleInfoRequest::OnResponse, base::Unretained(this))); } JingleInfoRequest::~JingleInfoRequest() { - STLDeleteContainerPointers(stun_dns_requests_.begin(), - stun_dns_requests_.end()); } void JingleInfoRequest::Send(const OnJingleInfoCallback& callback) { @@ -48,6 +43,7 @@ void JingleInfoRequest::OnResponse(const buzz::XmlElement* stanza) { return; } + std::vector stun_hosts; const buzz::XmlElement* stun = query->FirstNamed(buzz::QN_JINGLE_INFO_STUN); if (stun) { for (const buzz::XmlElement* server = @@ -63,49 +59,27 @@ void JingleInfoRequest::OnResponse(const buzz::XmlElement* stanza) { continue; } - if (host_resolver_factory_) { - net::IPAddressNumber ip_number; - HostResolver* resolver = host_resolver_factory_->CreateHostResolver(); - stun_dns_requests_.insert(resolver); - resolver->SignalDone.connect( - this, &JingleInfoRequest::OnStunAddressResponse); - resolver->Resolve(talk_base::SocketAddress(host, port)); - } else { - // If there is no |host_resolver_factory_|, we're not sandboxed, so - // we can let libjingle itself do the DNS resolution. - stun_hosts_.push_back(talk_base::SocketAddress(host, port)); - } + stun_hosts.push_back(talk_base::SocketAddress(host, port)); } } } + std::vector relay_hosts; + std::string relay_token; const buzz::XmlElement* relay = query->FirstNamed(buzz::QN_JINGLE_INFO_RELAY); if (relay) { - relay_token_ = relay->TextNamed(buzz::QN_JINGLE_INFO_TOKEN); + relay_token = relay->TextNamed(buzz::QN_JINGLE_INFO_TOKEN); for (const buzz::XmlElement* server = relay->FirstNamed(buzz::QN_JINGLE_INFO_SERVER); server != NULL; server = server->NextNamed(buzz::QN_JINGLE_INFO_SERVER)) { std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST); if (host != buzz::STR_EMPTY) - relay_hosts_.push_back(host); + relay_hosts.push_back(host); } } - if (stun_dns_requests_.empty()) - on_jingle_info_cb_.Run(relay_token_, relay_hosts_, stun_hosts_); -} - -void JingleInfoRequest::OnStunAddressResponse( - HostResolver* resolver, const talk_base::SocketAddress& address) { - if (!address.IsNil()) - stun_hosts_.push_back(address); - - MessageLoop::current()->DeleteSoon(FROM_HERE, resolver); - stun_dns_requests_.erase(resolver); - - if (stun_dns_requests_.empty()) - on_jingle_info_cb_.Run(relay_token_, relay_hosts_, stun_hosts_); + on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); } } // namespace remoting diff --git a/remoting/jingle_glue/jingle_info_request.h b/remoting/jingle_glue/jingle_info_request.h index df7552f..6d5bcf6 100644 --- a/remoting/jingle_glue/jingle_info_request.h +++ b/remoting/jingle_glue/jingle_info_request.h @@ -27,8 +27,6 @@ class SocketAddress; namespace remoting { class IqRequest; -class HostResolver; -class HostResolverFactory; // JingleInfoRequest handles requesting STUN/Relay infromation from // the Google Talk network. The query is made when Send() is @@ -49,8 +47,7 @@ class JingleInfoRequest : public sigslot::has_slots<> { const std::string&, const std::vector&, const std::vector&)> OnJingleInfoCallback; - explicit JingleInfoRequest(IqRequest* request, - HostResolverFactory* host_resolver_factory); + explicit JingleInfoRequest(IqRequest* request); virtual ~JingleInfoRequest(); void Send(const OnJingleInfoCallback& callback); @@ -59,19 +56,10 @@ class JingleInfoRequest : public sigslot::has_slots<> { struct PendingDnsRequest; void OnResponse(const buzz::XmlElement* stanza); - void OnStunAddressResponse(HostResolver* resolver, - const talk_base::SocketAddress& address); - HostResolverFactory* host_resolver_factory_; scoped_ptr request_; OnJingleInfoCallback on_jingle_info_cb_; - std::vector relay_hosts_; - std::vector stun_hosts_; - std::string relay_token_; - - std::set stun_dns_requests_; - DISALLOW_COPY_AND_ASSIGN(JingleInfoRequest); }; -- cgit v1.1