Bug 867341 - Replace NULL with nullptr in Rooted<JSObject*> lines. r=vladan
authorSteve Fink <sfink@mozilla.com>
Thu, 02 May 2013 12:51:41 -0700
changeset 130703 e728bef882df351c8f5e7b2705c98bb4d558a2de
parent 130702 0875726579b21a321215d363ce44b8437fa96192
child 130704 e2dc6cdc1c02a124c0afe27a6123580b486a2cad
push id1579
push userphilringnalda@gmail.com
push dateSat, 04 May 2013 04:38:04 +0000
treeherderfx-team@a56432a42a41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladan
bugs867341
milestone23.0a1
Bug 867341 - Replace NULL with nullptr in Rooted<JSObject*> lines. r=vladan This is the rebased remnants of an earlier patch replacing AutoObjectRooter with Rooted<JSObject*>, after dzbarsky landed a patch doing the same thing.
toolkit/components/telemetry/Telemetry.cpp
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -691,17 +691,17 @@ WrapAndReturnHistogram(Histogram *h, JSC
 {
   static JSClass JSHistogram_class = {
     "JSHistogram",  /* name */
     JSCLASS_HAS_PRIVATE, /* flags */
     JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub
   };
 
-  JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, &JSHistogram_class, NULL, NULL));
+  JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, &JSHistogram_class, nullptr, nullptr));
   if (!obj)
     return NS_ERROR_FAILURE;
   if (!(JS_DefineFunction(cx, obj, "add", JSHistogram_Add, 1, 0)
         && JS_DefineFunction(cx, obj, "snapshot", JSHistogram_Snapshot, 0, 0)
         && JS_DefineFunction(cx, obj, "clear", JSHistogram_Clear, 0, 0))) {
     return NS_ERROR_FAILURE;
   }
   *ret = OBJECT_TO_JSVAL(obj);
@@ -1022,17 +1022,17 @@ TelemetryImpl::ReflectOtherThreadsSQL(Sl
 {
   return ReflectSQL(entry, &entry->mData.otherThreads, cx, obj);
 }
 
 bool
 TelemetryImpl::AddSQLInfo(JSContext *cx, JSObject *rootObj, bool mainThread,
                           bool privateSQL)
 {
-  JS::Rooted<JSObject*> statsObj(cx, JS_NewObject(cx, NULL, NULL, NULL));
+  JS::Rooted<JSObject*> statsObj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
   if (!statsObj)
     return false;
 
   AutoHashtable<SlowSQLEntryType> &sqlMap =
     (privateSQL ? mPrivateSQL : mSanitizedSQL);
   AutoHashtable<SlowSQLEntryType>::ReflectEntryFunc reflectFunction =
     (mainThread ? ReflectMainThreadSQL : ReflectOtherThreadsSQL);
   if(!sqlMap.ReflectIntoJS(reflectFunction, cx, statsObj)) {
@@ -1272,17 +1272,17 @@ TelemetryImpl::UnregisterAddonHistograms
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TelemetryImpl::GetHistogramSnapshots(JSContext *cx, JS::Value *ret)
 {
-  JS::Rooted<JSObject*> root_obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
+  JS::Rooted<JSObject*> root_obj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
   if (!root_obj)
     return NS_ERROR_FAILURE;
   *ret = OBJECT_TO_JSVAL(root_obj);
 
   // Ensure that all the HISTOGRAM_FLAG histograms have been created, so
   // that their values are snapshotted.
   for (size_t i = 0; i < Telemetry::HistogramCount; ++i) {
     if (gHistograms[i].histogramType == nsITelemetry::HISTOGRAM_FLAG) {
@@ -1299,23 +1299,24 @@ TelemetryImpl::GetHistogramSnapshots(JSC
   // in the loop below, to ensure that our corruption statistics don't
   // depend on histogram enumeration order.
   //
   // Of course, we hope that all of these corruption-statistics
   // histograms are not themselves corrupt...
   IdentifyCorruptHistograms(hs);
 
   // OK, now we can actually reflect things.
+  JS::Rooted<JSObject*> hobj(cx);
   for (HistogramIterator it = hs.begin(); it != hs.end(); ++it) {
     Histogram *h = *it;
     if (!ShouldReflectHistogram(h) || IsEmpty(h)) {
       continue;
     }
 
-    JS::Rooted<JSObject*> hobj(cx, JS_NewObject(cx, NULL, NULL, NULL));
+    hobj = JS_NewObject(cx, nullptr, nullptr, nullptr);
     if (!hobj) {
       return NS_ERROR_FAILURE;
     }
     switch (ReflectHistogramSnapshot(cx, hobj, h)) {
     case REFLECT_CORRUPT:
       // We can still hit this case even if ShouldReflectHistograms
       // returns true.  The histogram lies outside of our control
       // somehow; just skip it.
@@ -1367,17 +1368,17 @@ TelemetryImpl::AddonHistogramReflector(A
       return false;
     }
   }
 
   if (IsEmpty(info.h)) {
     return true;
   }
 
-  JS::Rooted<JSObject*> snapshot(cx, JS_NewObject(cx, NULL, NULL, NULL));
+  JS::Rooted<JSObject*> snapshot(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
   if (!snapshot) {
     // Just consider this to be skippable.
     return true;
   }
   switch (ReflectHistogramSnapshot(cx, snapshot, info.h)) {
   case REFLECT_FAILURE:
   case REFLECT_CORRUPT:
     return false;
@@ -1394,17 +1395,17 @@ TelemetryImpl::AddonHistogramReflector(A
   return true;
 }
 
 bool
 TelemetryImpl::AddonReflector(AddonEntryType *entry,
                               JSContext *cx, JSObject *obj)
 {
   const nsACString &addonId = entry->GetKey();
-  JS::Rooted<JSObject*> subobj(cx, JS_NewObject(cx, NULL, NULL, NULL));
+  JS::Rooted<JSObject*> subobj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
   if (!subobj) {
     return false;
   }
 
   AddonHistogramMapType *map = entry->mData;
   if (!(map->ReflectIntoJS(AddonHistogramReflector, cx, subobj)
         && JS_DefineProperty(cx, obj,
                              PromiseFlatCString(addonId).get(),
@@ -1414,32 +1415,32 @@ TelemetryImpl::AddonReflector(AddonEntry
   }
   return true;
 }
 
 NS_IMETHODIMP
 TelemetryImpl::GetAddonHistogramSnapshots(JSContext *cx, JS::Value *ret)
 {
   *ret = JSVAL_VOID;
-  JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
+  JS::Rooted<JSObject*> obj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
   if (!obj) {
     return NS_ERROR_FAILURE;
   }
 
   if (!mAddonMap.ReflectIntoJS(AddonReflector, cx, obj)) {
     return NS_ERROR_FAILURE;
   }
   *ret = OBJECT_TO_JSVAL(obj);
   return NS_OK;
 }
 
 bool
 TelemetryImpl::GetSQLStats(JSContext *cx, JS::Value *ret, bool includePrivateSql)
 {
-  JS::Rooted<JSObject*> root_obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
+  JSObject *root_obj = JS_NewObject(cx, nullptr, nullptr, nullptr);
   if (!root_obj)
     return false;
   *ret = OBJECT_TO_JSVAL(root_obj);
 
   MutexAutoLock hashMutex(mHashMutex);
   // Add info about slow SQL queries on the main thread
   if (!AddSQLInfo(cx, root_obj, true, includePrivateSql))
     return false;
@@ -1782,20 +1783,19 @@ TelemetryImpl::GetLateWrites(JSContext *
   *ret = OBJECT_TO_JSVAL(report);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TelemetryImpl::GetRegisteredHistograms(JSContext *cx, JS::Value *ret)
 {
   size_t count = ArrayLength(gHistograms);
-  JS::Rooted<JSObject*> info(cx, JS_NewObject(cx, NULL, NULL, NULL));
+  JS::Rooted<JSObject*> info(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
   if (!info)
     return NS_ERROR_FAILURE;
-  JS::AutoObjectRooter root(cx, info);
 
   for (size_t i = 0; i < count; ++i) {
     JSString *comment = JS_InternString(cx, gHistograms[i].comment());
 
     if (!(comment
           && JS_DefineProperty(cx, info, gHistograms[i].id(),
                                STRING_TO_JSVAL(comment), NULL, NULL,
                                JSPROP_ENUMERATE))) {