Bug 784739 - Switch from NULL to nullptr in startupcache/; r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Wed, 31 Jul 2013 11:44:43 -0400
changeset 153069 417f4d51eba24f710542bdb1f540dc656e57710b
parent 153068 ac758cadd0341af4ea6a8e9763cf6b668a677734
child 153070 dfd50d4b9ac6e38ce413fe1713003a04510605c4
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs784739
milestone25.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 784739 - Switch from NULL to nullptr in startupcache/; r=ehsan
startupcache/StartupCache.cpp
startupcache/StartupCacheModule.cpp
startupcache/test/TestStartupCache.cpp
--- a/startupcache/StartupCache.cpp
+++ b/startupcache/StartupCache.cpp
@@ -121,17 +121,17 @@ StartupCache::InitSingleton()
 }
 
 StartupCache* StartupCache::gStartupCache;
 bool StartupCache::gShutdownInitiated;
 bool StartupCache::gIgnoreDiskCache;
 enum StartupCache::TelemetrifyAge StartupCache::gPostFlushAgeAction = StartupCache::IGNORE_AGE;
 
 StartupCache::StartupCache() 
-  : mArchive(NULL), mStartupWriteInitiated(false), mWriteThread(NULL),
+  : mArchive(nullptr), mStartupWriteInitiated(false), mWriteThread(nullptr),
     mMappingMemoryReporter(nullptr), mDataMemoryReporter(nullptr) { }
 
 StartupCache::~StartupCache() 
 {
   if (mTimer) {
     mTimer->Cancel();
   }
 
@@ -249,17 +249,17 @@ StartupCache::Init()
  */
 nsresult
 StartupCache::LoadArchive(enum TelemetrifyAge flag)
 {
   if (gIgnoreDiskCache)
     return NS_ERROR_FAILURE;
 
   bool exists;
-  mArchive = NULL;
+  mArchive = nullptr;
   nsresult rv = mFile->Exists(&exists);
   if (NS_FAILED(rv) || !exists)
     return NS_ERROR_FILE_NOT_FOUND;
   
   mArchive = new nsZipArchive();
   rv = mArchive->OpenArchive(mFile);
   if (NS_FAILED(rv) || flag == IGNORE_AGE)
     return rv;
@@ -476,34 +476,34 @@ StartupCache::WriteToDisk()
   CacheWriteHolder holder;
   holder.stream = stream;
   holder.writer = zipW;
   holder.time = now;
 
   mTable.Enumerate(CacheCloseHelper, &holder);
 
   // Close the archive so Windows doesn't choke.
-  mArchive = NULL;
+  mArchive = nullptr;
   zipW->Close();
 
   // We succesfully wrote the archive to disk; mark the disk file as trusted
   gIgnoreDiskCache = false;
 
   // Our reader's view of the archive is outdated now, reload it.
   LoadArchive(gPostFlushAgeAction);
   
   return;
 }
 
 void
 StartupCache::InvalidateCache() 
 {
   WaitOnWriteThread();
   mTable.Clear();
-  mArchive = NULL;
+  mArchive = nullptr;
   nsresult rv = mFile->Remove(false);
   if (NS_FAILED(rv) && rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
       rv != NS_ERROR_FILE_NOT_FOUND) {
     gIgnoreDiskCache = true;
     mozilla::Telemetry::Accumulate(Telemetry::STARTUP_CACHE_INVALID, true);
     return;
   }
   gIgnoreDiskCache = false;
@@ -526,17 +526,17 @@ StartupCache::IgnoreDiskCache()
 void
 StartupCache::WaitOnWriteThread()
 {
   NS_ASSERTION(NS_IsMainThread(), "Startup cache should only wait for io thread on main thread");
   if (!mWriteThread || mWriteThread == PR_GetCurrentThread())
     return;
 
   PR_JoinThread(mWriteThread);
-  mWriteThread = NULL;
+  mWriteThread = nullptr;
 }
 
 void 
 StartupCache::ThreadedWrite(void *aClosure)
 {
   PR_SetCurrentThreadName("StartupCache");
   gStartupCache->WriteToDisk();
 }
@@ -546,17 +546,17 @@ StartupCache::ThreadedWrite(void *aClosu
  * can avoid a slow shutdown. After writing out the cache, the zipreader is
  * reloaded on the worker thread.
  */
 void
 StartupCache::WriteTimeout(nsITimer *aTimer, void *aClosure)
 {
   gStartupCache->mWriteThread = PR_CreateThread(PR_USER_THREAD,
                                                 StartupCache::ThreadedWrite,
-                                                NULL,
+                                                nullptr,
                                                 PR_PRIORITY_NORMAL,
                                                 PR_LOCAL_THREAD,
                                                 PR_JOINABLE_THREAD,
                                                 0);
 }
 
 // We don't want to refcount StartupCache, so we'll just
 // hold a ref to this and pass it to observerService instead.
--- a/startupcache/StartupCacheModule.cpp
+++ b/startupcache/StartupCacheModule.cpp
@@ -18,28 +18,28 @@
 using namespace mozilla::scache;
 
 // XXX Need help with guard for ENABLE_TEST
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(StartupCacheWrapper,
                                          StartupCacheWrapper::GetSingleton)
 NS_DEFINE_NAMED_CID(NS_STARTUPCACHE_CID);
 
 static const mozilla::Module::CIDEntry kStartupCacheCIDs[] = {
-    { &kNS_STARTUPCACHE_CID, false, NULL, StartupCacheWrapperConstructor },
-    { NULL }
+    { &kNS_STARTUPCACHE_CID, false, nullptr, StartupCacheWrapperConstructor },
+    { nullptr }
 };
 
 static const mozilla::Module::ContractIDEntry kStartupCacheContracts[] = {
     { "@mozilla.org/startupcache/cache;1", &kNS_STARTUPCACHE_CID },
-    { NULL }
+    { nullptr }
 };
 
 static const mozilla::Module kStartupCacheModule = {
     mozilla::Module::kVersion,
     kStartupCacheCIDs,
     kStartupCacheContracts,
-    NULL,
-    NULL,
-    NULL,
-    NULL
+    nullptr,
+    nullptr,
+    nullptr,
+    nullptr
 };
 
 NSMODULE_DEFN(StartupCacheModule) = &kStartupCacheModule;
--- a/startupcache/test/TestStartupCache.cpp
+++ b/startupcache/test/TestStartupCache.cpp
@@ -86,17 +86,17 @@ TestStartupWriteRead() {
     return NS_ERROR_FAILURE;
   } else {
     passed("got a pointer?");
   }
   sc->InvalidateCache();
   
   const char* buf = "Market opportunities for BeardBook";
   const char* id = "id";
-  char* outbufPtr = NULL;
+  char* outbufPtr = nullptr;
   nsAutoArrayPtr<char> outbuf;  
   uint32_t len;
   
   rv = sc->PutBuffer(id, buf, strlen(buf) + 1);
   NS_ENSURE_SUCCESS(rv, rv);
   
   rv = sc->GetBuffer(id, &outbufPtr, &len);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -115,17 +115,17 @@ TestStartupWriteRead() {
   return NS_OK;
 }
 
 nsresult
 TestWriteInvalidateRead() {
   nsresult rv;
   const char* buf = "BeardBook competitive analysis";
   const char* id = "id";
-  char* outbuf = NULL;
+  char* outbuf = nullptr;
   uint32_t len;
   nsCOMPtr<nsIStartupCache> sc
     = do_GetService("@mozilla.org/startupcache/cache;1", &rv);
   sc->InvalidateCache();
 
   rv = sc->PutBuffer(id, buf, strlen(buf) + 1);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -191,31 +191,31 @@ TestWriteObject() {
   }
   nsCOMPtr<nsISupports> objQI(do_QueryInterface(obj));
   rv = objectOutput->WriteObject(objQI, true);
   if (NS_FAILED(rv)) {
     fail("failed to write object");
     return rv;
   }
 
-  char* bufPtr = NULL;
+  char* bufPtr = nullptr;
   nsAutoArrayPtr<char> buf;
   uint32_t len;
   NewBufferFromStorageStream(storageStream, &bufPtr, &len);
   buf = bufPtr;
 
   // Since this is a post-startup write, it should be written and
   // available.
   rv = sc->PutBuffer(id, buf, len);
   if (NS_FAILED(rv)) {
     fail("failed to insert input stream");
     return rv;
   }
     
-  char* buf2Ptr = NULL;
+  char* buf2Ptr = nullptr;
   nsAutoArrayPtr<char> buf2;
   uint32_t len2;
   nsCOMPtr<nsIObjectInputStream> objectInput;
   rv = sc->GetBuffer(id, &buf2Ptr, &len2);
   if (NS_FAILED(rv)) {
     fail("failed to retrieve buffer");
     return rv;
   }
@@ -310,17 +310,17 @@ nsresult
 TestIgnoreDiskCache(nsIFile* profileDir) {
   nsresult rv;
   nsCOMPtr<nsIStartupCache> sc
     = do_GetService("@mozilla.org/startupcache/cache;1", &rv);
   sc->InvalidateCache();
   
   const char* buf = "Get a Beardbook app for your smartphone";
   const char* id = "id";
-  char* outbuf = NULL;
+  char* outbuf = nullptr;
   uint32_t len;
   
   rv = sc->PutBuffer(id, buf, strlen(buf) + 1);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = sc->ResetStartupWriteTimer();
   rv = WaitForStartupTimer();
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -356,17 +356,17 @@ TestEarlyShutdown() {
   nsresult rv;
   nsCOMPtr<nsIStartupCache> sc
     = do_GetService("@mozilla.org/startupcache/cache;1", &rv);
   sc->InvalidateCache();
 
   const char* buf = "Find your soul beardmate on BeardBook";
   const char* id = "id";
   uint32_t len;
-  char* outbuf = NULL;
+  char* outbuf = nullptr;
   
   sc->ResetStartupWriteTimer();
   rv = sc->PutBuffer(id, buf, strlen(buf) + 1);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIObserver> obs;
   sc->GetObserver(getter_AddRefs(obs));
   obs->Observe(nullptr, "xpcom-shutdown", nullptr);
@@ -408,23 +408,23 @@ GetHistogramCounts(const char *testmsg, 
   nsresult trv = telemetry->GetHistogramById(histogram_id, cx, h.address());
   if (NS_FAILED(trv)) {
     fail("%s: couldn't get histogram %s", testmsg, ToNewCString(histogram_id));
     return false;
   }
   passed(testmsg);
 
   Rooted<Value> snapshot_val(cx);
-  JSFunction *snapshot_fn = NULL;
+  JSFunction *snapshot_fn = nullptr;
   Rooted<Value> ss(cx);
   return (JS_GetProperty(cx, JSVAL_TO_OBJECT(h), "snapshot",
                          &snapshot_val)
           && (snapshot_fn = JS_ValueToFunction(cx, snapshot_val))
           && JS::Call(cx, JSVAL_TO_OBJECT(h),
-                      snapshot_fn, 0, NULL, &ss)
+                      snapshot_fn, 0, nullptr, &ss)
           && JS_GetProperty(cx, JSVAL_TO_OBJECT(ss), "counts", counts));
 }
 
 nsresult
 CompareCountArrays(JSContext *cx, JSObject *aBefore, JSObject *aAfter)
 {
   uint32_t before_size, after_size;
   JS::RootedObject before(cx, aBefore);
@@ -517,17 +517,17 @@ int main(int argc, char** argv)
     "global", JSCLASS_NEW_RESOLVE | JSCLASS_GLOBAL_FLAGS | JSCLASS_HAS_PRIVATE,
     JS_PropertyStub,  JS_DeletePropertyStub,
     JS_PropertyStub,  JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub,
     JS_ConvertStub
   };
   JSObject *glob = nullptr;
   if (use_js)
-    glob = JS_NewGlobalObject(cx, &global_class, NULL);
+    glob = JS_NewGlobalObject(cx, &global_class, nullptr);
   if (!glob)
     use_js = false;
   mozilla::Maybe<JSAutoCompartment> ac;
   if (use_js)
     ac.construct(cx, glob);
   if (use_js && !JS_InitStandardClasses(cx, glob))
     use_js = false;