Bug 1203900 - Fix cycle collection and array buffer creation bug in the implementation of MediaKeyMessageEvent, MediaEncryptedEvent, and BluetoothLeDeviceEvent. r=bz
authorJocelyn Liu <joliu@mozilla.com>
Fri, 11 Sep 2015 21:05:00 +0200
changeset 294915 9a3bfacb1a093a26e6dc3532182875ba4b1dbccb
parent 294914 7441b33a26e71618d60848d31e2f461e1a2f6c71
child 294916 a3994f4ac9df331302de2a4a7fb421ae8bbe2024
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1203900
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1203900 - Fix cycle collection and array buffer creation bug in the implementation of MediaKeyMessageEvent, MediaEncryptedEvent, and BluetoothLeDeviceEvent. r=bz
dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.cpp
dom/media/eme/MediaEncryptedEvent.cpp
dom/media/eme/MediaKeyMessageEvent.cpp
--- a/dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.cpp
+++ b/dom/bluetooth/common/webapi/BluetoothLeDeviceEvent.cpp
@@ -28,16 +28,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(BluetoothLeDeviceEvent, Event)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mScanRecord)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BluetoothLeDeviceEvent, Event)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mDevice)
   tmp->mScanRecord = nullptr;
+  mozilla::DropJSObjects(this);
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothLeDeviceEvent)
 NS_INTERFACE_MAP_END_INHERITING(Event)
 
 BluetoothLeDeviceEvent::BluetoothLeDeviceEvent(
   mozilla::dom::EventTarget* aOwner)
   : Event(aOwner, nullptr, nullptr)
@@ -124,16 +125,17 @@ BluetoothLeDeviceEvent::Rssi() const
 void
 BluetoothLeDeviceEvent::GetScanRecord(
   JSContext* cx,
   JS::MutableHandle<JSObject*> aScanRecord,
   ErrorResult& aRv)
 {
   if (!mScanRecord) {
     mScanRecord = ArrayBuffer::Create(cx,
+                                      this,
                                       mRawScanRecord.Length(),
                                       mRawScanRecord.Elements());
     if (!mScanRecord) {
       aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
       return;
     }
     mRawScanRecord.Clear();
   }
--- a/dom/media/eme/MediaEncryptedEvent.cpp
+++ b/dom/media/eme/MediaEncryptedEvent.cpp
@@ -23,16 +23,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MediaEncryptedEvent, Event)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mInitData)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MediaEncryptedEvent, Event)
   tmp->mInitData = nullptr;
+  mozilla::DropJSObjects(this);
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MediaEncryptedEvent)
 NS_INTERFACE_MAP_END_INHERITING(Event)
 
 MediaEncryptedEvent::MediaEncryptedEvent(EventTarget* aOwner)
   : Event(aOwner, nullptr, nullptr)
 {
@@ -107,16 +108,17 @@ MediaEncryptedEvent::GetInitDataType(nsS
 
 void
 MediaEncryptedEvent::GetInitData(JSContext* cx,
                                  JS::MutableHandle<JSObject*> aData,
                                  ErrorResult& aRv)
 {
   if (mRawInitData.Length()) {
     mInitData = ArrayBuffer::Create(cx,
+                                    this,
                                     mRawInitData.Length(),
                                     mRawInitData.Elements());
     if (!mInitData) {
       aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
       return;
     }
     mRawInitData.Clear();
   }
--- a/dom/media/eme/MediaKeyMessageEvent.cpp
+++ b/dom/media/eme/MediaKeyMessageEvent.cpp
@@ -27,16 +27,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MediaKeyMessageEvent, Event)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mMessage)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MediaKeyMessageEvent, Event)
   tmp->mMessage = nullptr;
+  mozilla::DropJSObjects(this);
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MediaKeyMessageEvent)
 NS_INTERFACE_MAP_END_INHERITING(Event)
 
 MediaKeyMessageEvent::MediaKeyMessageEvent(EventTarget* aOwner)
   : Event(aOwner, nullptr, nullptr)
 {
@@ -104,16 +105,17 @@ MediaKeyMessageEvent::Constructor(const 
 
 void
 MediaKeyMessageEvent::GetMessage(JSContext* cx,
                                  JS::MutableHandle<JSObject*> aMessage,
                                  ErrorResult& aRv)
 {
   if (!mMessage) {
     mMessage = ArrayBuffer::Create(cx,
+                                   this,
                                    mRawMessage.Length(),
                                    mRawMessage.Elements());
     if (!mMessage) {
       aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
       return;
     }
     mRawMessage.Clear();
   }