mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 893cf3614356 (bug 837919) for crashtest & mochitest orange.
This commit is contained in:
parent
f179a230e3
commit
496b8525d5
@ -95,7 +95,6 @@ nrappkit copyright:
|
||||
#include "prio.h"
|
||||
#include "prnetdb.h"
|
||||
|
||||
#include "mozilla/net/DNS.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsASocketHandler.h"
|
||||
#include "nsISocketTransportService.h"
|
||||
@ -111,6 +110,7 @@ extern "C" {
|
||||
#include "nr_socket.h"
|
||||
#include "nr_socket_local.h"
|
||||
}
|
||||
|
||||
#include "nr_socket_prsock.h"
|
||||
|
||||
// Implement the nsISupports ref counting
|
||||
@ -240,30 +240,6 @@ static int nr_transport_addr_to_praddr(nr_transport_addr *addr,
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int nr_netaddr_to_transport_addr(const net::NetAddr *netaddr,
|
||||
nr_transport_addr *addr)
|
||||
{
|
||||
int _status;
|
||||
int r;
|
||||
|
||||
switch(netaddr->raw.family) {
|
||||
case AF_INET:
|
||||
if ((r = nr_ip4_port_to_transport_addr(ntohl(netaddr->inet.ip),
|
||||
ntohs(netaddr->inet.port),
|
||||
IPPROTO_UDP, addr)))
|
||||
ABORT(r);
|
||||
break;
|
||||
case AF_INET6:
|
||||
ABORT(R_BAD_ARGS);
|
||||
default:
|
||||
MOZ_ASSERT(false);
|
||||
ABORT(R_BAD_ARGS);
|
||||
}
|
||||
_status=0;
|
||||
abort:
|
||||
return(_status);
|
||||
}
|
||||
|
||||
int nr_praddr_to_transport_addr(const PRNetAddr *praddr,
|
||||
nr_transport_addr *addr, int keep)
|
||||
{
|
||||
@ -277,9 +253,9 @@ int nr_praddr_to_transport_addr(const PRNetAddr *praddr,
|
||||
ip4.sin_addr.s_addr = praddr->inet.ip;
|
||||
ip4.sin_port = praddr->inet.port;
|
||||
if ((r = nr_sockaddr_to_transport_addr((sockaddr *)&ip4,
|
||||
sizeof(ip4),
|
||||
IPPROTO_UDP, keep,
|
||||
addr)))
|
||||
sizeof(ip4),
|
||||
IPPROTO_UDP, 1,
|
||||
addr)))
|
||||
ABORT(r);
|
||||
break;
|
||||
case PR_AF_INET6:
|
||||
@ -290,7 +266,6 @@ int nr_praddr_to_transport_addr(const PRNetAddr *praddr,
|
||||
#endif
|
||||
ABORT(R_BAD_ARGS);
|
||||
default:
|
||||
MOZ_ASSERT(false);
|
||||
ABORT(R_BAD_ARGS);
|
||||
}
|
||||
|
||||
|
@ -61,10 +61,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace net {
|
||||
union NetAddr;
|
||||
}
|
||||
|
||||
class NrSocket : public nsASocketHandler {
|
||||
public:
|
||||
NrSocket() : fd_(nullptr) {
|
||||
@ -114,9 +110,8 @@ private:
|
||||
nsCOMPtr<nsIEventTarget> ststhread_;
|
||||
};
|
||||
|
||||
int nr_netaddr_to_transport_addr(const net::NetAddr *netaddr,
|
||||
nr_transport_addr *addr);
|
||||
int nr_praddr_to_transport_addr(const PRNetAddr *praddr,
|
||||
nr_transport_addr *addr, int keep);
|
||||
|
||||
} // close namespace
|
||||
#endif
|
||||
|
@ -1,218 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
// Original authors: jib@mozilla.com, ekr@rtfm.com
|
||||
|
||||
// Some of this code is cut-and-pasted from nICEr. Copyright is:
|
||||
|
||||
/*
|
||||
Copyright (c) 2007, Adobe Systems, Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems, Network Resonance nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "nspr.h"
|
||||
#include "prnetdb.h"
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
|
||||
extern "C" {
|
||||
#include "nr_api.h"
|
||||
#include "async_timer.h"
|
||||
#include "nr_resolver.h"
|
||||
#include "transport_addr.h"
|
||||
}
|
||||
|
||||
#include "mozilla/net/DNS.h" // TODO(jib@mozilla.com) down here because bug 848578
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIDNSService.h"
|
||||
#include "nsIDNSListener.h"
|
||||
#include "nsIDNSRecord.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nriceresolver.h"
|
||||
#include "nr_socket_prsock.h"
|
||||
#include "mtransport/runnable_utils.h"
|
||||
|
||||
// Local includes
|
||||
#include "logging.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
MOZ_MTLOG_MODULE("mtransport")
|
||||
|
||||
NrIceResolver::NrIceResolver() :
|
||||
vtbl_(new nr_resolver_vtbl())
|
||||
#ifdef DEBUG
|
||||
, allocated_resolvers_(0)
|
||||
#endif
|
||||
{
|
||||
vtbl_->destroy = &NrIceResolver::destroy;
|
||||
vtbl_->resolve = &NrIceResolver::resolve;
|
||||
vtbl_->cancel = &NrIceResolver::cancel;
|
||||
}
|
||||
|
||||
NrIceResolver::~NrIceResolver() {
|
||||
MOZ_ASSERT(!allocated_resolvers_);
|
||||
delete vtbl_;
|
||||
}
|
||||
|
||||
nsresult NrIceResolver::Init() {
|
||||
nsresult rv;
|
||||
|
||||
sts_thread_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
dns_ = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
MOZ_MTLOG(PR_LOG_ERROR, "Could not acquire DNS service");
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nr_resolver *NrIceResolver::AllocateResolver() {
|
||||
nr_resolver *resolver;
|
||||
|
||||
int r = nr_resolver_create_int((void *)this, vtbl_, &resolver);
|
||||
MOZ_ASSERT(!r);
|
||||
if(r) {
|
||||
MOZ_MTLOG(PR_LOG_ERROR, "nr_resolver_create_int failed");
|
||||
return nullptr;
|
||||
}
|
||||
// We must be available to allocators until they all call DestroyResolver,
|
||||
// because allocators may (and do) outlive the originator of NrIceResolver.
|
||||
AddRef();
|
||||
#ifdef DEBUG
|
||||
++allocated_resolvers_;
|
||||
#endif
|
||||
return resolver;
|
||||
}
|
||||
|
||||
void NrIceResolver::DestroyResolver() {
|
||||
#ifdef DEBUG
|
||||
--allocated_resolvers_;
|
||||
#endif
|
||||
// Undoes Addref in AllocateResolver so the NrIceResolver can be freed.
|
||||
Release();
|
||||
}
|
||||
|
||||
int NrIceResolver::destroy(void **objp) {
|
||||
if (!objp || !*objp)
|
||||
return 0;
|
||||
NrIceResolver *resolver = static_cast<NrIceResolver *>(*objp);
|
||||
*objp = 0;
|
||||
resolver->DestroyResolver();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NrIceResolver::resolve(void *obj,
|
||||
nr_resolver_resource *resource,
|
||||
int (*cb)(void *cb_arg, nr_transport_addr *addr),
|
||||
void *cb_arg,
|
||||
void **handle) {
|
||||
MOZ_ASSERT(obj);
|
||||
return static_cast<NrIceResolver *>(obj)->resolve(resource, cb, cb_arg, handle);
|
||||
}
|
||||
|
||||
int NrIceResolver::resolve(nr_resolver_resource *resource,
|
||||
int (*cb)(void *cb_arg, nr_transport_addr *addr),
|
||||
void *cb_arg,
|
||||
void **handle) {
|
||||
int _status;
|
||||
MOZ_ASSERT(allocated_resolvers_ > 0);
|
||||
ASSERT_ON_THREAD(sts_thread_);
|
||||
nsCOMPtr<PendingResolution> pr;
|
||||
|
||||
if (resource->transport_protocol != IPPROTO_UDP) {
|
||||
MOZ_MTLOG(PR_LOG_ERROR, "Only UDP is supported.");
|
||||
ABORT(R_NOT_FOUND);
|
||||
}
|
||||
pr = new PendingResolution(this, resource->port? resource->port : 3478,
|
||||
cb, cb_arg);
|
||||
if (NS_FAILED(dns_->AsyncResolve(nsAutoCString(resource->domain_name),
|
||||
nsIDNSService::RESOLVE_DISABLE_IPV6, pr,
|
||||
sts_thread_, getter_AddRefs(pr->request_)))) {
|
||||
MOZ_MTLOG(PR_LOG_ERROR, "AsyncResolve failed.");
|
||||
ABORT(R_NOT_FOUND);
|
||||
}
|
||||
// Because the C API offers no "finished" method to release the handle we
|
||||
// return, we cannot return the request we got from AsyncResolve directly.
|
||||
//
|
||||
// Instead, we return an addref'ed reference to PendingResolution itself,
|
||||
// which in turn holds the request and coordinates between cancel and
|
||||
// OnLookupComplete to release it only once.
|
||||
*handle = pr.forget().get();
|
||||
|
||||
_status=0;
|
||||
abort:
|
||||
return _status;
|
||||
}
|
||||
|
||||
nsresult NrIceResolver::PendingResolution::OnLookupComplete(
|
||||
nsICancelable *request, nsIDNSRecord *record, nsresult status) {
|
||||
// First, check to see that we haven't canceled. This is single-threaded on
|
||||
// the STS thread, but cancel cannot guarantee this event isn't on the queue.
|
||||
ASSERT_ON_THREAD(resolver_->sts_thread_);
|
||||
if (!canceled_) {
|
||||
nr_transport_addr *cb_addr = nullptr;
|
||||
nr_transport_addr ta;
|
||||
// TODO(jib@mozilla.com): Revisit when we do TURN.
|
||||
if (NS_SUCCEEDED(status)) {
|
||||
net::NetAddr na;
|
||||
if (NS_SUCCEEDED(record->GetNextAddr(port_, &na))) {
|
||||
MOZ_ALWAYS_TRUE (nr_netaddr_to_transport_addr(&na, &ta) == 0);
|
||||
cb_addr = &ta;
|
||||
}
|
||||
}
|
||||
cb_(cb_arg_, cb_addr);
|
||||
Release();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int NrIceResolver::cancel(void *obj, void *handle) {
|
||||
MOZ_ALWAYS_TRUE(obj);
|
||||
MOZ_ASSERT(handle);
|
||||
ASSERT_ON_THREAD(static_cast<NrIceResolver *>(obj)->sts_thread_);
|
||||
return static_cast<PendingResolution *>(handle)->cancel();
|
||||
}
|
||||
|
||||
int NrIceResolver::PendingResolution::cancel() {
|
||||
request_->Cancel (NS_ERROR_ABORT);
|
||||
canceled_ = true; // in case OnLookupComplete is already on event queue.
|
||||
Release();
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(NrIceResolver::PendingResolution, nsIDNSListener);
|
||||
} // End of namespace mozilla
|
@ -1,120 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
|
||||
// Original authors: jib@mozilla.com, ekr@rtfm.com
|
||||
|
||||
// Some of this code is cut-and-pasted from nICEr. Copyright is:
|
||||
|
||||
/*
|
||||
Copyright (c) 2007, Adobe Systems, Incorporated
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Adobe Systems, Network Resonance nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef nriceresolver_h__
|
||||
#define nriceresolver_h__
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "nspr.h"
|
||||
#include "prnetdb.h"
|
||||
#include "nsIDNSService.h"
|
||||
#include "nsIDNSListener.h"
|
||||
#include "nsICancelable.h"
|
||||
|
||||
typedef struct nr_resolver_ nr_resolver;
|
||||
typedef struct nr_resolver_vtbl_ nr_resolver_vtbl;
|
||||
typedef struct nr_transport_addr_ nr_transport_addr;
|
||||
typedef struct nr_resolver_resource_ nr_resolver_resource;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class NrIceResolver
|
||||
{
|
||||
public:
|
||||
NrIceResolver();
|
||||
~NrIceResolver();
|
||||
|
||||
nsresult Init();
|
||||
nr_resolver *AllocateResolver();
|
||||
void DestroyResolver();
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(NrIceResolver)
|
||||
|
||||
private:
|
||||
// Implementations of vtbl functions
|
||||
static int destroy(void **objp);
|
||||
static int resolve(void *obj, nr_resolver_resource *resource,
|
||||
int (*cb)(void *cb_arg, nr_transport_addr *addr),
|
||||
void *cb_arg, void **handle);
|
||||
static void resolve_cb(NR_SOCKET s, int how, void *cb_arg);
|
||||
static int cancel(void *obj, void *handle);
|
||||
|
||||
int resolve(nr_resolver_resource *resource,
|
||||
int (*cb)(void *cb_arg, nr_transport_addr *addr),
|
||||
void *cb_arg, void **handle);
|
||||
|
||||
class PendingResolution : public nsIDNSListener
|
||||
{
|
||||
public:
|
||||
PendingResolution(NrIceResolver *resolver, uint16_t port,
|
||||
int (*cb)(void *cb_arg, nr_transport_addr *addr),
|
||||
void *cb_arg) :
|
||||
resolver_(resolver),
|
||||
port_(port),
|
||||
cb_(cb), cb_arg_(cb_arg),
|
||||
canceled_ (false){}
|
||||
virtual ~PendingResolution(){};
|
||||
NS_IMETHOD OnLookupComplete(nsICancelable *request, nsIDNSRecord *record,
|
||||
nsresult status);
|
||||
int cancel();
|
||||
nsCOMPtr<nsICancelable> request_;
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
private:
|
||||
NrIceResolver *resolver_;
|
||||
uint16_t port_;
|
||||
int (*cb_)(void *cb_arg, nr_transport_addr *addr);
|
||||
void *cb_arg_;
|
||||
bool canceled_;
|
||||
};
|
||||
|
||||
nr_resolver_vtbl* vtbl_;
|
||||
nsCOMPtr<nsIEventTarget> sts_thread_;
|
||||
nsCOMPtr<nsIDNSService> dns_;
|
||||
#ifdef DEBUG
|
||||
int allocated_resolvers_;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // End of namespace mozilla
|
||||
#endif
|
@ -67,7 +67,6 @@ MTRANSPORT_LCPPSRCS = \
|
||||
nricectx.cpp \
|
||||
nricemediastream.cpp \
|
||||
nriceresolverfake.cpp \
|
||||
nriceresolver.cpp \
|
||||
nr_socket_prsock.cpp \
|
||||
nr_timer.cpp \
|
||||
transportflow.cpp \
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "nricectx.h"
|
||||
#include "nricemediastream.h"
|
||||
#include "nriceresolverfake.h"
|
||||
#include "nriceresolver.h"
|
||||
#include "mtransport_test_utils.h"
|
||||
#include "runnable_utils.h"
|
||||
|
||||
@ -39,7 +38,7 @@ MtransportTestUtils *test_utils;
|
||||
bool stream_added = false;
|
||||
|
||||
const std::string kDefaultStunServerAddress((char *)"23.21.150.121");
|
||||
const std::string kDefaultStunServerHostname((char *)"ec2-23-21-150-121.compute-1.amazonaws.com");
|
||||
const std::string kDefaultStunServerHostname((char *)"stun-server.invalid");
|
||||
const std::string kBogusStunServerHostname((char *)"stun-server-nonexistent.invalid");
|
||||
const uint16_t kDefaultStunServerPort=3478;
|
||||
|
||||
@ -61,10 +60,9 @@ class IceTestPeer : public sigslot::has_slots<> {
|
||||
received_(0),
|
||||
sent_(0),
|
||||
fake_resolver_(),
|
||||
dns_resolver_(new NrIceResolver()),
|
||||
remote_(nullptr) {
|
||||
ice_ctx_->SignalGatheringCompleted.connect(this,
|
||||
&IceTestPeer::GatheringComplete);
|
||||
&IceTestPeer::GatheringComplete);
|
||||
ice_ctx_->SignalCompleted.connect(this, &IceTestPeer::IceCompleted);
|
||||
}
|
||||
|
||||
@ -100,18 +98,18 @@ class IceTestPeer : public sigslot::has_slots<> {
|
||||
ASSERT_TRUE(NS_SUCCEEDED(ice_ctx_->SetStunServers(stun_servers)));
|
||||
}
|
||||
|
||||
void SetFakeResolver() {
|
||||
ASSERT_TRUE(NS_SUCCEEDED(dns_resolver_->Init()));
|
||||
void AddAddressToResolver(const std::string hostname,
|
||||
const std::string address) {
|
||||
PRNetAddr addr;
|
||||
PRStatus status = PR_StringToNetAddr(kDefaultStunServerAddress.c_str(), &addr);
|
||||
PRStatus status = PR_StringToNetAddr(address.c_str(), &addr);
|
||||
ASSERT_EQ(PR_SUCCESS, status);
|
||||
fake_resolver_.SetAddr(kDefaultStunServerHostname, addr);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(ice_ctx_->SetResolver(fake_resolver_.AllocateResolver())));
|
||||
|
||||
fake_resolver_.SetAddr(hostname, addr);
|
||||
}
|
||||
|
||||
void SetDNSResolver() {
|
||||
ASSERT_TRUE(NS_SUCCEEDED(dns_resolver_->Init()));
|
||||
ASSERT_TRUE(NS_SUCCEEDED(ice_ctx_->SetResolver(dns_resolver_->AllocateResolver())));
|
||||
void SetResolver() {
|
||||
ASSERT_TRUE(NS_SUCCEEDED(ice_ctx_->SetResolver(
|
||||
fake_resolver_.AllocateResolver())));
|
||||
}
|
||||
|
||||
void Gather() {
|
||||
@ -272,7 +270,6 @@ class IceTestPeer : public sigslot::has_slots<> {
|
||||
size_t received_;
|
||||
size_t sent_;
|
||||
NrIceResolverFake fake_resolver_;
|
||||
nsRefPtr<NrIceResolver> dns_resolver_;
|
||||
IceTestPeer *remote_;
|
||||
};
|
||||
|
||||
@ -281,6 +278,12 @@ class IceGatherTest : public ::testing::Test {
|
||||
void SetUp() {
|
||||
peer_ = new IceTestPeer("P1", true, false);
|
||||
peer_->AddStream(1);
|
||||
peer_->AddAddressToResolver(kDefaultStunServerHostname,
|
||||
kDefaultStunServerAddress);
|
||||
}
|
||||
|
||||
void SetResolver() {
|
||||
peer_->SetResolver();
|
||||
}
|
||||
|
||||
void Gather() {
|
||||
@ -392,47 +395,30 @@ class IceConnectTest : public ::testing::Test {
|
||||
|
||||
} // end namespace
|
||||
|
||||
TEST_F(IceGatherTest, TestGatherFakeStunServerHostnameNoResolver) {
|
||||
peer_->SetStunServer(kDefaultStunServerHostname, kDefaultStunServerPort);
|
||||
Gather();
|
||||
}
|
||||
|
||||
TEST_F(IceGatherTest, TestGatherFakeStunServerIpAddress) {
|
||||
TEST_F(IceGatherTest, TestGatherStunServerIpAddress) {
|
||||
peer_->SetStunServer(kDefaultStunServerAddress, kDefaultStunServerPort);
|
||||
peer_->SetFakeResolver();
|
||||
peer_->SetResolver();
|
||||
Gather();
|
||||
}
|
||||
|
||||
TEST_F(IceGatherTest, TestGatherFakeStunServerHostname) {
|
||||
TEST_F(IceGatherTest, TestGatherStunServerHostname) {
|
||||
peer_->SetStunServer(kDefaultStunServerHostname, kDefaultStunServerPort);
|
||||
peer_->SetFakeResolver();
|
||||
peer_->SetResolver();
|
||||
Gather();
|
||||
}
|
||||
|
||||
TEST_F(IceGatherTest, TestGatherFakeStunBogusHostname) {
|
||||
TEST_F(IceGatherTest, TestGatherStunBogusHostname) {
|
||||
peer_->SetStunServer(kBogusStunServerHostname, kDefaultStunServerPort);
|
||||
peer_->SetFakeResolver();
|
||||
peer_->SetResolver();
|
||||
Gather();
|
||||
}
|
||||
|
||||
TEST_F(IceGatherTest, TestGatherDNSStunServerIpAddress) {
|
||||
peer_->SetStunServer(kDefaultStunServerAddress, kDefaultStunServerPort);
|
||||
peer_->SetDNSResolver();
|
||||
Gather();
|
||||
// TODO(jib@mozilla.com): ensure we get server reflexive candidates Bug 848094
|
||||
}
|
||||
|
||||
TEST_F(IceGatherTest, TestGatherDNSStunServerHostname) {
|
||||
TEST_F(IceGatherTest, TestGatherStunServerHostnameNoResolver) {
|
||||
peer_->SetStunServer(kDefaultStunServerHostname, kDefaultStunServerPort);
|
||||
peer_->SetDNSResolver();
|
||||
Gather();
|
||||
}
|
||||
|
||||
TEST_F(IceGatherTest, TestGatherDNSStunBogusHostname) {
|
||||
peer_->SetStunServer(kBogusStunServerHostname, kDefaultStunServerPort);
|
||||
peer_->SetDNSResolver();
|
||||
Gather();
|
||||
}
|
||||
|
||||
TEST_F(IceConnectTest, TestGather) {
|
||||
AddStream("first", 1);
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISocketTransportService.h"
|
||||
@ -45,10 +44,10 @@ class MtransportTestUtils {
|
||||
|
||||
void InitServices() {
|
||||
nsresult rv;
|
||||
ioservice_ = do_GetIOService(&rv);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
sts_target_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
sts_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
|
||||
@ -79,7 +78,6 @@ class MtransportTestUtils {
|
||||
|
||||
private:
|
||||
ScopedXPCOM xpcom_;
|
||||
nsCOMPtr<nsIIOService> ioservice_;
|
||||
nsCOMPtr<nsIEventTarget> sts_target_;
|
||||
nsCOMPtr<nsPISocketTransportService> sts_;
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
|
@ -79,17 +79,8 @@ nsresult PeerConnectionMedia::Init(const std::vector<NrIceStunServer>& stun_serv
|
||||
CSFLogError(logTag, "%s: Failed to create Ice Context", __FUNCTION__);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = mIceCtx->SetStunServers(stun_servers))) {
|
||||
CSFLogError(logTag, "%s: Failed to set stun servers", __FUNCTION__);
|
||||
return rv;
|
||||
}
|
||||
if (NS_FAILED(rv = mDNSResolver->Init())) {
|
||||
CSFLogError(logTag, "%s: Failed to initialize dns resolver", __FUNCTION__);
|
||||
return rv;
|
||||
}
|
||||
if (NS_FAILED(rv = mIceCtx->SetResolver(mDNSResolver->AllocateResolver()))) {
|
||||
CSFLogError(logTag, "%s: Failed to get dns resolver", __FUNCTION__);
|
||||
nsresult rv = mIceCtx->SetStunServers(stun_servers);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mIceCtx->SignalGatheringCompleted.connect(this,
|
||||
|
@ -37,7 +37,6 @@ namespace mozilla {
|
||||
#endif
|
||||
|
||||
#include "nricectx.h"
|
||||
#include "nriceresolver.h"
|
||||
#include "nricemediastream.h"
|
||||
#include "MediaPipeline.h"
|
||||
|
||||
@ -240,12 +239,13 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
|
||||
PeerConnectionMedia(PeerConnectionImpl *parent)
|
||||
: mParent(parent),
|
||||
mLocalSourceStreamsLock("PeerConnectionMedia.mLocalSourceStreamsLock"),
|
||||
mIceCtx(NULL),
|
||||
mDNSResolver(new mozilla::NrIceResolver()) {}
|
||||
mIceCtx(NULL) {}
|
||||
|
||||
~PeerConnectionMedia() {}
|
||||
~PeerConnectionMedia() {
|
||||
}
|
||||
|
||||
nsresult Init(const std::vector<mozilla::NrIceStunServer>& stun_servers);
|
||||
|
||||
// WARNING: This destroys the object!
|
||||
void SelfDestruct();
|
||||
|
||||
@ -354,9 +354,6 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
|
||||
mozilla::RefPtr<mozilla::NrIceCtx> mIceCtx;
|
||||
std::vector<mozilla::RefPtr<mozilla::NrIceMediaStream> > mIceStreams;
|
||||
|
||||
// DNS
|
||||
nsRefPtr<mozilla::NrIceResolver> mDNSResolver;
|
||||
|
||||
// Transport flows: even is RTP, odd is RTCP
|
||||
std::map<int, mozilla::RefPtr<mozilla::TransportFlow> > mTransportFlows;
|
||||
|
||||
|
@ -27,10 +27,6 @@ using namespace std;
|
||||
#include "runnable_utils.h"
|
||||
#include "nsStaticComponents.h"
|
||||
#include "nsIDOMRTCPeerConnection.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIDNSService.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nricectx.h"
|
||||
|
||||
@ -1144,6 +1140,7 @@ public:
|
||||
SignalingAgent a2_; // Canonically "callee"
|
||||
};
|
||||
|
||||
|
||||
TEST_F(SignalingTest, JustInit)
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user