Bug 844323 - Prelude part 4: Use 's' prefix on class-static variables, not 'g'. r=me
authorJustin Lebar <justin.lebar@gmail.com>
Thu, 25 Apr 2013 20:53:26 -0400
changeset 140871 77960f39133f4cb5052ef4e8241efdfa747750ca
parent 140870 7b93ed92f8fe6a702377745b4e3473f02dd904ea
child 140872 38fee265dbe51dcacf9fe0b693727ea3e4faac4d
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs844323
milestone23.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 844323 - Prelude part 4: Use 's' prefix on class-static variables, not 'g'. r=me
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -189,19 +189,19 @@ MemoryReportRequestParent::Recv__delete_
     return true;
 }
 
 MemoryReportRequestParent::~MemoryReportRequestParent()
 {
     MOZ_COUNT_DTOR(MemoryReportRequestParent);
 }
 
-nsDataHashtable<nsStringHashKey, ContentParent*>* ContentParent::gAppContentParents;
-nsTArray<ContentParent*>* ContentParent::gNonAppContentParents;
-nsTArray<ContentParent*>* ContentParent::gPrivateContent;
+nsDataHashtable<nsStringHashKey, ContentParent*>* ContentParent::sAppContentParents;
+nsTArray<ContentParent*>* ContentParent::sNonAppContentParents;
+nsTArray<ContentParent*>* ContentParent::sPrivateContent;
 
 // This is true when subprocess launching is enabled.  This is the
 // case between StartUp() and ShutDown() or JoinAllSubprocesses().
 static bool sCanLaunchSubprocesses;
 
 // The first content child has ID 1, so the chrome process can have ID 0.
 static uint64_t gContentChildID = 1;
 
@@ -371,37 +371,37 @@ ContentParent::JoinAllSubprocesses()
     }
 
     sCanLaunchSubprocesses = false;
 }
 
 /*static*/ already_AddRefed<ContentParent>
 ContentParent::GetNewOrUsed(bool aForBrowserElement)
 {
-    if (!gNonAppContentParents)
-        gNonAppContentParents = new nsTArray<ContentParent*>();
+    if (!sNonAppContentParents)
+        sNonAppContentParents = new nsTArray<ContentParent*>();
 
     int32_t maxContentProcesses = Preferences::GetInt("dom.ipc.processCount", 1);
     if (maxContentProcesses < 1)
         maxContentProcesses = 1;
 
-    if (gNonAppContentParents->Length() >= uint32_t(maxContentProcesses)) {
-        uint32_t idx = rand() % gNonAppContentParents->Length();
-        nsRefPtr<ContentParent> p = (*gNonAppContentParents)[idx];
-        NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in gNonAppContentParents?");
+    if (sNonAppContentParents->Length() >= uint32_t(maxContentProcesses)) {
+        uint32_t idx = rand() % sNonAppContentParents->Length();
+        nsRefPtr<ContentParent> p = (*sNonAppContentParents)[idx];
+        NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in sNonAppContentParents?");
         return p.forget();
     }
 
     nsRefPtr<ContentParent> p =
         new ContentParent(/* appManifestURL = */ EmptyString(),
                           aForBrowserElement,
                           base::PRIVILEGES_DEFAULT,
                           PROCESS_PRIORITY_FOREGROUND);
     p->Init();
-    gNonAppContentParents->AppendElement(p);
+    sNonAppContentParents->AppendElement(p);
     return p.forget();
 }
 
 namespace {
 struct SpecialPermission {
     const char* perm;           // an app permission
     ChildPrivileges privs;      // the OS privilege it requires
 };
@@ -477,32 +477,32 @@ ContentParent::CreateBrowserOrApp(const 
         return nullptr;
     }
 
     // If we got here, we have an app and we're not a browser element.  ownApp
     // shouldn't be null, because we otherwise would have gone into the
     // !HasOwnApp() branch above.
     nsCOMPtr<mozIApplication> ownApp = aContext.GetOwnApp();
 
-    if (!gAppContentParents) {
-        gAppContentParents =
+    if (!sAppContentParents) {
+        sAppContentParents =
             new nsDataHashtable<nsStringHashKey, ContentParent*>();
-        gAppContentParents->Init();
+        sAppContentParents->Init();
     }
 
     // Each app gets its own ContentParent instance.
     nsAutoString manifestURL;
     if (NS_FAILED(ownApp->GetManifestURL(manifestURL))) {
         NS_ERROR("Failed to get manifest URL");
         return nullptr;
     }
 
     ProcessPriority initialPriority = GetInitialProcessPriority(aFrameElement);
 
-    nsRefPtr<ContentParent> p = gAppContentParents->Get(manifestURL);
+    nsRefPtr<ContentParent> p = sAppContentParents->Get(manifestURL);
     if (p) {
         // Check that the process is still alive and set its priority.
         // Hopefully the process won't die after this point, if this call
         // succeeds.
         if (!p->SetPriorityAndCheckIsAlive(initialPriority)) {
             p = nullptr;
         }
     }
@@ -512,17 +512,17 @@ ContentParent::CreateBrowserOrApp(const 
         p = MaybeTakePreallocatedAppProcess(manifestURL, privs,
                                             initialPriority);
         if (!p) {
             NS_WARNING("Unable to use pre-allocated app process");
             p = new ContentParent(manifestURL, /* isBrowserElement = */ false,
                                   privs, initialPriority);
             p->Init();
         }
-        gAppContentParents->Put(manifestURL, p);
+        sAppContentParents->Put(manifestURL, p);
     }
 
     nsRefPtr<TabParent> tp = new TabParent(aContext);
     tp->SetOwnerElement(aFrameElement);
     PBrowserParent* browser = p->SendPBrowserConstructor(
         tp.forget().get(), // DeallocPBrowserParent() releases this ref.
         aContext.AsIPCTabContext(),
         /* chromeFlags */ 0);
@@ -785,36 +785,36 @@ ContentParent::ShutDownProcess()
   // returned from Get*() while in the midst of shutdown.
   MarkAsDead();
 }
 
 void
 ContentParent::MarkAsDead()
 {
     if (!mAppManifestURL.IsEmpty()) {
-        if (gAppContentParents) {
-            gAppContentParents->Remove(mAppManifestURL);
-            if (!gAppContentParents->Count()) {
-                delete gAppContentParents;
-                gAppContentParents = NULL;
+        if (sAppContentParents) {
+            sAppContentParents->Remove(mAppManifestURL);
+            if (!sAppContentParents->Count()) {
+                delete sAppContentParents;
+                sAppContentParents = NULL;
             }
         }
-    } else if (gNonAppContentParents) {
-        gNonAppContentParents->RemoveElement(this);
-        if (!gNonAppContentParents->Length()) {
-            delete gNonAppContentParents;
-            gNonAppContentParents = NULL;
+    } else if (sNonAppContentParents) {
+        sNonAppContentParents->RemoveElement(this);
+        if (!sNonAppContentParents->Length()) {
+            delete sNonAppContentParents;
+            sNonAppContentParents = NULL;
         }
     }
 
-    if (gPrivateContent) {
-        gPrivateContent->RemoveElement(this);
-        if (!gPrivateContent->Length()) {
-            delete gPrivateContent;
-            gPrivateContent = NULL;
+    if (sPrivateContent) {
+        sPrivateContent->RemoveElement(this);
+        if (!sPrivateContent->Length()) {
+            delete sPrivateContent;
+            sPrivateContent = NULL;
         }
     }
 
     mIsAlive = false;
 }
 
 void
 ContentParent::OnChannelConnected(int32_t pid)
@@ -1144,27 +1144,27 @@ ContentParent::~ContentParent()
     }
 
     if (OtherProcess())
         base::CloseProcessHandle(OtherProcess());
 
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
     // We should be removed from all these lists in ActorDestroy.
-    MOZ_ASSERT(!gPrivateContent || !gPrivateContent->Contains(this));
+    MOZ_ASSERT(!sPrivateContent || !sPrivateContent->Contains(this));
     if (mAppManifestURL.IsEmpty()) {
-        MOZ_ASSERT(!gNonAppContentParents ||
-                   !gNonAppContentParents->Contains(this));
+        MOZ_ASSERT(!sNonAppContentParents ||
+                   !sNonAppContentParents->Contains(this));
     } else {
-        // In general, we expect gAppContentParents->Get(mAppManifestURL) to be
+        // In general, we expect sAppContentParents->Get(mAppManifestURL) to be
         // NULL.  But it could be that we created another ContentParent for this
         // app after we did this->ActorDestroy(), so the right check is that
         // gAppContentParent->Get(mAppManifestURL) != this.
-        MOZ_ASSERT(!gAppContentParents ||
-                   gAppContentParents->Get(mAppManifestURL) != this);
+        MOZ_ASSERT(!sAppContentParents ||
+                   sAppContentParents->Get(mAppManifestURL) != this);
     }
 }
 
 bool
 ContentParent::IsAlive()
 {
     return mIsAlive;
 }
@@ -2518,27 +2518,27 @@ ContentParent::RecvScriptError(const nsS
 
   consoleService->LogMessageWithMode(msg, nsConsoleService::SuppressLog);
   return true;
 }
 
 bool
 ContentParent::RecvPrivateDocShellsExist(const bool& aExist)
 {
-  if (!gPrivateContent)
-    gPrivateContent = new nsTArray<ContentParent*>();
+  if (!sPrivateContent)
+    sPrivateContent = new nsTArray<ContentParent*>();
   if (aExist) {
-    gPrivateContent->AppendElement(this);
+    sPrivateContent->AppendElement(this);
   } else {
-    gPrivateContent->RemoveElement(this);
-    if (!gPrivateContent->Length()) {
+    sPrivateContent->RemoveElement(this);
+    if (!sPrivateContent->Length()) {
       nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
       obs->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
-      delete gPrivateContent;
-      gPrivateContent = NULL;
+      delete sPrivateContent;
+      sPrivateContent = NULL;
     }
   }
   return true;
 }
 
 bool
 ContentParent::DoSendAsyncMessage(const nsAString& aMessage,
                                   const mozilla::dom::StructuredCloneData& aData)
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -146,19 +146,19 @@ public:
 
     uint64_t ChildID() { return mChildID; }
 
 protected:
     void OnChannelConnected(int32_t pid);
     virtual void ActorDestroy(ActorDestroyReason why);
 
 private:
-    static nsDataHashtable<nsStringHashKey, ContentParent*> *gAppContentParents;
-    static nsTArray<ContentParent*>* gNonAppContentParents;
-    static nsTArray<ContentParent*>* gPrivateContent;
+    static nsDataHashtable<nsStringHashKey, ContentParent*> *sAppContentParents;
+    static nsTArray<ContentParent*>* sNonAppContentParents;
+    static nsTArray<ContentParent*>* sPrivateContent;
 
     static void JoinProcessesIOThread(const nsTArray<ContentParent*>* aProcesses,
                                       Monitor* aMonitor, bool* aDone);
 
     static void PreallocateAppProcess();
     static void DelayedPreallocateAppProcess();
     static void ScheduleDelayedPreallocateAppProcess();