Backed out 2 changesets (bug 1251714, bug 1251715) for gtest failures in media code a=backout

Backed out changeset 1bbd0cd10f76 (bug 1251714)
Backed out changeset 80b197c5608f (bug 1251715)

MozReview-Commit-ID: EHOtiKLS4Xr
This commit is contained in:
Wes Kocher 2016-03-01 11:36:35 -08:00
parent 48cce72dbb
commit fe16a1ee67
27 changed files with 175 additions and 156 deletions

View File

@ -1103,7 +1103,7 @@ static auto& MediaManager_AnonymizeDevices = MediaManager::AnonymizeDevices;
already_AddRefed<MediaManager::PledgeChar> already_AddRefed<MediaManager::PledgeChar>
MediaManager::SelectSettings( MediaManager::SelectSettings(
MediaStreamConstraints& aConstraints, MediaStreamConstraints& aConstraints,
RefPtr<Refcountable<UniquePtr<SourceSet>>>& aSources) RefPtr<Refcountable<ScopedDeletePtr<SourceSet>>>& aSources)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
RefPtr<PledgeChar> p = new PledgeChar(); RefPtr<PledgeChar> p = new PledgeChar();
@ -1414,7 +1414,7 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId,
realBackend = manager->GetBackend(aWindowId); realBackend = manager->GetBackend(aWindowId);
} }
auto result = MakeUnique<SourceSet>(); ScopedDeletePtr<SourceSet> result(new SourceSet);
if (hasVideo) { if (hasVideo) {
nsTArray<RefPtr<VideoDevice>> videos; nsTArray<RefPtr<VideoDevice>> videos;
@ -1432,16 +1432,16 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId,
result->AppendElement(source); result->AppendElement(source);
} }
} }
SourceSet* handoff = result.release(); SourceSet* handoff = result.forget();
NS_DispatchToMainThread(do_AddRef(NewRunnableFrom([id, handoff]() mutable { NS_DispatchToMainThread(do_AddRef(NewRunnableFrom([id, handoff]() mutable {
UniquePtr<SourceSet> result(handoff); // grab result ScopedDeletePtr<SourceSet> result(handoff); // grab result
RefPtr<MediaManager> mgr = MediaManager_GetInstance(); RefPtr<MediaManager> mgr = MediaManager_GetInstance();
if (!mgr) { if (!mgr) {
return NS_OK; return NS_OK;
} }
RefPtr<PledgeSourceSet> p = mgr->mOutstandingPledges.Remove(id); RefPtr<PledgeSourceSet> p = mgr->mOutstandingPledges.Remove(id);
if (p) { if (p) {
p->Resolve(result.release()); p->Resolve(result.forget());
} }
return NS_OK; return NS_OK;
}))); })));
@ -1609,9 +1609,9 @@ media::Parent<media::NonE10s>*
MediaManager::GetNonE10sParent() MediaManager::GetNonE10sParent()
{ {
if (!mNonE10sParent) { if (!mNonE10sParent) {
mNonE10sParent = MakeUnique<media::Parent<media::NonE10s>>(true); mNonE10sParent = new media::Parent<media::NonE10s>(true);
} }
return mNonE10sParent.get(); return mNonE10sParent;
} }
/* static */ void /* static */ void
@ -2115,8 +2115,8 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow,
p->Then([this, onSuccess, onFailure, windowID, c, listener, askPermission, p->Then([this, onSuccess, onFailure, windowID, c, listener, askPermission,
prefs, isHTTPS, callID, origin](SourceSet*& aDevices) mutable { prefs, isHTTPS, callID, origin](SourceSet*& aDevices) mutable {
RefPtr<Refcountable<UniquePtr<SourceSet>>> devices( RefPtr<Refcountable<ScopedDeletePtr<SourceSet>>> devices(
new Refcountable<UniquePtr<SourceSet>>(aDevices)); // grab result new Refcountable<ScopedDeletePtr<SourceSet>>(aDevices)); // grab result
// Ensure that the captured 'this' pointer and our windowID are still good. // Ensure that the captured 'this' pointer and our windowID are still good.
if (!MediaManager::Exists() || if (!MediaManager::Exists() ||
@ -2176,7 +2176,7 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow,
onFailure.forget(), onFailure.forget(),
windowID, listener, windowID, listener,
prefs, origin, prefs, origin,
devices->release())); devices->forget()));
// Store the task w/callbacks. // Store the task w/callbacks.
mActiveCallbacks.Put(callID, task.forget()); mActiveCallbacks.Put(callID, task.forget());
@ -2335,7 +2335,7 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
aVideoType, aAudioType, aVideoType, aAudioType,
aFake, aFakeTracks); aFake, aFakeTracks);
p->Then([id, aWindowId, aOriginKey](SourceSet*& aDevices) mutable { p->Then([id, aWindowId, aOriginKey](SourceSet*& aDevices) mutable {
UniquePtr<SourceSet> devices(aDevices); // secondary result ScopedDeletePtr<SourceSet> devices(aDevices); // secondary result
// Only run if window is still on our active list. // Only run if window is still on our active list.
RefPtr<MediaManager> mgr = MediaManager_GetInstance(); RefPtr<MediaManager> mgr = MediaManager_GetInstance();
@ -2347,7 +2347,7 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
return NS_OK; return NS_OK;
} }
MediaManager_AnonymizeDevices(*devices, aOriginKey); MediaManager_AnonymizeDevices(*devices, aOriginKey);
p->Resolve(devices.release()); p->Resolve(devices.forget());
return NS_OK; return NS_OK;
}); });
}); });
@ -2381,7 +2381,7 @@ MediaManager::EnumerateDevices(nsPIDOMWindowInner* aWindow,
MediaSourceEnum::Microphone, MediaSourceEnum::Microphone,
fake); fake);
p->Then([onSuccess, windowId, listener](SourceSet*& aDevices) mutable { p->Then([onSuccess, windowId, listener](SourceSet*& aDevices) mutable {
UniquePtr<SourceSet> devices(aDevices); // grab result ScopedDeletePtr<SourceSet> devices(aDevices); // grab result
RefPtr<MediaManager> mgr = MediaManager_GetInstance(); RefPtr<MediaManager> mgr = MediaManager_GetInstance();
mgr->RemoveFromWindowList(windowId, listener); mgr->RemoveFromWindowList(windowId, listener);
nsCOMPtr<nsIWritableVariant> array = MediaManager_ToJSArray(*devices); nsCOMPtr<nsIWritableVariant> array = MediaManager_ToJSArray(*devices);

View File

@ -30,7 +30,6 @@
#include "mozilla/media/MediaChild.h" #include "mozilla/media/MediaChild.h"
#include "mozilla/media/MediaParent.h" #include "mozilla/media/MediaParent.h"
#include "mozilla/Logging.h" #include "mozilla/Logging.h"
#include "mozilla/UniquePtr.h"
#include "DOMMediaStream.h" #include "DOMMediaStream.h"
#ifdef MOZ_WEBRTC #ifdef MOZ_WEBRTC
@ -502,7 +501,7 @@ private:
already_AddRefed<PledgeChar> already_AddRefed<PledgeChar>
SelectSettings( SelectSettings(
dom::MediaStreamConstraints& aConstraints, dom::MediaStreamConstraints& aConstraints,
RefPtr<media::Refcountable<UniquePtr<SourceSet>>>& aSources); RefPtr<media::Refcountable<ScopedDeletePtr<SourceSet>>>& aSources);
StreamListeners* AddWindowID(uint64_t aWindowId); StreamListeners* AddWindowID(uint64_t aWindowId);
WindowTable *GetActiveWindows() { WindowTable *GetActiveWindows() {
@ -551,7 +550,7 @@ private:
#endif #endif
public: public:
media::CoatCheck<media::Pledge<nsCString>> mGetOriginKeyPledges; media::CoatCheck<media::Pledge<nsCString>> mGetOriginKeyPledges;
UniquePtr<media::Parent<media::NonE10s>> mNonE10sParent; ScopedDeletePtr<media::Parent<media::NonE10s>> mNonE10sParent;
}; };
} // namespace mozilla } // namespace mozilla

View File

@ -8,7 +8,6 @@
#include "gfx2DGlue.h" #include "gfx2DGlue.h"
#include "ImageContainer.h" #include "ImageContainer.h"
#include "Layers.h" #include "Layers.h"
#include "mozilla/UniquePtr.h"
namespace mozilla { namespace mozilla {
@ -53,18 +52,18 @@ VideoFrame::CreateBlackImage(const gfx::IntSize& aSize)
int len = ((aSize.width * aSize.height) * 3 / 2); int len = ((aSize.width * aSize.height) * 3 / 2);
// Generate a black image. // Generate a black image.
auto frame = MakeUnique<uint8_t[]>(len); ScopedDeletePtr<uint8_t> frame(new uint8_t[len]);
int y = aSize.width * aSize.height; int y = aSize.width * aSize.height;
// Fill Y plane. // Fill Y plane.
memset(frame.get(), 0x10, y); memset(frame.rwget(), 0x10, y);
// Fill Cb/Cr planes. // Fill Cb/Cr planes.
memset(frame.get() + y, 0x80, (len - y)); memset(frame.rwget() + y, 0x80, (len - y));
const uint8_t lumaBpp = 8; const uint8_t lumaBpp = 8;
const uint8_t chromaBpp = 4; const uint8_t chromaBpp = 4;
layers::PlanarYCbCrData data; layers::PlanarYCbCrData data;
data.mYChannel = frame.get(); data.mYChannel = frame.rwget();
data.mYSize = gfx::IntSize(aSize.width, aSize.height); data.mYSize = gfx::IntSize(aSize.width, aSize.height);
data.mYStride = (int32_t) (aSize.width * lumaBpp / 8.0); data.mYStride = (int32_t) (aSize.width * lumaBpp / 8.0);
data.mCbCrStride = (int32_t) (aSize.width * chromaBpp / 8.0); data.mCbCrStride = (int32_t) (aSize.width * chromaBpp / 8.0);

View File

@ -46,7 +46,7 @@ SanitizeOriginKeys(const uint64_t& aSinceWhen, bool aOnlyPrivateBrowsing)
if (XRE_GetProcessType() == GeckoProcessType_Default) { if (XRE_GetProcessType() == GeckoProcessType_Default) {
// Avoid opening MediaManager in this case, since this is called by // Avoid opening MediaManager in this case, since this is called by
// sanitize.js when cookies are cleared, which can happen on startup. // sanitize.js when cookies are cleared, which can happen on startup.
auto tmpParent = MakeUnique<Parent<NonE10s>>(true); ScopedDeletePtr<Parent<NonE10s>> tmpParent(new Parent<NonE10s>(true));
tmpParent->RecvSanitizeOriginKeys(aSinceWhen, aOnlyPrivateBrowsing); tmpParent->RecvSanitizeOriginKeys(aSinceWhen, aOnlyPrivateBrowsing);
} else { } else {
Child::Get()->SendSanitizeOriginKeys(aSinceWhen, aOnlyPrivateBrowsing); Child::Get()->SendSanitizeOriginKeys(aSinceWhen, aOnlyPrivateBrowsing);

View File

@ -10,7 +10,6 @@
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "nsIAsyncShutdown.h" #include "nsIAsyncShutdown.h"
#include "mozilla/UniquePtr.h"
#include "base/task.h" #include "base/task.h"
namespace mozilla { namespace mozilla {
@ -97,8 +96,8 @@ public:
OnSuccessType mOnSuccess; OnSuccessType mOnSuccess;
OnFailureType mOnFailure; OnFailureType mOnFailure;
}; };
mFunctors = MakeUnique<Functors>(Forward<OnSuccessType>(aOnSuccess), mFunctors = new Functors(Forward<OnSuccessType>(aOnSuccess),
Forward<OnFailureType>(aOnFailure)); Forward<OnFailureType>(aOnFailure));
if (mDone) { if (mDone) {
if (!mRejected) { if (!mRejected) {
mFunctors->Succeed(mValue); mFunctors->Succeed(mValue);
@ -143,7 +142,7 @@ private:
bool mDone; bool mDone;
bool mRejected; bool mRejected;
ErrorType mError; ErrorType mError;
UniquePtr<FunctorsBase> mFunctors; ScopedDeletePtr<FunctorsBase> mFunctors;
}; };
/* media::NewRunnableFrom() - Create an nsRunnable from a lambda. /* media::NewRunnableFrom() - Create an nsRunnable from a lambda.
@ -338,7 +337,7 @@ private:
* (or owning smart-pointers to such objects) refcountable. * (or owning smart-pointers to such objects) refcountable.
* *
* Technical limitation: A template specialization is needed for types that take * Technical limitation: A template specialization is needed for types that take
* a constructor. Please add below (UniquePtr covers a lot of ground though). * a constructor. Please add below (ScopedDeletePtr covers a lot of ground though).
*/ */
template<typename T> template<typename T>
@ -351,13 +350,13 @@ private:
}; };
template<typename T> template<typename T>
class Refcountable<UniquePtr<T>> : public UniquePtr<T> class Refcountable<ScopedDeletePtr<T>> : public ScopedDeletePtr<T>
{ {
public: public:
explicit Refcountable<UniquePtr<T>>(T* aPtr) : UniquePtr<T>(aPtr) {} explicit Refcountable<ScopedDeletePtr<T>>(T* aPtr) : ScopedDeletePtr<T>(aPtr) {}
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Refcountable<T>) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Refcountable<T>)
private: private:
~Refcountable<UniquePtr<T>>() {} ~Refcountable<ScopedDeletePtr<T>>() {}
}; };
/* media::ShutdownBlocker - Async shutdown helper. /* media::ShutdownBlocker - Async shutdown helper.

View File

@ -58,8 +58,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "prnetdb.h" #include "prnetdb.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/Scoped.h"
#include "mozilla/TimeStamp.h" #include "mozilla/TimeStamp.h"
#include "mozilla/UniquePtr.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsIEventTarget.h" #include "nsIEventTarget.h"
#include "nsITimer.h" #include "nsITimer.h"
@ -99,15 +99,16 @@ class NrIceStunServer {
} }
// The main function to use. Will take either an address or a hostname. // The main function to use. Will take either an address or a hostname.
static UniquePtr<NrIceStunServer> Create(const std::string& addr, uint16_t port, static NrIceStunServer* Create(const std::string& addr, uint16_t port,
const char *transport = kNrIceTransportUdp) { const char *transport = kNrIceTransportUdp) {
UniquePtr<NrIceStunServer> server(new NrIceStunServer(transport)); ScopedDeletePtr<NrIceStunServer> server(
new NrIceStunServer(transport));
nsresult rv = server->Init(addr, port); nsresult rv = server->Init(addr, port);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return nullptr; return nullptr;
return server; return server.forget();
} }
nsresult ToNicerStunStruct(nr_ice_stun_server* server) const; nsresult ToNicerStunStruct(nr_ice_stun_server* server) const;
@ -145,17 +146,18 @@ class NrIceStunServer {
class NrIceTurnServer : public NrIceStunServer { class NrIceTurnServer : public NrIceStunServer {
public: public:
static UniquePtr<NrIceTurnServer> Create(const std::string& addr, uint16_t port, static NrIceTurnServer *Create(const std::string& addr, uint16_t port,
const std::string& username, const std::string& username,
const std::vector<unsigned char>& password, const std::vector<unsigned char>& password,
const char *transport = kNrIceTransportUdp) { const char *transport = kNrIceTransportUdp) {
UniquePtr<NrIceTurnServer> server(new NrIceTurnServer(username, password, transport)); ScopedDeletePtr<NrIceTurnServer> server(
new NrIceTurnServer(username, password, transport));
nsresult rv = server->Init(addr, port); nsresult rv = server->Init(addr, port);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return nullptr; return nullptr;
return server; return server.forget();
} }
nsresult ToNicerTurnStruct(nr_ice_turn_server *server) const; nsresult ToNicerTurnStruct(nr_ice_turn_server *server) const;

View File

@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "logging.h" #include "logging.h"
#include "nsError.h" #include "nsError.h"
#include "mozilla/Scoped.h"
// nICEr includes // nICEr includes
extern "C" { extern "C" {
@ -168,13 +169,13 @@ static bool ToNrIceCandidate(const nr_ice_candidate& candc,
// Make an NrIceCandidate from the candidate |cand|. // Make an NrIceCandidate from the candidate |cand|.
// This is not a member fxn because we want to hide the // This is not a member fxn because we want to hide the
// defn of nr_ice_candidate but we pass by reference. // defn of nr_ice_candidate but we pass by reference.
static UniquePtr<NrIceCandidate> MakeNrIceCandidate(const nr_ice_candidate& candc) { static NrIceCandidate* MakeNrIceCandidate(const nr_ice_candidate& candc) {
UniquePtr<NrIceCandidate> out(new NrIceCandidate()); ScopedDeletePtr<NrIceCandidate> out(new NrIceCandidate());
if (!ToNrIceCandidate(candc, out.get())) { if (!ToNrIceCandidate(candc, out)) {
return nullptr; return nullptr;
} }
return out; return out.forget();
} }
// NrIceMediaStream // NrIceMediaStream
@ -258,8 +259,8 @@ nsresult NrIceMediaStream::ParseTrickleCandidate(const std::string& candidate) {
// Returns NS_ERROR_NOT_AVAILABLE if component is unpaired or disabled. // Returns NS_ERROR_NOT_AVAILABLE if component is unpaired or disabled.
nsresult NrIceMediaStream::GetActivePair(int component, nsresult NrIceMediaStream::GetActivePair(int component,
UniquePtr<NrIceCandidate>* localp, NrIceCandidate **localp,
UniquePtr<NrIceCandidate>* remotep) { NrIceCandidate **remotep) {
int r; int r;
nr_ice_candidate *local_int; nr_ice_candidate *local_int;
nr_ice_candidate *remote_int; nr_ice_candidate *remote_int;
@ -279,20 +280,20 @@ nsresult NrIceMediaStream::GetActivePair(int component,
if (r) if (r)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
UniquePtr<NrIceCandidate> local( ScopedDeletePtr<NrIceCandidate> local(
MakeNrIceCandidate(*local_int)); MakeNrIceCandidate(*local_int));
if (!local) if (!local)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
UniquePtr<NrIceCandidate> remote( ScopedDeletePtr<NrIceCandidate> remote(
MakeNrIceCandidate(*remote_int)); MakeNrIceCandidate(*remote_int));
if (!remote) if (!remote)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
if (localp) if (localp)
*localp = Move(local); *localp = local.forget();
if (remotep) if (remotep)
*remotep = Move(remote); *remotep = remote.forget();
return NS_OK; return NS_OK;
} }

View File

@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "sigslot.h" #include "sigslot.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h" #include "mozilla/Scoped.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIEventTarget.h" #include "nsIEventTarget.h"
#include "nsITimer.h" #include "nsITimer.h"
@ -159,8 +159,7 @@ class NrIceMediaStream {
// Get the candidate pair currently active. It's the // Get the candidate pair currently active. It's the
// caller's responsibility to free these. // caller's responsibility to free these.
nsresult GetActivePair(int component, nsresult GetActivePair(int component,
UniquePtr<NrIceCandidate>* local, NrIceCandidate** local, NrIceCandidate** remote);
UniquePtr<NrIceCandidate>* remote);
// The number of components // The number of components
size_t components() const { return components_; } size_t components() const { return components_; }

View File

@ -12,6 +12,8 @@
#include "nss.h" #include "nss.h"
#include "ssl.h" #include "ssl.h"
#include "mozilla/Scoped.h"
extern "C" { extern "C" {
#include "nr_api.h" #include "nr_api.h"
#include "nr_socket.h" #include "nr_socket.h"

View File

@ -22,6 +22,7 @@
#include "ssl.h" #include "ssl.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/Scoped.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "nsXPCOM.h" #include "nsXPCOM.h"
@ -470,7 +471,7 @@ class IceTestPeer : public sigslot::has_slots<> {
} }
std::vector<NrIceStunServer> stun_servers; std::vector<NrIceStunServer> stun_servers;
UniquePtr<NrIceStunServer> server(NrIceStunServer::Create( ScopedDeletePtr<NrIceStunServer> server(NrIceStunServer::Create(
addr, port, transport)); addr, port, transport));
stun_servers.push_back(*server); stun_servers.push_back(*server);
SetStunServers(stun_servers); SetStunServers(stun_servers);
@ -499,7 +500,7 @@ class IceTestPeer : public sigslot::has_slots<> {
const std::vector<unsigned char> password, const std::vector<unsigned char> password,
const char* transport) { const char* transport) {
std::vector<NrIceTurnServer> turn_servers; std::vector<NrIceTurnServer> turn_servers;
UniquePtr<NrIceTurnServer> server(NrIceTurnServer::Create( ScopedDeletePtr<NrIceTurnServer> server(NrIceTurnServer::Create(
addr, port, username, password, transport)); addr, port, username, password, transport));
turn_servers.push_back(*server); turn_servers.push_back(*server);
ASSERT_TRUE(NS_SUCCEEDED(ice_ctx_->SetTurnServers(turn_servers))); ASSERT_TRUE(NS_SUCCEEDED(ice_ctx_->SetTurnServers(turn_servers)));
@ -843,8 +844,8 @@ class IceTestPeer : public sigslot::has_slots<> {
for (size_t j=0; j < streams_[i]->components(); ++j) { for (size_t j=0; j < streams_[i]->components(); ++j) {
std::cerr << "Stream " << i << " component " << j+1 << std::endl; std::cerr << "Stream " << i << " component " << j+1 << std::endl;
UniquePtr<NrIceCandidate> local; NrIceCandidate *local;
UniquePtr<NrIceCandidate> remote; NrIceCandidate *remote;
nsresult res = streams_[i]->GetActivePair(j+1, &local, &remote); nsresult res = streams_[i]->GetActivePair(j+1, &local, &remote);
if (res == NS_ERROR_NOT_AVAILABLE) { if (res == NS_ERROR_NOT_AVAILABLE) {
@ -875,6 +876,8 @@ class IceTestPeer : public sigslot::has_slots<> {
if (!expected_remote_addr_.empty()) { if (!expected_remote_addr_.empty()) {
ASSERT_EQ(expected_remote_addr_, remote->cand_addr.host); ASSERT_EQ(expected_remote_addr_, remote->cand_addr.host);
} }
delete local;
delete remote;
} }
} }
} }
@ -1312,12 +1315,12 @@ class IceGatherTest : public StunTest {
void EnsurePeer(const unsigned int flags = ICE_TEST_PEER_OFFERER) { void EnsurePeer(const unsigned int flags = ICE_TEST_PEER_OFFERER) {
if (!peer_) { if (!peer_) {
peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, peer_ = new IceTestPeer("P1", test_utils_,
flags & ICE_TEST_PEER_OFFERER, flags & ICE_TEST_PEER_OFFERER,
flags & ICE_TEST_PEER_ALLOW_LOOPBACK, flags & ICE_TEST_PEER_ALLOW_LOOPBACK,
flags & ICE_TEST_PEER_ENABLED_TCP, flags & ICE_TEST_PEER_ENABLED_TCP,
flags & ICE_TEST_PEER_ALLOW_LINK_LOCAL, flags & ICE_TEST_PEER_ALLOW_LINK_LOCAL,
flags & ICE_TEST_PEER_HIDE_NON_DEFAULT); flags & ICE_TEST_PEER_HIDE_NON_DEFAULT);
peer_->AddStream(1); peer_->AddStream(1);
} }
} }
@ -1450,7 +1453,7 @@ class IceGatherTest : public StunTest {
} }
protected: protected:
mozilla::UniquePtr<IceTestPeer> peer_; mozilla::ScopedDeletePtr<IceTestPeer> peer_;
}; };
class IceConnectTest : public StunTest { class IceConnectTest : public StunTest {
@ -1490,10 +1493,10 @@ class IceConnectTest : public StunTest {
void Init(bool allow_loopback, bool enable_tcp, bool default_only = false) { void Init(bool allow_loopback, bool enable_tcp, bool default_only = false) {
if (!initted_) { if (!initted_) {
p1_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, allow_loopback, p1_ = new IceTestPeer("P1", test_utils_, true, allow_loopback,
enable_tcp, false, default_only); enable_tcp, false, default_only);
p2_ = MakeUnique<IceTestPeer>("P2", test_utils_, false, allow_loopback, p2_ = new IceTestPeer("P2", test_utils_, false, allow_loopback,
enable_tcp, false, default_only); enable_tcp, false, default_only);
} }
initted_ = true; initted_ = true;
} }
@ -1590,8 +1593,8 @@ class IceConnectTest : public StunTest {
// to |this|, meaning that p2_->Connect(p1_, ...) simulates p1 sending an // to |this|, meaning that p2_->Connect(p1_, ...) simulates p1 sending an
// offer to p2. Order matters here because it determines which peer is // offer to p2. Order matters here because it determines which peer is
// controlling. // controlling.
p2_->Connect(p1_.get(), TRICKLE_NONE); p2_->Connect(p1_, TRICKLE_NONE);
p1_->Connect(p2_.get(), TRICKLE_NONE); p1_->Connect(p2_, TRICKLE_NONE);
ASSERT_TRUE_WAIT(p1_->ready_ct() == 1 && p2_->ready_ct() == 1, ASSERT_TRUE_WAIT(p1_->ready_ct() == 1 && p2_->ready_ct() == 1,
kDefaultTimeout); kDefaultTimeout);
@ -1621,11 +1624,11 @@ class IceConnectTest : public StunTest {
} }
void ConnectP1(TrickleMode mode = TRICKLE_NONE) { void ConnectP1(TrickleMode mode = TRICKLE_NONE) {
p1_->Connect(p2_.get(), mode); p1_->Connect(p2_, mode);
} }
void ConnectP2(TrickleMode mode = TRICKLE_NONE) { void ConnectP2(TrickleMode mode = TRICKLE_NONE) {
p2_->Connect(p1_.get(), mode); p2_->Connect(p1_, mode);
} }
void WaitForComplete(int expected_streams = 1) { void WaitForComplete(int expected_streams = 1) {
@ -1646,8 +1649,8 @@ class IceConnectTest : public StunTest {
} }
void ConnectTrickle(TrickleMode trickle = TRICKLE_SIMULATE) { void ConnectTrickle(TrickleMode trickle = TRICKLE_SIMULATE) {
p2_->Connect(p1_.get(), trickle); p2_->Connect(p1_, trickle);
p1_->Connect(p2_.get(), trickle); p1_->Connect(p2_, trickle);
} }
void SimulateTrickle(size_t stream) { void SimulateTrickle(size_t stream) {
@ -1673,8 +1676,8 @@ class IceConnectTest : public StunTest {
} }
void ConnectThenDelete() { void ConnectThenDelete() {
p2_->Connect(p1_.get(), TRICKLE_NONE, false); p2_->Connect(p1_, TRICKLE_NONE, false);
p1_->Connect(p2_.get(), TRICKLE_NONE, true); p1_->Connect(p2_, TRICKLE_NONE, true);
test_utils_->sts_target()->Dispatch(WrapRunnable(this, test_utils_->sts_target()->Dispatch(WrapRunnable(this,
&IceConnectTest::CloseP1), &IceConnectTest::CloseP1),
NS_DISPATCH_SYNC); NS_DISPATCH_SYNC);
@ -1698,8 +1701,8 @@ class IceConnectTest : public StunTest {
protected: protected:
bool initted_; bool initted_;
nsCOMPtr<nsIEventTarget> target_; nsCOMPtr<nsIEventTarget> target_;
mozilla::UniquePtr<IceTestPeer> p1_; mozilla::ScopedDeletePtr<IceTestPeer> p1_;
mozilla::UniquePtr<IceTestPeer> p2_; mozilla::ScopedDeletePtr<IceTestPeer> p2_;
bool use_nat_; bool use_nat_;
TestNat::NatBehavior filtering_type_; TestNat::NatBehavior filtering_type_;
TestNat::NatBehavior mapping_type_; TestNat::NatBehavior mapping_type_;
@ -1857,7 +1860,7 @@ TEST_F(IceGatherTest, TestGatherStunServerIpAddressDefaultRouteOnly) {
return; return;
} }
peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false, false, true); peer_ = new IceTestPeer("P1", test_utils_, true, false, false, false, true);
peer_->AddStream(1); peer_->AddStream(1);
peer_->SetStunServer(stun_server_address_, kDefaultStunServerPort); peer_->SetStunServer(stun_server_address_, kDefaultStunServerPort);
peer_->SetFakeResolver(stun_server_address_, stun_server_hostname_); peer_->SetFakeResolver(stun_server_address_, stun_server_hostname_);
@ -2046,7 +2049,7 @@ TEST_F(IceGatherTest, TestGatherVerifyNoLoopback) {
TEST_F(IceGatherTest, TestGatherAllowLoopback) { TEST_F(IceGatherTest, TestGatherAllowLoopback) {
// Set up peer with loopback allowed. // Set up peer with loopback allowed.
peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, true); peer_ = new IceTestPeer("P1", test_utils_, true, true);
peer_->AddStream(1); peer_->AddStream(1);
Gather(); Gather();
ASSERT_TRUE(StreamHasMatchingCandidate(0, "127.0.0.1")); ASSERT_TRUE(StreamHasMatchingCandidate(0, "127.0.0.1"));
@ -2054,7 +2057,7 @@ TEST_F(IceGatherTest, TestGatherAllowLoopback) {
TEST_F(IceGatherTest, TestGatherTcpDisabled) { TEST_F(IceGatherTest, TestGatherTcpDisabled) {
// Set up peer with tcp disabled. // Set up peer with tcp disabled.
peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false); peer_ = new IceTestPeer("P1", test_utils_, true, false, false);
peer_->AddStream(1); peer_->AddStream(1);
Gather(); Gather();
ASSERT_FALSE(StreamHasMatchingCandidate(0, " TCP ")); ASSERT_FALSE(StreamHasMatchingCandidate(0, " TCP "));
@ -2157,7 +2160,7 @@ TEST_F(IceGatherTest, TestStunServerTrickle) {
// Test default route only with our fake STUN server and // Test default route only with our fake STUN server and
// apparently NATted. // apparently NATted.
TEST_F(IceGatherTest, TestFakeStunServerNatedDefaultRouteOnly) { TEST_F(IceGatherTest, TestFakeStunServerNatedDefaultRouteOnly) {
peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false, false, true); peer_ = new IceTestPeer("P1", test_utils_, true, false, false, false, true);
peer_->AddStream(1); peer_->AddStream(1);
UseFakeStunUdpServerWithResponse("192.0.2.1", 3333); UseFakeStunUdpServerWithResponse("192.0.2.1", 3333);
Gather(0); Gather(0);
@ -2175,7 +2178,7 @@ TEST_F(IceGatherTest, TestFakeStunServerNatedDefaultRouteOnly) {
// Test default route only with our fake STUN server and // Test default route only with our fake STUN server and
// apparently non-NATted. // apparently non-NATted.
TEST_F(IceGatherTest, TestFakeStunServerNoNatDefaultRouteOnly) { TEST_F(IceGatherTest, TestFakeStunServerNoNatDefaultRouteOnly) {
peer_ = MakeUnique<IceTestPeer>("P1", test_utils_, true, false, false, false, true); peer_ = new IceTestPeer("P1", test_utils_, true, false, false, false, true);
peer_->AddStream(1); peer_->AddStream(1);
UseTestStunServer(); UseTestStunServer();
Gather(0); Gather(0);
@ -3054,8 +3057,10 @@ TEST_F(IceConnectTest, TestHostCandPairingFilter) {
} }
ConnectTrickle(); ConnectTrickle();
AddNonPairableCandidates(p1_->ControlTrickle(0), p1_.get(), 0, host_net, test_utils_); AddNonPairableCandidates(p1_->ControlTrickle(0), p1_, 0, host_net,
AddNonPairableCandidates(p2_->ControlTrickle(0), p2_.get(), 0, host_net, test_utils_); test_utils_);
AddNonPairableCandidates(p2_->ControlTrickle(0), p2_, 0, host_net,
test_utils_);
std::vector<NrIceCandidatePair> pairs; std::vector<NrIceCandidatePair> pairs;
p1_->GetCandidatePairs(0, &pairs); p1_->GetCandidatePairs(0, &pairs);
@ -3116,8 +3121,8 @@ TEST_F(IceConnectTest, TestPollCandPairsDuringConnect) {
AddStream("first", 1); AddStream("first", 1);
ASSERT_TRUE(Gather()); ASSERT_TRUE(Gather());
p2_->Connect(p1_.get(), TRICKLE_NONE, false); p2_->Connect(p1_, TRICKLE_NONE, false);
p1_->Connect(p2_.get(), TRICKLE_NONE, false); p1_->Connect(p2_, TRICKLE_NONE, false);
std::vector<NrIceCandidatePair> pairs1; std::vector<NrIceCandidatePair> pairs1;
std::vector<NrIceCandidatePair> pairs2; std::vector<NrIceCandidatePair> pairs2;
@ -3141,8 +3146,8 @@ TEST_F(IceConnectTest, TestRLogRingBuffer) {
AddStream("first", 1); AddStream("first", 1);
ASSERT_TRUE(Gather()); ASSERT_TRUE(Gather());
p2_->Connect(p1_.get(), TRICKLE_NONE, false); p2_->Connect(p1_, TRICKLE_NONE, false);
p1_->Connect(p2_.get(), TRICKLE_NONE, false); p1_->Connect(p2_, TRICKLE_NONE, false);
std::vector<NrIceCandidatePair> pairs1; std::vector<NrIceCandidatePair> pairs1;
std::vector<NrIceCandidatePair> pairs2; std::vector<NrIceCandidatePair> pairs2;

View File

@ -7,6 +7,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include "mozilla/Scoped.h"
#include "mozilla/Atomics.h" #include "mozilla/Atomics.h"
#include "runnable_utils.h" #include "runnable_utils.h"
#include "nss.h" #include "nss.h"
@ -105,7 +106,7 @@ class MultiTcpSocketTest : public MtransportTest {
if (!stun_server_addr.empty()) { if (!stun_server_addr.empty()) {
std::vector<NrIceStunServer> stun_servers; std::vector<NrIceStunServer> stun_servers;
UniquePtr<NrIceStunServer> server(NrIceStunServer::Create( ScopedDeletePtr<NrIceStunServer> server(NrIceStunServer::Create(
stun_server_addr, stun_server_port, kNrIceTransportTcp)); stun_server_addr, stun_server_port, kNrIceTransportTcp));
stun_servers.push_back(*server); stun_servers.push_back(*server);

View File

@ -12,6 +12,8 @@
#include "nss.h" #include "nss.h"
#include "ssl.h" #include "ssl.h"
#include "mozilla/Scoped.h"
extern "C" { extern "C" {
#include "nr_api.h" #include "nr_api.h"
#include "nr_socket.h" #include "nr_socket.h"

View File

@ -78,8 +78,7 @@ nrappkit copyright:
ekr@rtfm.com Thu Dec 20 20:14:49 2001 ekr@rtfm.com Thu Dec 20 20:14:49 2001
*/ */
#include "logging.h" #include "logging.h"
#include "mozilla/UniquePtr.h" #include "mozilla/Scoped.h"
#include "mozilla/unused.h"
#include "databuffer.h" #include "databuffer.h"
extern "C" { extern "C" {
@ -175,7 +174,7 @@ static nr_socket_vtbl nr_socket_wrapped_vtbl = {
}; };
int nr_socket_wrapped_create(nr_socket *inner, nr_socket **outp) { int nr_socket_wrapped_create(nr_socket *inner, nr_socket **outp) {
auto wrapped = MakeUnique<nr_socket_wrapped>(); ScopedDeletePtr<nr_socket_wrapped> wrapped(new nr_socket_wrapped());
wrapped->sock_ = inner; wrapped->sock_ = inner;
@ -183,7 +182,7 @@ int nr_socket_wrapped_create(nr_socket *inner, nr_socket **outp) {
if (r) if (r)
return r; return r;
Unused << wrapped.release(); wrapped.forget();
return 0; return 0;
} }
@ -191,10 +190,10 @@ int nr_socket_wrapped_create(nr_socket *inner, nr_socket **outp) {
// Instance static. // Instance static.
// Note: Calling Create() at static init time is not going to be safe, since // Note: Calling Create() at static init time is not going to be safe, since
// we have no reason to expect this will be initted to a nullptr yet. // we have no reason to expect this will be initted to a nullptr yet.
UniquePtr<TestStunServer> TestStunServer::instance; TestStunServer *TestStunServer::instance;
UniquePtr<TestStunTcpServer> TestStunTcpServer::instance; TestStunTcpServer *TestStunTcpServer::instance;
UniquePtr<TestStunServer> TestStunServer::instance6; TestStunServer *TestStunServer::instance6;
UniquePtr<TestStunTcpServer> TestStunTcpServer::instance6; TestStunTcpServer *TestStunTcpServer::instance6;
uint16_t TestStunServer::instance_port = 3478; uint16_t TestStunServer::instance_port = 3478;
uint16_t TestStunTcpServer::instance_port = 3478; uint16_t TestStunTcpServer::instance_port = 3478;
@ -324,10 +323,10 @@ int TestStunServer::Initialize(int address_family) {
return 0; return 0;
} }
UniquePtr<TestStunServer> TestStunServer::Create(int address_family) { TestStunServer* TestStunServer::Create(int address_family) {
NR_reg_init(NR_REG_MODE_LOCAL); NR_reg_init(NR_REG_MODE_LOCAL);
UniquePtr<TestStunServer> server(new TestStunServer()); ScopedDeletePtr<TestStunServer> server(new TestStunServer());
if (server->Initialize(address_family)) if (server->Initialize(address_family))
return nullptr; return nullptr;
@ -341,7 +340,7 @@ UniquePtr<TestStunServer> TestStunServer::Create(int address_family) {
NR_ASYNC_WAIT(fd, NR_ASYNC_WAIT_READ, &TestStunServer::readable_cb, server.get()); NR_ASYNC_WAIT(fd, NR_ASYNC_WAIT_READ, &TestStunServer::readable_cb, server.get());
return server; return server.forget();
} }
void TestStunServer::ConfigurePort(uint16_t port) { void TestStunServer::ConfigurePort(uint16_t port) {
@ -355,19 +354,21 @@ TestStunServer* TestStunServer::GetInstance(int address_family) {
instance = Create(address_family); instance = Create(address_family);
MOZ_ASSERT(instance); MOZ_ASSERT(instance);
return instance.get(); return instance;
case AF_INET6: case AF_INET6:
if (!instance6) if (!instance6)
instance6 = Create(address_family); instance6 = Create(address_family);
return instance6.get(); return instance6;
default: default:
MOZ_CRASH(); MOZ_CRASH();
} }
} }
void TestStunServer::ShutdownInstance() { void TestStunServer::ShutdownInstance() {
delete instance;
instance = nullptr; instance = nullptr;
delete instance6;
instance6 = nullptr; instance6 = nullptr;
} }
@ -536,19 +537,21 @@ TestStunTcpServer* TestStunTcpServer::GetInstance(int address_family) {
instance = Create(address_family); instance = Create(address_family);
MOZ_ASSERT(instance); MOZ_ASSERT(instance);
return instance.get(); return instance;
case AF_INET6: case AF_INET6:
if (!instance6) if (!instance6)
instance6 = Create(address_family); instance6 = Create(address_family);
return instance6.get(); return instance6;
default: default:
MOZ_CRASH(); MOZ_CRASH();
} }
} }
void TestStunTcpServer::ShutdownInstance() { void TestStunTcpServer::ShutdownInstance() {
delete instance;
instance = nullptr; instance = nullptr;
delete instance6;
instance6 = nullptr; instance6 = nullptr;
} }
@ -628,10 +631,10 @@ void TestStunTcpServer::accept_cb(NR_SOCKET s, int how, void *cb_arg) {
NR_ASYNC_WAIT(fd, NR_ASYNC_WAIT_READ, &TestStunServer::readable_cb, server); NR_ASYNC_WAIT(fd, NR_ASYNC_WAIT_READ, &TestStunServer::readable_cb, server);
} }
UniquePtr<TestStunTcpServer> TestStunTcpServer::Create(int address_family) { TestStunTcpServer* TestStunTcpServer::Create(int address_family) {
NR_reg_init(NR_REG_MODE_LOCAL); NR_reg_init(NR_REG_MODE_LOCAL);
UniquePtr<TestStunTcpServer> server(new TestStunTcpServer()); ScopedDeletePtr<TestStunTcpServer> server(new TestStunTcpServer());
if (server->Initialize(address_family)) { if (server->Initialize(address_family)) {
return nullptr; return nullptr;
@ -645,7 +648,7 @@ void TestStunTcpServer::accept_cb(NR_SOCKET s, int how, void *cb_arg) {
NR_ASYNC_WAIT(fd, NR_ASYNC_WAIT_READ, &TestStunTcpServer::accept_cb, server.get()); NR_ASYNC_WAIT(fd, NR_ASYNC_WAIT_READ, &TestStunTcpServer::accept_cb, server.get());
return server; return server.forget();
} }
TestStunTcpServer::~TestStunTcpServer() { TestStunTcpServer::~TestStunTcpServer() {

View File

@ -13,7 +13,6 @@
#include <string> #include <string>
#include "prio.h" #include "prio.h"
#include "nsError.h" #include "nsError.h"
#include "mozilla/UniquePtr.h"
typedef struct nr_stun_server_ctx_ nr_stun_server_ctx; typedef struct nr_stun_server_ctx_ nr_stun_server_ctx;
typedef struct nr_socket_ nr_socket; typedef struct nr_socket_ nr_socket;
@ -32,7 +31,7 @@ class TestStunServer {
// to |GetInstance| (possibly following a |ShutdownInstance| call) // to |GetInstance| (possibly following a |ShutdownInstance| call)
static void ConfigurePort(uint16_t port); static void ConfigurePort(uint16_t port);
// AF_INET, AF_INET6 // AF_INET, AF_INET6
static UniquePtr<TestStunServer> Create(int address_family); static TestStunServer *Create(int address_family);
virtual ~TestStunServer(); virtual ~TestStunServer();
@ -90,8 +89,8 @@ class TestStunServer {
void *timer_handle_; void *timer_handle_;
std::map<std::string, uint32_t> received_ct_; std::map<std::string, uint32_t> received_ct_;
static UniquePtr<TestStunServer> instance; static TestStunServer *instance;
static UniquePtr<TestStunServer> instance6; static TestStunServer *instance6;
static uint16_t instance_port; static uint16_t instance_port;
}; };
@ -111,10 +110,10 @@ class TestStunTcpServer: public TestStunServer {
private: private:
virtual int TryOpenListenSocket(nr_local_addr *addr, uint16_t port); virtual int TryOpenListenSocket(nr_local_addr *addr, uint16_t port);
static UniquePtr<TestStunTcpServer> Create(int address_family); static TestStunTcpServer *Create(int address_family);
static UniquePtr<TestStunTcpServer> instance; static TestStunTcpServer *instance;
static UniquePtr<TestStunTcpServer> instance6; static TestStunTcpServer *instance6;
static uint16_t instance_port; static uint16_t instance_port;
std::map<NR_SOCKET, nr_socket*> connections_; std::map<NR_SOCKET, nr_socket*> connections_;

View File

@ -49,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "nss.h" #include "nss.h"
#include "ssl.h" #include "ssl.h"
#include "mozilla/Scoped.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "nsXPCOM.h" #include "nsXPCOM.h"

View File

@ -35,14 +35,14 @@ TransportFlow::~TransportFlow() {
// destroy it simultaneously. The conversion to an nsAutoPtr // destroy it simultaneously. The conversion to an nsAutoPtr
// ensures automatic destruction of the queue at exit of // ensures automatic destruction of the queue at exit of
// DestroyFinal. // DestroyFinal.
nsAutoPtr<std::deque<TransportLayer*>> layers_tmp(layers_.release()); nsAutoPtr<std::deque<TransportLayer*> > layers_tmp(layers_.forget());
RUN_ON_THREAD(target_, RUN_ON_THREAD(target_,
WrapRunnableNM(&TransportFlow::DestroyFinal, layers_tmp), WrapRunnableNM(&TransportFlow::DestroyFinal, layers_tmp),
NS_DISPATCH_NORMAL); NS_DISPATCH_NORMAL);
} }
void TransportFlow::DestroyFinal(nsAutoPtr<std::deque<TransportLayer *> > layers) { void TransportFlow::DestroyFinal(nsAutoPtr<std::deque<TransportLayer *> > layers) {
ClearLayers(layers.get()); ClearLayers(layers);
} }
void TransportFlow::ClearLayers(std::queue<TransportLayer *>* layers) { void TransportFlow::ClearLayers(std::queue<TransportLayer *>* layers) {
@ -61,7 +61,7 @@ void TransportFlow::ClearLayers(std::deque<TransportLayer *>* layers) {
nsresult TransportFlow::PushLayer(TransportLayer *layer) { nsresult TransportFlow::PushLayer(TransportLayer *layer) {
CheckThread(); CheckThread();
UniquePtr<TransportLayer> layer_tmp(layer); // Destroy on failure. ScopedDeletePtr<TransportLayer> layer_tmp(layer); // Destroy on failure.
// Don't allow pushes once we are in error state. // Don't allow pushes once we are in error state.
if (state_ == TransportLayer::TS_ERROR) { if (state_ == TransportLayer::TS_ERROR) {
@ -90,7 +90,7 @@ nsresult TransportFlow::PushLayer(TransportLayer *layer) {
old_layer->SignalStateChange.disconnect(this); old_layer->SignalStateChange.disconnect(this);
old_layer->SignalPacketReceived.disconnect(this); old_layer->SignalPacketReceived.disconnect(this);
} }
layers_->push_front(layer_tmp.release()); layers_->push_front(layer_tmp.forget());
layer->Inserted(this, old_layer); layer->Inserted(this, old_layer);
layer->SignalStateChange.connect(this, &TransportFlow::StateChange); layer->SignalStateChange.connect(this, &TransportFlow::StateChange);
@ -146,11 +146,11 @@ nsresult TransportFlow::PushLayers(nsAutoPtr<std::queue<TransportLayer *> > laye
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
// Destroy any layers we could not push. // Destroy any layers we could not push.
ClearLayers(layers.get()); ClearLayers(layers);
// Now destroy the rest of the flow, because it's no longer // Now destroy the rest of the flow, because it's no longer
// in an acceptable state. // in an acceptable state.
ClearLayers(layers_.get()); ClearLayers(layers_);
// Set ourselves to have failed. // Set ourselves to have failed.
StateChangeInt(TransportLayer::TS_ERROR); StateChangeInt(TransportLayer::TS_ERROR);

View File

@ -15,7 +15,7 @@
#include "nscore.h" #include "nscore.h"
#include "nsISupportsImpl.h" #include "nsISupportsImpl.h"
#include "mozilla/UniquePtr.h" #include "mozilla/Scoped.h"
#include "transportlayer.h" #include "transportlayer.h"
#include "m_cpp_utils.h" #include "m_cpp_utils.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
@ -135,7 +135,7 @@ class TransportFlow final : public nsISupports,
std::string id_; std::string id_;
TransportLayer::State state_; TransportLayer::State state_;
UniquePtr<std::deque<TransportLayer *>> layers_; ScopedDeletePtr<std::deque<TransportLayer *> > layers_;
nsCOMPtr<nsIEventTarget> target_; nsCOMPtr<nsIEventTarget> target_;
}; };

View File

@ -463,7 +463,7 @@ bool TransportLayerDtls::Setup() {
MOZ_MTLOG(ML_ERROR, "DTLS layer with nothing below. This is useless"); MOZ_MTLOG(ML_ERROR, "DTLS layer with nothing below. This is useless");
return false; return false;
} }
nspr_io_adapter_ = MakeUnique<TransportLayerNSPRAdapter>(downward_); nspr_io_adapter_ = new TransportLayerNSPRAdapter(downward_);
if (!identity_) { if (!identity_) {
MOZ_MTLOG(ML_ERROR, "Can't start DTLS without an identity"); MOZ_MTLOG(ML_ERROR, "Can't start DTLS without an identity");

View File

@ -15,7 +15,7 @@
#include "sigslot.h" #include "sigslot.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h" #include "mozilla/Scoped.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIEventTarget.h" #include "nsIEventTarget.h"
#include "nsITimer.h" #include "nsITimer.h"
@ -177,7 +177,7 @@ class TransportLayerDtls final : public TransportLayer {
// Must delete nspr_io_adapter after ssl_fd_ b/c ssl_fd_ causes an alert // Must delete nspr_io_adapter after ssl_fd_ b/c ssl_fd_ causes an alert
// (ssl_fd_ contains an un-owning pointer to nspr_io_adapter_) // (ssl_fd_ contains an un-owning pointer to nspr_io_adapter_)
UniquePtr<TransportLayerNSPRAdapter> nspr_io_adapter_; ScopedDeletePtr<TransportLayerNSPRAdapter> nspr_io_adapter_;
ScopedPRFileDesc ssl_fd_; ScopedPRFileDesc ssl_fd_;
ScopedCERTCertificate peer_cert_; ScopedCERTCertificate peer_cert_;

View File

@ -15,6 +15,7 @@
#include "sigslot.h" #include "sigslot.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/Scoped.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIEventTarget.h" #include "nsIEventTarget.h"
#include "nsITimer.h" #include "nsITimer.h"

View File

@ -8,6 +8,7 @@
#include <vector> #include <vector>
#include "mozilla/Move.h" #include "mozilla/Move.h"
#include "mozilla/Scoped.h"
#include "mozilla/SyncRunnable.h" #include "mozilla/SyncRunnable.h"
#include "VideoConduit.h" #include "VideoConduit.h"
#include "AudioConduit.h" #include "AudioConduit.h"

View File

@ -12,6 +12,7 @@
#include "MediaCodec.h" #include "MediaCodec.h"
#include "WebrtcMediaCodecVP8VideoCodec.h" #include "WebrtcMediaCodecVP8VideoCodec.h"
#include "AndroidJNIWrapper.h" #include "AndroidJNIWrapper.h"
#include "mozilla/Scoped.h"
#include "mozilla/ArrayUtils.h" #include "mozilla/ArrayUtils.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "mozilla/Monitor.h" #include "mozilla/Monitor.h"

View File

@ -513,10 +513,11 @@ void MediaPipeline::RtpPacketReceived(TransportLayer *layer,
} }
// Make a copy rather than cast away constness // Make a copy rather than cast away constness
auto inner_data = MakeUnique<unsigned char[]>(len); ScopedDeletePtr<unsigned char> inner_data(
memcpy(inner_data.get(), data, len); new unsigned char[len]);
memcpy(inner_data, data, len);
int out_len = 0; int out_len = 0;
nsresult res = rtp_.recv_srtp_->UnprotectRtp(inner_data.get(), nsresult res = rtp_.recv_srtp_->UnprotectRtp(inner_data,
len, len, &out_len); len, len, &out_len);
if (!NS_SUCCEEDED(res)) { if (!NS_SUCCEEDED(res)) {
char tmp[16]; char tmp[16];
@ -535,7 +536,7 @@ void MediaPipeline::RtpPacketReceived(TransportLayer *layer,
MOZ_MTLOG(ML_DEBUG, description_ << " received RTP packet."); MOZ_MTLOG(ML_DEBUG, description_ << " received RTP packet.");
increment_rtp_packets_received(out_len); increment_rtp_packets_received(out_len);
(void)conduit_->ReceivedRTPPacket(inner_data.get(), out_len); // Ignore error codes (void)conduit_->ReceivedRTPPacket(inner_data, out_len); // Ignore error codes
} }
void MediaPipeline::RtcpPacketReceived(TransportLayer *layer, void MediaPipeline::RtcpPacketReceived(TransportLayer *layer,
@ -571,11 +572,12 @@ void MediaPipeline::RtcpPacketReceived(TransportLayer *layer,
} }
// Make a copy rather than cast away constness // Make a copy rather than cast away constness
auto inner_data = MakeUnique<unsigned char[]>(len); ScopedDeletePtr<unsigned char> inner_data(
memcpy(inner_data.get(), data, len); new unsigned char[len]);
memcpy(inner_data, data, len);
int out_len; int out_len;
nsresult res = rtcp_.recv_srtp_->UnprotectRtcp(inner_data.get(), nsresult res = rtcp_.recv_srtp_->UnprotectRtcp(inner_data,
len, len,
len, len,
&out_len); &out_len);
@ -586,7 +588,7 @@ void MediaPipeline::RtcpPacketReceived(TransportLayer *layer,
// We do not filter RTCP for send pipelines, since the webrtc.org code for // We do not filter RTCP for send pipelines, since the webrtc.org code for
// senders already has logic to ignore RRs that do not apply. // senders already has logic to ignore RRs that do not apply.
if (filter_ && direction_ == RECEIVE) { if (filter_ && direction_ == RECEIVE) {
if (!filter_->FilterSenderReport(inner_data.get(), out_len)) { if (!filter_->FilterSenderReport(inner_data, out_len)) {
MOZ_MTLOG(ML_NOTICE, "Dropping rtcp packet"); MOZ_MTLOG(ML_NOTICE, "Dropping rtcp packet");
return; return;
} }
@ -597,7 +599,7 @@ void MediaPipeline::RtcpPacketReceived(TransportLayer *layer,
MOZ_ASSERT(rtcp_.recv_srtp_); // This should never happen MOZ_ASSERT(rtcp_.recv_srtp_); // This should never happen
(void)conduit_->ReceivedRTCPPacket(inner_data.get(), out_len); // Ignore error codes (void)conduit_->ReceivedRTCPPacket(inner_data, out_len); // Ignore error codes
} }
bool MediaPipeline::IsRtp(const unsigned char *data, size_t len) { bool MediaPipeline::IsRtp(const unsigned char *data, size_t len) {

View File

@ -125,10 +125,10 @@ JsepCodecDescToCodecConfig(const JsepCodecDescription& aCodec,
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
UniquePtr<VideoCodecConfigH264> h264Config; ScopedDeletePtr<VideoCodecConfigH264> h264Config;
if (desc.mName == "H264") { if (desc.mName == "H264") {
h264Config = MakeUnique<VideoCodecConfigH264>(); h264Config = new VideoCodecConfigH264;
size_t spropSize = sizeof(h264Config->sprop_parameter_sets); size_t spropSize = sizeof(h264Config->sprop_parameter_sets);
strncpy(h264Config->sprop_parameter_sets, strncpy(h264Config->sprop_parameter_sets,
desc.mSpropParameterSets.c_str(), desc.mSpropParameterSets.c_str(),
@ -141,7 +141,7 @@ JsepCodecDescToCodecConfig(const JsepCodecDescription& aCodec,
VideoCodecConfig* configRaw; VideoCodecConfig* configRaw;
configRaw = new VideoCodecConfig( configRaw = new VideoCodecConfig(
pt, desc.mName, desc.mConstraints, h264Config.get()); pt, desc.mName, desc.mConstraints, h264Config);
configRaw->mAckFbTypes = desc.mAckFbTypes; configRaw->mAckFbTypes = desc.mAckFbTypes;
configRaw->mNackFbTypes = desc.mNackFbTypes; configRaw->mNackFbTypes = desc.mNackFbTypes;

View File

@ -157,11 +157,12 @@ public:
bool addStunServer(const std::string& addr, uint16_t port, bool addStunServer(const std::string& addr, uint16_t port,
const char* transport) const char* transport)
{ {
UniquePtr<NrIceStunServer> server(NrIceStunServer::Create(addr, port, transport)); NrIceStunServer* server(NrIceStunServer::Create(addr, port, transport));
if (!server) { if (!server) {
return false; return false;
} }
addStunServer(*server); addStunServer(*server);
delete server;
return true; return true;
} }
bool addTurnServer(const std::string& addr, uint16_t port, bool addTurnServer(const std::string& addr, uint16_t port,
@ -173,12 +174,13 @@ public:
// username and password. Bug # ??? // username and password. Bug # ???
std::vector<unsigned char> password(pwd.begin(), pwd.end()); std::vector<unsigned char> password(pwd.begin(), pwd.end());
UniquePtr<NrIceTurnServer> server(NrIceTurnServer::Create(addr, port, username, password, NrIceTurnServer* server(NrIceTurnServer::Create(addr, port, username, password,
transport)); transport));
if (!server) { if (!server) {
return false; return false;
} }
addTurnServer(*server); addTurnServer(*server);
delete server;
return true; return true;
} }
void addStunServer(const NrIceStunServer& server) { mStunServers.push_back (server); } void addStunServer(const NrIceStunServer& server) { mStunServers.push_back (server); }

View File

@ -11,8 +11,8 @@
using namespace std; using namespace std;
#include "mozilla/Scoped.h"
#include "mozilla/SyncRunnable.h" #include "mozilla/SyncRunnable.h"
#include "mozilla/UniquePtr.h"
#include <MediaConduitInterface.h> #include <MediaConduitInterface.h>
#include "GmpVideoCodec.h" #include "GmpVideoCodec.h"
#include "nsIEventTarget.h" #include "nsIEventTarget.h"
@ -92,8 +92,8 @@ public:
{ {
mSession = aSession; mSession = aSession;
mLen = ((width * height) * 3 / 2); mLen = ((width * height) * 3 / 2);
mFrame = mozilla::MakeUnique<uint8_t[]>(mLen); mFrame = (uint8_t*) PR_MALLOC(mLen);
memset(mFrame.get(), COLOR, mLen); memset(mFrame, COLOR, mLen);
numFrames = 121; numFrames = 121;
} }
@ -101,7 +101,7 @@ public:
{ {
do do
{ {
mSession->SendVideoFrame(reinterpret_cast<unsigned char*>(mFrame.get()), mSession->SendVideoFrame((unsigned char*)mFrame,
mLen, mLen,
width, width,
height, height,
@ -115,7 +115,7 @@ public:
private: private:
RefPtr<mozilla::VideoSessionConduit> mSession; RefPtr<mozilla::VideoSessionConduit> mSession;
mozilla::UniquePtr<uint8_t[]> mFrame; mozilla::ScopedDeletePtr<uint8_t> mFrame;
int mLen; int mLen;
int width, height; int width, height;
int rate; int rate;
@ -290,8 +290,8 @@ void AudioSendAndReceive::GenerateMusic(short* buf, int len)
//Hardcoded for 16 bit samples for now //Hardcoded for 16 bit samples for now
void AudioSendAndReceive::GenerateAndReadSamples() void AudioSendAndReceive::GenerateAndReadSamples()
{ {
mozilla::UniquePtr<int16_t[]> audioInput(mozilla::MakeUnique<int16_t []>(PLAYOUT_SAMPLE_LENGTH)); mozilla::ScopedDeletePtr<int16_t> audioInput(new int16_t [PLAYOUT_SAMPLE_LENGTH]);
mozilla::UniquePtr<int16_t[]> audioOutput(mozilla::MakeUnique<int16_t []>(PLAYOUT_SAMPLE_LENGTH)); mozilla::ScopedDeletePtr<int16_t> audioOutput(new int16_t [PLAYOUT_SAMPLE_LENGTH]);
short* inbuf; short* inbuf;
int sampleLengthDecoded = 0; int sampleLengthDecoded = 0;
unsigned int SAMPLES = (PLAYOUT_SAMPLE_FREQUENCY * 10); //10 seconds unsigned int SAMPLES = (PLAYOUT_SAMPLE_FREQUENCY * 10); //10 seconds

View File

@ -1688,19 +1688,19 @@ class SignalingAgentTest : public ::testing::Test {
} }
bool CreateAgent(const std::string stun_addr, uint16_t stun_port) { bool CreateAgent(const std::string stun_addr, uint16_t stun_port) {
UniquePtr<SignalingAgent> agent( ScopedDeletePtr<SignalingAgent> agent(
new SignalingAgent("agent", stun_addr, stun_port)); new SignalingAgent("agent", stun_addr, stun_port));
agent->Init(); agent->Init();
agents_.push_back(agent.release()); agents_.push_back(agent.forget());
return true; return true;
} }
void CreateAgentNoInit() { void CreateAgentNoInit() {
UniquePtr<SignalingAgent> agent(new SignalingAgent("agent")); ScopedDeletePtr<SignalingAgent> agent(new SignalingAgent("agent"));
agents_.push_back(agent.release()); agents_.push_back(agent.forget());
} }
SignalingAgent *agent(size_t i) { SignalingAgent *agent(size_t i) {
@ -1749,8 +1749,8 @@ public:
if (init_) if (init_)
return; return;
a1_ = MakeUnique<SignalingAgent>(callerName, stun_addr_, stun_port_); a1_ = new SignalingAgent(callerName, stun_addr_, stun_port_);
a2_ = MakeUnique<SignalingAgent>(calleeName, stun_addr_, stun_port_); a2_ = new SignalingAgent(calleeName, stun_addr_, stun_port_);
if (GetParam() == "no_bundle") { if (GetParam() == "no_bundle") {
a1_->SetBundleEnabled(false); a1_->SetBundleEnabled(false);
@ -2170,8 +2170,8 @@ public:
protected: protected:
bool init_; bool init_;
UniquePtr<SignalingAgent> a1_; // Canonically "caller" ScopedDeletePtr<SignalingAgent> a1_; // Canonically "caller"
UniquePtr<SignalingAgent> a2_; // Canonically "callee" ScopedDeletePtr<SignalingAgent> a2_; // Canonically "callee"
std::string stun_addr_; std::string stun_addr_;
uint16_t stun_port_; uint16_t stun_port_;
}; };