mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 867459: Root toolkit/ r=terrence
This commit is contained in:
parent
fc7eb30f67
commit
3ad1dacd45
@ -41,8 +41,8 @@ Module::~Module()
|
|||||||
static JSBool
|
static JSBool
|
||||||
SealObjectAndPrototype(JSContext* cx, JSObject* parent, const char* name)
|
SealObjectAndPrototype(JSContext* cx, JSObject* parent, const char* name)
|
||||||
{
|
{
|
||||||
JS::Value prop;
|
JS::Rooted<JS::Value> prop(cx);
|
||||||
if (!JS_GetProperty(cx, parent, name, &prop))
|
if (!JS_GetProperty(cx, parent, name, prop.address()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (prop.isUndefined()) {
|
if (prop.isUndefined()) {
|
||||||
@ -50,16 +50,16 @@ SealObjectAndPrototype(JSContext* cx, JSObject* parent, const char* name)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject* obj = JSVAL_TO_OBJECT(prop);
|
JS::Rooted<JSObject*> obj(cx, prop.toObjectOrNull());
|
||||||
if (!JS_GetProperty(cx, obj, "prototype", &prop))
|
if (!JS_GetProperty(cx, obj, "prototype", prop.address()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
JSObject* prototype = JSVAL_TO_OBJECT(prop);
|
JS::Rooted<JSObject*> prototype(cx, prop.toObjectOrNull());
|
||||||
return JS_FreezeObject(cx, obj) && JS_FreezeObject(cx, prototype);
|
return JS_FreezeObject(cx, obj) && JS_FreezeObject(cx, prototype);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
InitAndSealPerfMeasurementClass(JSContext* cx, JSObject* global)
|
InitAndSealPerfMeasurementClass(JSContext* cx, JS::Handle<JSObject*> global)
|
||||||
{
|
{
|
||||||
// Init the PerfMeasurement class
|
// Init the PerfMeasurement class
|
||||||
if (!JS::RegisterPerfMeasurement(cx, global))
|
if (!JS::RegisterPerfMeasurement(cx, global))
|
||||||
|
@ -228,8 +228,8 @@ GetURIFromJSObject(JSContext* aCtx,
|
|||||||
JSObject* aObject,
|
JSObject* aObject,
|
||||||
const char* aProperty)
|
const char* aProperty)
|
||||||
{
|
{
|
||||||
JS::Value uriVal;
|
JS::Rooted<JS::Value> uriVal(aCtx);
|
||||||
JSBool rc = JS_GetProperty(aCtx, aObject, aProperty, &uriVal);
|
JSBool rc = JS_GetProperty(aCtx, aObject, aProperty, uriVal.address());
|
||||||
NS_ENSURE_TRUE(rc, nullptr);
|
NS_ENSURE_TRUE(rc, nullptr);
|
||||||
|
|
||||||
if (!JSVAL_IS_PRIMITIVE(uriVal)) {
|
if (!JSVAL_IS_PRIMITIVE(uriVal)) {
|
||||||
@ -263,8 +263,8 @@ GetStringFromJSObject(JSContext* aCtx,
|
|||||||
const char* aProperty,
|
const char* aProperty,
|
||||||
nsString& _string)
|
nsString& _string)
|
||||||
{
|
{
|
||||||
JS::Value val;
|
JS::Rooted<JS::Value> val(aCtx);
|
||||||
JSBool rc = JS_GetProperty(aCtx, aObject, aProperty, &val);
|
JSBool rc = JS_GetProperty(aCtx, aObject, aProperty, val.address());
|
||||||
if (!rc || JSVAL_IS_VOID(val) ||
|
if (!rc || JSVAL_IS_VOID(val) ||
|
||||||
!(JSVAL_IS_NULL(val) || JSVAL_IS_STRING(val))) {
|
!(JSVAL_IS_NULL(val) || JSVAL_IS_STRING(val))) {
|
||||||
_string.SetIsVoid(true);
|
_string.SetIsVoid(true);
|
||||||
@ -304,8 +304,8 @@ GetIntFromJSObject(JSContext* aCtx,
|
|||||||
const char* aProperty,
|
const char* aProperty,
|
||||||
IntType* _int)
|
IntType* _int)
|
||||||
{
|
{
|
||||||
JS::Value value;
|
JS::Rooted<JS::Value> value(aCtx);
|
||||||
JSBool rc = JS_GetProperty(aCtx, aObject, aProperty, &value);
|
JSBool rc = JS_GetProperty(aCtx, aObject, aProperty, value.address());
|
||||||
NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED);
|
||||||
if (JSVAL_IS_VOID(value)) {
|
if (JSVAL_IS_VOID(value)) {
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
@ -345,8 +345,8 @@ GetJSObjectFromArray(JSContext* aCtx,
|
|||||||
NS_PRECONDITION(JS_IsArrayObject(aCtx, aArray),
|
NS_PRECONDITION(JS_IsArrayObject(aCtx, aArray),
|
||||||
"Must provide an object that is an array!");
|
"Must provide an object that is an array!");
|
||||||
|
|
||||||
JS::Value value;
|
JS::Rooted<JS::Value> value(aCtx);
|
||||||
JSBool rc = JS_GetElement(aCtx, aArray, aIndex, &value);
|
JSBool rc = JS_GetElement(aCtx, aArray, aIndex, value.address());
|
||||||
NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED);
|
||||||
NS_ENSURE_ARG(!JSVAL_IS_PRIMITIVE(value));
|
NS_ENSURE_ARG(!JSVAL_IS_PRIMITIVE(value));
|
||||||
*_rooter = JSVAL_TO_OBJECT(value);
|
*_rooter = JSVAL_TO_OBJECT(value);
|
||||||
@ -2506,9 +2506,9 @@ History::UpdatePlaces(const JS::Value& aPlaceInfos,
|
|||||||
NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(aPlaceInfos), NS_ERROR_INVALID_ARG);
|
NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(aPlaceInfos), NS_ERROR_INVALID_ARG);
|
||||||
|
|
||||||
uint32_t infosLength = 1;
|
uint32_t infosLength = 1;
|
||||||
JSObject* infos;
|
JS::Rooted<JSObject*> infos(aCtx);
|
||||||
if (JS_IsArrayObject(aCtx, JSVAL_TO_OBJECT(aPlaceInfos))) {
|
if (JS_IsArrayObject(aCtx, aPlaceInfos.toObjectOrNull())) {
|
||||||
infos = JSVAL_TO_OBJECT(aPlaceInfos);
|
infos = aPlaceInfos.toObjectOrNull();
|
||||||
(void)JS_GetArrayLength(aCtx, infos, &infosLength);
|
(void)JS_GetArrayLength(aCtx, infos, &infosLength);
|
||||||
NS_ENSURE_ARG(infosLength > 0);
|
NS_ENSURE_ARG(infosLength > 0);
|
||||||
}
|
}
|
||||||
@ -2524,8 +2524,8 @@ History::UpdatePlaces(const JS::Value& aPlaceInfos,
|
|||||||
|
|
||||||
nsTArray<VisitData> visitData;
|
nsTArray<VisitData> visitData;
|
||||||
for (uint32_t i = 0; i < infosLength; i++) {
|
for (uint32_t i = 0; i < infosLength; i++) {
|
||||||
JSObject* info;
|
JS::Rooted<JSObject*> info(aCtx);
|
||||||
nsresult rv = GetJSObjectFromArray(aCtx, infos, i, &info);
|
nsresult rv = GetJSObjectFromArray(aCtx, infos, i, info.address());
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri = GetURIFromJSObject(aCtx, info, "uri");
|
nsCOMPtr<nsIURI> uri = GetURIFromJSObject(aCtx, info, "uri");
|
||||||
@ -2557,10 +2557,10 @@ History::UpdatePlaces(const JS::Value& aPlaceInfos,
|
|||||||
nsString title;
|
nsString title;
|
||||||
GetStringFromJSObject(aCtx, info, "title", title);
|
GetStringFromJSObject(aCtx, info, "title", title);
|
||||||
|
|
||||||
JSObject* visits = NULL;
|
JS::Rooted<JSObject*> visits(aCtx, nullptr);
|
||||||
{
|
{
|
||||||
JS::Value visitsVal;
|
JS::Rooted<JS::Value> visitsVal(aCtx);
|
||||||
JSBool rc = JS_GetProperty(aCtx, info, "visits", &visitsVal);
|
JSBool rc = JS_GetProperty(aCtx, info, "visits", visitsVal.address());
|
||||||
NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED);
|
||||||
if (!JSVAL_IS_PRIMITIVE(visitsVal)) {
|
if (!JSVAL_IS_PRIMITIVE(visitsVal)) {
|
||||||
visits = JSVAL_TO_OBJECT(visitsVal);
|
visits = JSVAL_TO_OBJECT(visitsVal);
|
||||||
@ -2578,8 +2578,8 @@ History::UpdatePlaces(const JS::Value& aPlaceInfos,
|
|||||||
// Check each visit, and build our array of VisitData objects.
|
// Check each visit, and build our array of VisitData objects.
|
||||||
visitData.SetCapacity(visitData.Length() + visitsLength);
|
visitData.SetCapacity(visitData.Length() + visitsLength);
|
||||||
for (uint32_t j = 0; j < visitsLength; j++) {
|
for (uint32_t j = 0; j < visitsLength; j++) {
|
||||||
JSObject* visit;
|
JS::Rooted<JSObject*> visit(aCtx);
|
||||||
rv = GetJSObjectFromArray(aCtx, visits, j, &visit);
|
rv = GetJSObjectFromArray(aCtx, visits, j, visit.address());
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
VisitData& data = *visitData.AppendElement(VisitData(uri));
|
VisitData& data = *visitData.AppendElement(VisitData(uri));
|
||||||
|
@ -75,10 +75,10 @@ PlaceInfo::GetVisits(JSContext* aContext,
|
|||||||
{
|
{
|
||||||
// TODO bug 625913 when we use this in situations that have more than one
|
// TODO bug 625913 when we use this in situations that have more than one
|
||||||
// visit here, we will likely want to make this cache the value.
|
// visit here, we will likely want to make this cache the value.
|
||||||
JSObject* visits = JS_NewArrayObject(aContext, 0, NULL);
|
JS::Rooted<JSObject*> visits(aContext, JS_NewArrayObject(aContext, 0, NULL));
|
||||||
NS_ENSURE_TRUE(visits, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(visits, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
JSObject* global = JS_GetGlobalForScopeChain(aContext);
|
JS::Rooted<JSObject*> global(aContext, JS_GetGlobalForScopeChain(aContext));
|
||||||
NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);
|
||||||
|
|
||||||
nsCOMPtr<nsIXPConnect> xpc = mozilla::services::GetXPConnect();
|
nsCOMPtr<nsIXPConnect> xpc = mozilla::services::GetXPConnect();
|
||||||
@ -90,8 +90,8 @@ PlaceInfo::GetVisits(JSContext* aContext,
|
|||||||
getter_AddRefs(wrapper));
|
getter_AddRefs(wrapper));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
JSObject* jsobj;
|
JS::Rooted<JSObject*> jsobj(aContext);
|
||||||
rv = wrapper->GetJSObject(&jsobj);
|
rv = wrapper->GetJSObject(jsobj.address());
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
JS::Value wrappedVisit = OBJECT_TO_JSVAL(jsobj);
|
JS::Value wrappedVisit = OBJECT_TO_JSVAL(jsobj);
|
||||||
|
|
||||||
|
@ -786,7 +786,7 @@ CalculateProcessCreationTimestamp()
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsAppStartup::GetStartupInfo(JSContext* aCx, JS::Value* aRetval)
|
nsAppStartup::GetStartupInfo(JSContext* aCx, JS::Value* aRetval)
|
||||||
{
|
{
|
||||||
JSObject *obj = JS_NewObject(aCx, NULL, NULL, NULL);
|
JS::Rooted<JSObject*> obj(aCx, JS_NewObject(aCx, NULL, NULL, NULL));
|
||||||
*aRetval = OBJECT_TO_JSVAL(obj);
|
*aRetval = OBJECT_TO_JSVAL(obj);
|
||||||
|
|
||||||
PRTime ProcessCreationTimestamp = StartupTimeline::Get(StartupTimeline::PROCESS_CREATION);
|
PRTime ProcessCreationTimestamp = StartupTimeline::Get(StartupTimeline::PROCESS_CREATION);
|
||||||
|
@ -518,7 +518,7 @@ GetHistogramByEnumId(Telemetry::ID id, Histogram **ret)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FillRanges(JSContext *cx, JSObject *array, Histogram *h)
|
FillRanges(JSContext *cx, JS::Handle<JSObject*> array, Histogram *h)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < h->bucket_count(); i++) {
|
for (size_t i = 0; i < h->bucket_count(); i++) {
|
||||||
if (!JS_DefineElement(cx, array, i, INT_TO_JSVAL(h->ranges(i)), NULL, NULL, JSPROP_ENUMERATE))
|
if (!JS_DefineElement(cx, array, i, INT_TO_JSVAL(h->ranges(i)), NULL, NULL, JSPROP_ENUMERATE))
|
||||||
@ -568,22 +568,20 @@ ReflectHistogramAndSamples(JSContext *cx, JSObject *obj, Histogram *h,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const size_t count = h->bucket_count();
|
const size_t count = h->bucket_count();
|
||||||
JSObject *rarray = JS_NewArrayObject(cx, count, nullptr);
|
JS::Rooted<JSObject*> rarray(cx, JS_NewArrayObject(cx, count, nullptr));
|
||||||
if (!rarray) {
|
if (!rarray) {
|
||||||
return REFLECT_FAILURE;
|
return REFLECT_FAILURE;
|
||||||
}
|
}
|
||||||
JS::AutoObjectRooter aroot(cx, rarray);
|
|
||||||
if (!(FillRanges(cx, rarray, h)
|
if (!(FillRanges(cx, rarray, h)
|
||||||
&& JS_DefineProperty(cx, obj, "ranges", OBJECT_TO_JSVAL(rarray),
|
&& JS_DefineProperty(cx, obj, "ranges", OBJECT_TO_JSVAL(rarray),
|
||||||
NULL, NULL, JSPROP_ENUMERATE))) {
|
NULL, NULL, JSPROP_ENUMERATE))) {
|
||||||
return REFLECT_FAILURE;
|
return REFLECT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *counts_array = JS_NewArrayObject(cx, count, NULL);
|
JS::Rooted<JSObject*> counts_array(cx, JS_NewArrayObject(cx, count, nullptr));
|
||||||
if (!counts_array) {
|
if (!counts_array) {
|
||||||
return REFLECT_FAILURE;
|
return REFLECT_FAILURE;
|
||||||
}
|
}
|
||||||
JS::AutoObjectRooter croot(cx, counts_array);
|
|
||||||
if (!JS_DefineProperty(cx, obj, "counts", OBJECT_TO_JSVAL(counts_array),
|
if (!JS_DefineProperty(cx, obj, "counts", OBJECT_TO_JSVAL(counts_array),
|
||||||
NULL, NULL, JSPROP_ENUMERATE)) {
|
NULL, NULL, JSPROP_ENUMERATE)) {
|
||||||
return REFLECT_FAILURE;
|
return REFLECT_FAILURE;
|
||||||
@ -656,10 +654,9 @@ JSHistogram_Snapshot(JSContext *cx, unsigned argc, JS::Value *vp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Histogram *h = static_cast<Histogram*>(JS_GetPrivate(obj));
|
Histogram *h = static_cast<Histogram*>(JS_GetPrivate(obj));
|
||||||
JSObject *snapshot = JS_NewObject(cx, nullptr, nullptr, nullptr);
|
JS::Rooted<JSObject*> snapshot(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
|
||||||
if (!snapshot)
|
if (!snapshot)
|
||||||
return JS_FALSE;
|
return JS_FALSE;
|
||||||
JS::AutoObjectRooter sroot(cx, snapshot);
|
|
||||||
|
|
||||||
switch (ReflectHistogramSnapshot(cx, snapshot, h)) {
|
switch (ReflectHistogramSnapshot(cx, snapshot, h)) {
|
||||||
case REFLECT_FAILURE:
|
case REFLECT_FAILURE:
|
||||||
@ -699,10 +696,9 @@ WrapAndReturnHistogram(Histogram *h, JSContext *cx, JS::Value *ret)
|
|||||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub
|
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub
|
||||||
};
|
};
|
||||||
|
|
||||||
JSObject *obj = JS_NewObject(cx, &JSHistogram_class, NULL, NULL);
|
JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, &JSHistogram_class, NULL, NULL));
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
JS::AutoObjectRooter root(cx, obj);
|
|
||||||
if (!(JS_DefineFunction(cx, obj, "add", JSHistogram_Add, 1, 0)
|
if (!(JS_DefineFunction(cx, obj, "add", JSHistogram_Add, 1, 0)
|
||||||
&& JS_DefineFunction(cx, obj, "snapshot", JSHistogram_Snapshot, 0, 0)
|
&& JS_DefineFunction(cx, obj, "snapshot", JSHistogram_Snapshot, 0, 0)
|
||||||
&& JS_DefineFunction(cx, obj, "clear", JSHistogram_Clear, 0, 0))) {
|
&& JS_DefineFunction(cx, obj, "clear", JSHistogram_Clear, 0, 0))) {
|
||||||
@ -1001,11 +997,10 @@ TelemetryImpl::ReflectSQL(const SlowSQLEntryType *entry,
|
|||||||
JS::Value hitCount = UINT_TO_JSVAL(stat->hitCount);
|
JS::Value hitCount = UINT_TO_JSVAL(stat->hitCount);
|
||||||
JS::Value totalTime = UINT_TO_JSVAL(stat->totalTime);
|
JS::Value totalTime = UINT_TO_JSVAL(stat->totalTime);
|
||||||
|
|
||||||
JSObject *arrayObj = JS_NewArrayObject(cx, 0, nullptr);
|
JS::Rooted<JSObject*> arrayObj(cx, JS_NewArrayObject(cx, 0, nullptr));
|
||||||
if (!arrayObj) {
|
if (!arrayObj) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
JS::AutoObjectRooter root(cx, arrayObj);
|
|
||||||
return (JS_SetElement(cx, arrayObj, 0, &hitCount)
|
return (JS_SetElement(cx, arrayObj, 0, &hitCount)
|
||||||
&& JS_SetElement(cx, arrayObj, 1, &totalTime)
|
&& JS_SetElement(cx, arrayObj, 1, &totalTime)
|
||||||
&& JS_DefineProperty(cx, obj,
|
&& JS_DefineProperty(cx, obj,
|
||||||
@ -1032,10 +1027,9 @@ bool
|
|||||||
TelemetryImpl::AddSQLInfo(JSContext *cx, JSObject *rootObj, bool mainThread,
|
TelemetryImpl::AddSQLInfo(JSContext *cx, JSObject *rootObj, bool mainThread,
|
||||||
bool privateSQL)
|
bool privateSQL)
|
||||||
{
|
{
|
||||||
JSObject *statsObj = JS_NewObject(cx, NULL, NULL, NULL);
|
JS::Rooted<JSObject*> statsObj(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||||
if (!statsObj)
|
if (!statsObj)
|
||||||
return false;
|
return false;
|
||||||
JS::AutoObjectRooter root(cx, statsObj);
|
|
||||||
|
|
||||||
AutoHashtable<SlowSQLEntryType> &sqlMap =
|
AutoHashtable<SlowSQLEntryType> &sqlMap =
|
||||||
(privateSQL ? mPrivateSQL : mSanitizedSQL);
|
(privateSQL ? mPrivateSQL : mSanitizedSQL);
|
||||||
@ -1283,7 +1277,7 @@ TelemetryImpl::UnregisterAddonHistograms(const nsACString &id)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
TelemetryImpl::GetHistogramSnapshots(JSContext *cx, JS::Value *ret)
|
TelemetryImpl::GetHistogramSnapshots(JSContext *cx, JS::Value *ret)
|
||||||
{
|
{
|
||||||
JSObject *root_obj = JS_NewObject(cx, NULL, NULL, NULL);
|
JS::Rooted<JSObject*> root_obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||||
if (!root_obj)
|
if (!root_obj)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
*ret = OBJECT_TO_JSVAL(root_obj);
|
*ret = OBJECT_TO_JSVAL(root_obj);
|
||||||
@ -1316,11 +1310,10 @@ TelemetryImpl::GetHistogramSnapshots(JSContext *cx, JS::Value *ret)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *hobj = JS_NewObject(cx, NULL, NULL, NULL);
|
JS::Rooted<JSObject*> hobj(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||||
if (!hobj) {
|
if (!hobj) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
JS::AutoObjectRooter root(cx, hobj);
|
|
||||||
switch (ReflectHistogramSnapshot(cx, hobj, h)) {
|
switch (ReflectHistogramSnapshot(cx, hobj, h)) {
|
||||||
case REFLECT_CORRUPT:
|
case REFLECT_CORRUPT:
|
||||||
// We can still hit this case even if ShouldReflectHistograms
|
// We can still hit this case even if ShouldReflectHistograms
|
||||||
@ -1379,12 +1372,11 @@ TelemetryImpl::AddonHistogramReflector(AddonHistogramEntryType *entry,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *snapshot = JS_NewObject(cx, NULL, NULL, NULL);
|
JS::Rooted<JSObject*> snapshot(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||||
if (!snapshot) {
|
if (!snapshot) {
|
||||||
// Just consider this to be skippable.
|
// Just consider this to be skippable.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
JS::AutoObjectRooter r(cx, snapshot);
|
|
||||||
switch (ReflectHistogramSnapshot(cx, snapshot, info.h)) {
|
switch (ReflectHistogramSnapshot(cx, snapshot, info.h)) {
|
||||||
case REFLECT_FAILURE:
|
case REFLECT_FAILURE:
|
||||||
case REFLECT_CORRUPT:
|
case REFLECT_CORRUPT:
|
||||||
@ -1407,11 +1399,10 @@ TelemetryImpl::AddonReflector(AddonEntryType *entry,
|
|||||||
JSContext *cx, JSObject *obj)
|
JSContext *cx, JSObject *obj)
|
||||||
{
|
{
|
||||||
const nsACString &addonId = entry->GetKey();
|
const nsACString &addonId = entry->GetKey();
|
||||||
JSObject *subobj = JS_NewObject(cx, NULL, NULL, NULL);
|
JS::Rooted<JSObject*> subobj(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||||
if (!subobj) {
|
if (!subobj) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
JS::AutoObjectRooter r(cx, subobj);
|
|
||||||
|
|
||||||
AddonHistogramMapType *map = entry->mData;
|
AddonHistogramMapType *map = entry->mData;
|
||||||
if (!(map->ReflectIntoJS(AddonHistogramReflector, cx, subobj)
|
if (!(map->ReflectIntoJS(AddonHistogramReflector, cx, subobj)
|
||||||
@ -1428,11 +1419,10 @@ NS_IMETHODIMP
|
|||||||
TelemetryImpl::GetAddonHistogramSnapshots(JSContext *cx, JS::Value *ret)
|
TelemetryImpl::GetAddonHistogramSnapshots(JSContext *cx, JS::Value *ret)
|
||||||
{
|
{
|
||||||
*ret = JSVAL_VOID;
|
*ret = JSVAL_VOID;
|
||||||
JSObject *obj = JS_NewObject(cx, NULL, NULL, NULL);
|
JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
JS::AutoObjectRooter r(cx, obj);
|
|
||||||
|
|
||||||
if (!mAddonMap.ReflectIntoJS(AddonReflector, cx, obj)) {
|
if (!mAddonMap.ReflectIntoJS(AddonReflector, cx, obj)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
@ -1444,7 +1434,7 @@ TelemetryImpl::GetAddonHistogramSnapshots(JSContext *cx, JS::Value *ret)
|
|||||||
bool
|
bool
|
||||||
TelemetryImpl::GetSQLStats(JSContext *cx, JS::Value *ret, bool includePrivateSql)
|
TelemetryImpl::GetSQLStats(JSContext *cx, JS::Value *ret, bool includePrivateSql)
|
||||||
{
|
{
|
||||||
JSObject *root_obj = JS_NewObject(cx, NULL, NULL, NULL);
|
JS::Rooted<JSObject*> root_obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||||
if (!root_obj)
|
if (!root_obj)
|
||||||
return false;
|
return false;
|
||||||
*ret = OBJECT_TO_JSVAL(root_obj);
|
*ret = OBJECT_TO_JSVAL(root_obj);
|
||||||
@ -1491,14 +1481,14 @@ TelemetryImpl::GetChromeHangs(JSContext *cx, JS::Value *ret)
|
|||||||
MutexAutoLock hangReportMutex(mHangReportsMutex);
|
MutexAutoLock hangReportMutex(mHangReportsMutex);
|
||||||
|
|
||||||
const CombinedStacks& stacks = mHangReports.GetStacks();
|
const CombinedStacks& stacks = mHangReports.GetStacks();
|
||||||
JSObject *fullReportObj = CreateJSStackObject(cx, stacks);
|
JS::Rooted<JSObject*> fullReportObj(cx, CreateJSStackObject(cx, stacks));
|
||||||
if (!fullReportObj) {
|
if (!fullReportObj) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ret = OBJECT_TO_JSVAL(fullReportObj);
|
*ret = OBJECT_TO_JSVAL(fullReportObj);
|
||||||
|
|
||||||
JSObject *durationArray = JS_NewArrayObject(cx, 0, nullptr);
|
JS::Rooted<JSObject*> durationArray(cx, JS_NewArrayObject(cx, 0, nullptr));
|
||||||
if (!durationArray) {
|
if (!durationArray) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
@ -1522,12 +1512,12 @@ TelemetryImpl::GetChromeHangs(JSContext *cx, JS::Value *ret)
|
|||||||
|
|
||||||
static JSObject *
|
static JSObject *
|
||||||
CreateJSStackObject(JSContext *cx, const CombinedStacks &stacks) {
|
CreateJSStackObject(JSContext *cx, const CombinedStacks &stacks) {
|
||||||
JSObject *ret = JS_NewObject(cx, nullptr, nullptr, nullptr);
|
JS::Rooted<JSObject*> ret(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *moduleArray = JS_NewArrayObject(cx, 0, nullptr);
|
JS::Rooted<JSObject*> moduleArray(cx, JS_NewArrayObject(cx, 0, nullptr));
|
||||||
if (!moduleArray) {
|
if (!moduleArray) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1544,7 +1534,7 @@ CreateJSStackObject(JSContext *cx, const CombinedStacks &stacks) {
|
|||||||
const Telemetry::ProcessedStack::Module& module =
|
const Telemetry::ProcessedStack::Module& module =
|
||||||
stacks.GetModule(moduleIndex);
|
stacks.GetModule(moduleIndex);
|
||||||
|
|
||||||
JSObject *moduleInfoArray = JS_NewArrayObject(cx, 0, nullptr);
|
JS::Rooted<JSObject*> moduleInfoArray(cx, JS_NewArrayObject(cx, 0, nullptr));
|
||||||
if (!moduleInfoArray) {
|
if (!moduleInfoArray) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1576,7 +1566,7 @@ CreateJSStackObject(JSContext *cx, const CombinedStacks &stacks) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObject *reportArray = JS_NewArrayObject(cx, 0, nullptr);
|
JS::Rooted<JSObject*> reportArray(cx, JS_NewArrayObject(cx, 0, nullptr));
|
||||||
if (!reportArray) {
|
if (!reportArray) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1590,7 +1580,7 @@ CreateJSStackObject(JSContext *cx, const CombinedStacks &stacks) {
|
|||||||
const size_t length = stacks.GetStackCount();
|
const size_t length = stacks.GetStackCount();
|
||||||
for (size_t i = 0; i < length; ++i) {
|
for (size_t i = 0; i < length; ++i) {
|
||||||
// Represent call stack PCs as (module index, offset) pairs.
|
// Represent call stack PCs as (module index, offset) pairs.
|
||||||
JSObject *pcArray = JS_NewArrayObject(cx, 0, nullptr);
|
JS::Rooted<JSObject*> pcArray(cx, JS_NewArrayObject(cx, 0, nullptr));
|
||||||
if (!pcArray) {
|
if (!pcArray) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1604,7 +1594,7 @@ CreateJSStackObject(JSContext *cx, const CombinedStacks &stacks) {
|
|||||||
const uint32_t pcCount = stack.size();
|
const uint32_t pcCount = stack.size();
|
||||||
for (size_t pcIndex = 0; pcIndex < pcCount; ++pcIndex) {
|
for (size_t pcIndex = 0; pcIndex < pcCount; ++pcIndex) {
|
||||||
const Telemetry::ProcessedStack::Frame& frame = stack[pcIndex];
|
const Telemetry::ProcessedStack::Frame& frame = stack[pcIndex];
|
||||||
JSObject *framePair = JS_NewArrayObject(cx, 0, nullptr);
|
JS::Rooted<JSObject*> framePair(cx, JS_NewArrayObject(cx, 0, nullptr));
|
||||||
if (!framePair) {
|
if (!framePair) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1797,7 +1787,7 @@ NS_IMETHODIMP
|
|||||||
TelemetryImpl::GetRegisteredHistograms(JSContext *cx, JS::Value *ret)
|
TelemetryImpl::GetRegisteredHistograms(JSContext *cx, JS::Value *ret)
|
||||||
{
|
{
|
||||||
size_t count = ArrayLength(gHistograms);
|
size_t count = ArrayLength(gHistograms);
|
||||||
JSObject *info = JS_NewObject(cx, NULL, NULL, NULL);
|
JS::Rooted<JSObject*> info(cx, JS_NewObject(cx, NULL, NULL, NULL));
|
||||||
if (!info)
|
if (!info)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
JS::AutoObjectRooter root(cx, info);
|
JS::AutoObjectRooter root(cx, info);
|
||||||
|
Loading…
Reference in New Issue
Block a user