Bug 857439 Part 4: Fix MediaStreamList wrapping r=bz

This commit is contained in:
David Zbarsky 2013-04-19 04:49:21 -04:00
parent 2fc3ae46ec
commit 00b6a3274d
3 changed files with 7 additions and 11 deletions

View File

@ -28,22 +28,18 @@ MediaStreamList::~MediaStreamList()
}
JSObject*
MediaStreamList::WrapObject(JSContext* cx, ErrorResult& error)
MediaStreamList::WrapObject(JSContext* cx, bool* aTookOwnership)
{
#ifdef MOZILLA_INTERNAL_API
nsCOMPtr<nsIScriptGlobalObject> global =
do_QueryInterface(mPeerConnection->GetWindow());
JSObject* scope = global->GetGlobalJSObject();
if (!scope) {
error.Throw(NS_ERROR_FAILURE);
return nullptr;
}
JSAutoCompartment ac(cx, scope);
JSObject* obj = MediaStreamListBinding::Wrap(cx, scope, this);
if (!obj) {
error.Throw(NS_ERROR_FAILURE);
}
JSObject* obj = MediaStreamListBinding::Wrap(cx, scope, this, aTookOwnership);
return obj;
#else
return nullptr;

View File

@ -35,7 +35,7 @@ public:
MediaStreamList(sipcc::PeerConnectionImpl* peerConnection, StreamType type);
~MediaStreamList();
JSObject* WrapObject(JSContext* cx, ErrorResult& error);
JSObject* WrapObject(JSContext* cx, bool* aTookOwnership);
DOMMediaStream* IndexedGetter(uint32_t index, bool& found);
uint32_t Length();

View File

@ -1466,11 +1466,11 @@ GetStreams(JSContext* cx, PeerConnectionImpl* peerConnection,
{
nsAutoPtr<MediaStreamList> list(new MediaStreamList(peerConnection, type));
ErrorResult rv;
JSObject* obj = list->WrapObject(cx, rv);
if (rv.Failed()) {
bool tookOwnership = false;
JSObject* obj = list->WrapObject(cx, &tookOwnership);
if (!tookOwnership) {
streams->setNull();
return rv.ErrorCode();
return NS_ERROR_FAILURE;
}
// Transfer ownership to the binding.