Bug 956258 - [cleanup] Patch 1/2: rename g* variables to s* ones, r=echou
authorBen Tian <btian@mozilla.com>
Fri, 10 Jan 2014 09:34:43 +0800
changeset 162843 1b22c75c10464d3ec68c2f4f81dd2337ad15d321
parent 162842 5995e46f8a2d27d6933fbb299365cd834922af1d
child 162844 615964c59f003ec94f59120f52b538ffc21f78b6
push id25973
push userryanvm@gmail.com
push dateFri, 10 Jan 2014 19:29:41 +0000
treeherdermozilla-central@f79cf39e525a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechou
bugs956258
milestone29.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 956258 - [cleanup] Patch 1/2: rename g* variables to s* ones, r=echou
dom/bluetooth/BluetoothService.cpp
dom/bluetooth/ipc/BluetoothChild.cpp
dom/bluetooth/ipc/BluetoothParent.cpp
dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
--- a/dom/bluetooth/BluetoothService.cpp
+++ b/dom/bluetooth/BluetoothService.cpp
@@ -78,20 +78,20 @@
 bool gBluetoothDebugFlag = false;
 
 using namespace mozilla;
 using namespace mozilla::dom;
 USING_BLUETOOTH_NAMESPACE
 
 namespace {
 
-StaticRefPtr<BluetoothService> gBluetoothService;
+StaticRefPtr<BluetoothService> sBluetoothService;
 
-bool gInShutdown = false;
-bool gToggleInProgress = false;
+bool sInShutdown = false;
+bool sToggleInProgress = false;
 
 bool
 IsMainProcess()
 {
   return XRE_GetProcessType() == GeckoProcessType_Default;
 }
 
 void
@@ -140,36 +140,36 @@ public:
   {
     MOZ_ASSERT(!NS_IsMainThread());
   }
 
   NS_IMETHOD Run()
   {
     MOZ_ASSERT(NS_IsMainThread());
 
-    NS_ENSURE_TRUE(gBluetoothService, NS_OK);
+    NS_ENSURE_TRUE(sBluetoothService, NS_OK);
 
-    if (gInShutdown) {
-      gBluetoothService = nullptr;
+    if (sInShutdown) {
+      sBluetoothService = nullptr;
       return NS_OK;
     }
 
     // Update mEnabled of BluetoothService object since
     // StartInternal/StopInternal have been already done.
-    gBluetoothService->SetEnabled(mEnabled);
-    gToggleInProgress = false;
+    sBluetoothService->SetEnabled(mEnabled);
+    sToggleInProgress = false;
 
     nsAutoString signalName;
     signalName = mEnabled ? NS_LITERAL_STRING("Enabled")
                           : NS_LITERAL_STRING("Disabled");
     BluetoothSignal signal(signalName, NS_LITERAL_STRING(KEY_MANAGER), true);
-    gBluetoothService->DistributeSignal(signal);
+    sBluetoothService->DistributeSignal(signal);
 
     // Event 'AdapterAdded' has to be fired after firing 'Enabled'
-    gBluetoothService->TryFiringAdapterAdded();
+    sBluetoothService->TryFiringAdapterAdded();
 
     return NS_OK;
   }
 
 private:
   bool mEnabled;
 };
 
@@ -184,36 +184,36 @@ public:
   }
 
   NS_IMETHOD Run()
   {
     MOZ_ASSERT(!NS_IsMainThread());
 
     /**
      * mEnabled: expected status of bluetooth
-     * gBluetoothService->IsEnabled(): real status of bluetooth
+     * sBluetoothService->IsEnabled(): real status of bluetooth
      *
      * When two values are the same, we don't switch on/off bluetooth
      * but we still do ToggleBtAck task. One special case happens at startup
      * stage. At startup, the initialization of BluetoothService still has to
      * be done even if mEnabled is equal to the status of Bluetooth firmware.
      *
      * Please see bug 892392 for more information.
      */
-    if (!mIsStartup && mEnabled == gBluetoothService->IsEnabledInternal()) {
+    if (!mIsStartup && mEnabled == sBluetoothService->IsEnabledInternal()) {
       BT_WARNING("Bluetooth has already been enabled/disabled before.");
     } else {
       // Switch on/off bluetooth
       if (mEnabled) {
-        if (NS_FAILED(gBluetoothService->StartInternal())) {
+        if (NS_FAILED(sBluetoothService->StartInternal())) {
           BT_WARNING("Bluetooth service failed to start!");
           mEnabled = !mEnabled;
         }
       } else {
-        if (NS_FAILED(gBluetoothService->StopInternal())) {
+        if (NS_FAILED(sBluetoothService->StopInternal())) {
           BT_WARNING("Bluetooth service failed to stop!");
           mEnabled = !mEnabled;
         }
       }
     }
 
     // This is requested in Bug 836516. With settings this property, WLAN
     // firmware could be aware of Bluetooth has been turned on/off, so that the
@@ -252,18 +252,18 @@ public:
 
     if (!aResult.isBoolean()) {
       BT_WARNING("Setting for '" BLUETOOTH_ENABLED_SETTING "' is not a boolean!");
       return NS_OK;
     }
 
     // It is theoretically possible to shut down before the first settings check
     // has completed (though extremely unlikely).
-    if (gBluetoothService) {
-      return gBluetoothService->HandleStartupSettingsCheck(aResult.toBoolean());
+    if (sBluetoothService) {
+      return sBluetoothService->HandleStartupSettingsCheck(aResult.toBoolean());
     }
 
     return NS_OK;
   }
 
   NS_IMETHOD HandleError(const nsAString& aName)
   {
     BT_WARNING("Unable to get value for '" BLUETOOTH_ENABLED_SETTING "'");
@@ -273,17 +273,17 @@ public:
 
 NS_IMPL_ISUPPORTS1(BluetoothService::StartupTask, nsISettingsServiceCallback);
 
 NS_IMPL_ISUPPORTS1(BluetoothService, nsIObserver)
 
 bool
 BluetoothService::IsToggling() const
 {
-  return gToggleInProgress;
+  return sToggleInProgress;
 }
 
 BluetoothService::~BluetoothService()
 {
   Cleanup();
 }
 
 PLDHashOperator
@@ -458,17 +458,17 @@ BluetoothService::DistributeSignal(const
   ol->Broadcast(aSignal);
 }
 
 nsresult
 BluetoothService::StartStopBluetooth(bool aStart, bool aIsStartup)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  if (gInShutdown) {
+  if (sInShutdown) {
     if (aStart) {
       // Don't try to start if we're already shutting down.
       MOZ_ASSERT(false, "Start called while in shutdown!");
       return NS_ERROR_FAILURE;
     }
 
     if (!mBluetoothThread) {
       // Don't create a new thread after we've begun shutdown since bluetooth
@@ -542,42 +542,42 @@ BluetoothService::SetEnabled(bool aEnabl
       RemoveObserversExceptBluetoothManager, nullptr);
   }
 
   /**
    * mEnabled: real status of bluetooth
    * aEnabled: expected status of bluetooth
    */
   if (mEnabled == aEnabled) {
-    BT_WARNING("Bluetooth has already been enabled/disabled before\
-                or the toggling is failed.");
+    BT_WARNING("Bluetooth has already been enabled/disabled before"
+               "or the toggling is failed.");
   }
 
   mEnabled = aEnabled;
 }
 
 nsresult
 BluetoothService::HandleStartup()
 {
   MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(!gToggleInProgress);
+  MOZ_ASSERT(!sToggleInProgress);
 
   nsCOMPtr<nsISettingsService> settings =
     do_GetService("@mozilla.org/settingsService;1");
   NS_ENSURE_TRUE(settings, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<nsISettingsServiceLock> settingsLock;
   nsresult rv = settings->CreateLock(getter_AddRefs(settingsLock));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsRefPtr<StartupTask> callback = new StartupTask();
   rv = settingsLock->Get(BLUETOOTH_ENABLED_SETTING, callback);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  gToggleInProgress = true;
+  sToggleInProgress = true;
   return NS_OK;
 }
 
 nsresult
 BluetoothService::HandleStartupSettingsCheck(bool aEnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
   return StartStopBluetooth(aEnable, true);
@@ -654,22 +654,22 @@ BluetoothService::HandleSettingsChanged(
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
     if (!value.isBoolean()) {
       MOZ_ASSERT(false, "Expecting a boolean for 'bluetooth.enabled'!");
       return NS_ERROR_UNEXPECTED;
     }
 
-    if (gToggleInProgress || value.toBoolean() == IsEnabled()) {
+    if (sToggleInProgress || value.toBoolean() == IsEnabled()) {
       // Nothing to do here.
       return NS_OK;
     }
 
-    gToggleInProgress = true;
+    sToggleInProgress = true;
 
     nsresult rv = StartStopBluetooth(value.toBoolean(), false);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return NS_OK;
 }
 
@@ -677,17 +677,17 @@ nsresult
 BluetoothService::HandleShutdown()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // This is a two phase shutdown. First we notify all child processes that
   // bluetooth is going away, and then we wait for them to acknowledge. Then we
   // close down all the bluetooth machinery.
 
-  gInShutdown = true;
+  sInShutdown = true;
 
   Cleanup();
 
   AutoInfallibleTArray<BluetoothParent*, 10> childActors;
   GetAllBluetoothActors(childActors);
 
   if (!childActors.IsEmpty()) {
     // Notify child processes that they should stop using bluetooth now.
@@ -740,37 +740,37 @@ BluetoothService::HandleShutdown()
 
 // static
 BluetoothService*
 BluetoothService::Get()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // If we already exist, exit early
-  if (gBluetoothService) {
-    return gBluetoothService;
+  if (sBluetoothService) {
+    return sBluetoothService;
   }
 
   // If we're in shutdown, don't create a new instance
-  if (gInShutdown) {
+  if (sInShutdown) {
     BT_WARNING("BluetoothService can't be created during shutdown");
     return nullptr;
   }
 
   // Create new instance, register, return
   nsRefPtr<BluetoothService> service = BluetoothService::Create();
   NS_ENSURE_TRUE(service, nullptr);
 
   if (!service->Init()) {
     service->Cleanup();
     return nullptr;
   }
 
-  gBluetoothService = service;
-  return gBluetoothService;
+  sBluetoothService = service;
+  return sBluetoothService;
 }
 
 nsresult
 BluetoothService::Observe(nsISupports* aSubject, const char* aTopic,
                           const char16_t* aData)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
--- a/dom/bluetooth/ipc/BluetoothChild.cpp
+++ b/dom/bluetooth/ipc/BluetoothChild.cpp
@@ -16,80 +16,80 @@
 #include "BluetoothReplyRunnable.h"
 #include "BluetoothService.h"
 #include "BluetoothServiceChildProcess.h"
 
 USING_BLUETOOTH_NAMESPACE
 
 namespace {
 
-BluetoothServiceChildProcess* gBluetoothService;
+BluetoothServiceChildProcess* sBluetoothService;
 
 } // anonymous namespace
 
 /*******************************************************************************
  * BluetoothChild
  ******************************************************************************/
 
 BluetoothChild::BluetoothChild(BluetoothServiceChildProcess* aBluetoothService)
 : mShutdownState(Running)
 {
   MOZ_COUNT_CTOR(BluetoothChild);
-  MOZ_ASSERT(!gBluetoothService);
+  MOZ_ASSERT(!sBluetoothService);
   MOZ_ASSERT(aBluetoothService);
 
-  gBluetoothService = aBluetoothService;
+  sBluetoothService = aBluetoothService;
 }
 
 BluetoothChild::~BluetoothChild()
 {
   MOZ_COUNT_DTOR(BluetoothChild);
-  MOZ_ASSERT(gBluetoothService);
+  MOZ_ASSERT(sBluetoothService);
   MOZ_ASSERT(mShutdownState == Dead);
 
-  gBluetoothService = nullptr;
+  sBluetoothService = nullptr;
 }
 
 void
 BluetoothChild::BeginShutdown()
 {
   // Only do something here if we haven't yet begun the shutdown sequence.
   if (mShutdownState == Running) {
     SendStopNotifying();
     mShutdownState = SentStopNotifying;
   }
 }
 
 void
 BluetoothChild::ActorDestroy(ActorDestroyReason aWhy)
 {
-  MOZ_ASSERT(gBluetoothService);
+  MOZ_ASSERT(sBluetoothService);
 
-  gBluetoothService->NoteDeadActor();
+  sBluetoothService->NoteDeadActor();
 
 #ifdef DEBUG
   mShutdownState = Dead;
 #endif
 }
 
 bool
 BluetoothChild::RecvNotify(const BluetoothSignal& aSignal)
 {
-  MOZ_ASSERT(gBluetoothService);
+  MOZ_ASSERT(sBluetoothService);
 
-  gBluetoothService->DistributeSignal(aSignal);
+  sBluetoothService->DistributeSignal(aSignal);
   return true;
 }
 
 bool
 BluetoothChild::RecvEnabled(const bool& aEnabled)
 {
-  MOZ_ASSERT(gBluetoothService);
+  MOZ_ASSERT(sBluetoothService);
 
-  gBluetoothService->SetEnabled(aEnabled);
+  sBluetoothService->SetEnabled(aEnabled);
   return true;
 }
 
 bool
 BluetoothChild::RecvBeginShutdown()
 {
   if (mShutdownState != Running && mShutdownState != SentStopNotifying) {
     MOZ_ASSERT(false, "Bad state!");
--- a/dom/bluetooth/ipc/BluetoothParent.cpp
+++ b/dom/bluetooth/ipc/BluetoothParent.cpp
@@ -398,17 +398,17 @@ BluetoothRequestParent::DoRequest(const 
 
 bool
 BluetoothRequestParent::DoRequest(const ConnectedDevicePropertiesRequest& aRequest)
 {
   MOZ_ASSERT(mService);
   MOZ_ASSERT(mRequestType == Request::TConnectedDevicePropertiesRequest);
   nsresult rv =
     mService->GetConnectedDevicePropertiesInternal(aRequest.serviceUuid(),
-                                                mReplyRunnable.get());
+                                                   mReplyRunnable.get());
   NS_ENSURE_SUCCESS(rv, false);
 
   return true;
 }
 
 bool
 BluetoothRequestParent::DoRequest(const SetPinCodeRequest& aRequest)
 {
--- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
+++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
@@ -13,90 +13,90 @@
 
 #include "BluetoothChild.h"
 #include "MainThreadUtils.h"
 
 USING_BLUETOOTH_NAMESPACE
 
 namespace {
 
-BluetoothChild* gBluetoothChild;
+BluetoothChild* sBluetoothChild;
 
 inline
 void
 SendRequest(BluetoothReplyRunnable* aRunnable, const Request& aRequest)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aRunnable);
 
-  NS_WARN_IF_FALSE(gBluetoothChild,
+  NS_WARN_IF_FALSE(sBluetoothChild,
                    "Calling methods on BluetoothServiceChildProcess during "
                    "shutdown!");
 
-  if (gBluetoothChild) {
+  if (sBluetoothChild) {
     BluetoothRequestChild* actor = new BluetoothRequestChild(aRunnable);
-    gBluetoothChild->SendPBluetoothRequestConstructor(actor, aRequest);
+    sBluetoothChild->SendPBluetoothRequestConstructor(actor, aRequest);
   }
 }
 
 } // anonymous namespace
 
 // static
 BluetoothServiceChildProcess*
 BluetoothServiceChildProcess::Create()
 {
-  MOZ_ASSERT(!gBluetoothChild);
+  MOZ_ASSERT(!sBluetoothChild);
 
   mozilla::dom::ContentChild* contentChild =
     mozilla::dom::ContentChild::GetSingleton();
   MOZ_ASSERT(contentChild);
 
   BluetoothServiceChildProcess* btService = new BluetoothServiceChildProcess();
 
-  gBluetoothChild = new BluetoothChild(btService);
-  contentChild->SendPBluetoothConstructor(gBluetoothChild);
+  sBluetoothChild = new BluetoothChild(btService);
+  contentChild->SendPBluetoothConstructor(sBluetoothChild);
 
   return btService;
 }
 
 BluetoothServiceChildProcess::BluetoothServiceChildProcess()
 {
 }
 
 BluetoothServiceChildProcess::~BluetoothServiceChildProcess()
 {
-  gBluetoothChild = nullptr;
+  sBluetoothChild = nullptr;
 }
 
 void
 BluetoothServiceChildProcess::NoteDeadActor()
 {
-  MOZ_ASSERT(gBluetoothChild);
-  gBluetoothChild = nullptr;
+  MOZ_ASSERT(sBluetoothChild);
+  sBluetoothChild = nullptr;
 }
 
 void
 BluetoothServiceChildProcess::RegisterBluetoothSignalHandler(
                                               const nsAString& aNodeName,
                                               BluetoothSignalObserver* aHandler)
 {
-  if (gBluetoothChild && !IsSignalRegistered(aNodeName)) {
-    gBluetoothChild->SendRegisterSignalHandler(nsString(aNodeName));
+  if (sBluetoothChild && !IsSignalRegistered(aNodeName)) {
+    sBluetoothChild->SendRegisterSignalHandler(nsString(aNodeName));
   }
   BluetoothService::RegisterBluetoothSignalHandler(aNodeName, aHandler);
 }
 
 void
 BluetoothServiceChildProcess::UnregisterBluetoothSignalHandler(
                                               const nsAString& aNodeName,
                                               BluetoothSignalObserver* aHandler)
 {
   BluetoothService::UnregisterBluetoothSignalHandler(aNodeName, aHandler);
-  if (gBluetoothChild && !IsSignalRegistered(aNodeName)) {
-    gBluetoothChild->SendUnregisterSignalHandler(nsString(aNodeName));
+  if (sBluetoothChild && !IsSignalRegistered(aNodeName)) {
+    sBluetoothChild->SendUnregisterSignalHandler(nsString(aNodeName));
   }
 }
 
 nsresult
 BluetoothServiceChildProcess::GetDefaultAdapterPathInternal(
                                               BluetoothReplyRunnable* aRunnable)
 {
   SendRequest(aRunnable, DefaultAdapterPathRequest());
@@ -356,18 +356,18 @@ BluetoothServiceChildProcess::HandleStar
   return NS_OK;
 }
 
 nsresult
 BluetoothServiceChildProcess::HandleShutdown()
 {
   // If this process is shutting down then we need to disconnect ourselves from
   // the parent.
-  if (gBluetoothChild) {
-    gBluetoothChild->BeginShutdown();
+  if (sBluetoothChild) {
+    sBluetoothChild->BeginShutdown();
   }
   return NS_OK;
 }
 
 nsresult
 BluetoothServiceChildProcess::StartInternal()
 {
   MOZ_CRASH("This should never be called!");