зеркало из https://github.com/mozilla/gecko-dev.git
Bug 876080. Don't use 'nativeOwnership':'owned' for MediaList. r=bzbarsky
This commit is contained in:
Родитель
adcf07edd8
Коммит
098a481f6c
|
@ -599,8 +599,6 @@ DOMInterfaces = {
|
|||
|
||||
'MediaStreamList': {
|
||||
'headerFile': 'MediaStreamList.h',
|
||||
'wrapperCache': False,
|
||||
'nativeOwnership': 'owned',
|
||||
'resultNotAddRefed': [ '__indexedGetter' ],
|
||||
'binaryNames': { '__indexedGetter': 'IndexedGetter' }
|
||||
},
|
||||
|
|
|
@ -7516,6 +7516,12 @@ class CGDescriptor(CGThing):
|
|||
|
||||
if descriptor.concrete:
|
||||
if descriptor.proxy:
|
||||
if descriptor.nativeOwnership != 'nsisupports':
|
||||
raise TypeError("We don't support non-nsISupports native classes for "
|
||||
"proxy-based bindings yet (" + descriptor.name + ")")
|
||||
if not descriptor.wrapperCache:
|
||||
raise TypeError("We need a wrappercache to support expandos for proxy-based "
|
||||
"bindings (" + descriptor.name + ")")
|
||||
cgThings.append(CGProxyIsProxy(descriptor))
|
||||
cgThings.append(CGProxyUnwrap(descriptor))
|
||||
cgThings.append(CGDOMJSProxyHandlerDOMClass(descriptor))
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "MediaStreamList.h"
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "mozilla/dom/MediaStreamListBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
#endif
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "PeerConnectionImpl.h"
|
||||
|
@ -19,33 +20,47 @@ MediaStreamList::MediaStreamList(sipcc::PeerConnectionImpl* peerConnection,
|
|||
: mPeerConnection(peerConnection),
|
||||
mType(type)
|
||||
{
|
||||
MOZ_COUNT_CTOR(mozilla::dom::MediaStreamList);
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
MediaStreamList::~MediaStreamList()
|
||||
{
|
||||
MOZ_COUNT_DTOR(mozilla::dom::MediaStreamList);
|
||||
}
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(MediaStreamList)
|
||||
#else
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MediaStreamList)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MediaStreamList)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(MediaStreamList)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
#endif
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaStreamList)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaStreamList)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaStreamList)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
JSObject*
|
||||
MediaStreamList::WrapObject(JSContext* cx, bool* aTookOwnership)
|
||||
MediaStreamList::WrapObject(JSContext* cx, JS::Handle<JSObject*> scope)
|
||||
{
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
nsCOMPtr<nsIScriptGlobalObject> global =
|
||||
do_QueryInterface(mPeerConnection->GetWindow());
|
||||
JS::Rooted<JSObject*> scope(cx, global->GetGlobalJSObject());
|
||||
if (!scope) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
JSObject* obj = MediaStreamListBinding::Wrap(cx, scope, this, aTookOwnership);
|
||||
return obj;
|
||||
return MediaStreamListBinding::Wrap(cx, scope, this);
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsISupports*
|
||||
MediaStreamList::GetParentObject()
|
||||
{
|
||||
return mPeerConnection->GetWindow();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static DOMMediaStream*
|
||||
GetStreamFromInfo(T* info, bool& found)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "nsISupportsImpl.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "jspubtd.h"
|
||||
#include "mozilla/dom/NonRefcountedDOMObject.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
#ifdef USE_FAKE_MEDIA_STREAMS
|
||||
#include "FakeMediaStreams.h"
|
||||
|
@ -24,7 +24,8 @@ class PeerConnectionImpl;
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MediaStreamList : public NonRefcountedDOMObject
|
||||
class MediaStreamList : public nsISupports,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
enum StreamType {
|
||||
|
@ -33,9 +34,14 @@ public:
|
|||
};
|
||||
|
||||
MediaStreamList(sipcc::PeerConnectionImpl* peerConnection, StreamType type);
|
||||
~MediaStreamList();
|
||||
virtual ~MediaStreamList();
|
||||
|
||||
JSObject* WrapObject(JSContext* cx, bool* aTookOwnership);
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaStreamList)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope)
|
||||
MOZ_OVERRIDE;
|
||||
nsISupports* GetParentObject();
|
||||
|
||||
DOMMediaStream* IndexedGetter(uint32_t index, bool& found);
|
||||
uint32_t Length();
|
||||
|
|
|
@ -1486,18 +1486,24 @@ static nsresult
|
|||
GetStreams(JSContext* cx, PeerConnectionImpl* peerConnection,
|
||||
MediaStreamList::StreamType type, JS::Value* streams)
|
||||
{
|
||||
nsAutoPtr<MediaStreamList> list(new MediaStreamList(peerConnection, type));
|
||||
nsRefPtr<MediaStreamList> list(new MediaStreamList(peerConnection, type));
|
||||
|
||||
bool tookOwnership = false;
|
||||
JSObject* obj = list->WrapObject(cx, &tookOwnership);
|
||||
if (!tookOwnership) {
|
||||
nsCOMPtr<nsIScriptGlobalObject> global =
|
||||
do_QueryInterface(peerConnection->GetWindow());
|
||||
JS::Rooted<JSObject*> scope(cx, global->GetGlobalJSObject());
|
||||
if (!scope) {
|
||||
streams->setNull();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
JSObject* obj = list->WrapObject(cx, scope);
|
||||
if (!obj) {
|
||||
streams->setNull();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Transfer ownership to the binding.
|
||||
streams->setObject(*obj);
|
||||
list.forget();
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче