Bug 833935 - Stop using one static var per compilation unit. r=jdm a=blocking-b2g
authorJason Duell <jduell.mcbugs@gmail.com>
Fri, 25 Jan 2013 19:28:00 +0000
changeset 118353 dc3e991c5ef0830c8186e01fd5a69984f53fb958
parent 118352 5c9f6113c3fa0f387839ebb1fb50e738503954c9
child 118354 b30d5224b47beeb483ce4b3298bd14f1a5d4df95
push id4
push userjduell@mozilla.com
push dateMon, 28 Jan 2013 01:39:38 +0000
reviewersjdm, blocking-b2g
bugs833935
milestone18.0
Bug 833935 - Stop using one static var per compilation unit. r=jdm a=blocking-b2g
netwerk/ipc/Makefile.in
netwerk/ipc/NeckoCommon.cpp
netwerk/ipc/NeckoCommon.h
--- a/netwerk/ipc/Makefile.in
+++ b/netwerk/ipc/Makefile.in
@@ -30,16 +30,17 @@ EXPORTS_mozilla/net = \
   NeckoCommon.h       \
   NeckoMessageUtils.h \
   ChannelEventQueue.h \
   RemoteOpenFileParent.h \
   RemoteOpenFileChild.h \
   $(NULL)
 
 CPPSRCS =               \
+  NeckoCommon.cpp       \
   NeckoChild.cpp        \
   NeckoParent.cpp       \
   ChannelEventQueue.cpp \
   RemoteOpenFileParent.cpp \
   RemoteOpenFileChild.cpp  \
   $(NULL)
 
 LOCAL_INCLUDES +=                  \
new file mode 100644
--- /dev/null
+++ b/netwerk/ipc/NeckoCommon.cpp
@@ -0,0 +1,19 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=8 et tw=80 : */
+
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "NeckoCommon.h"
+
+namespace mozilla {
+namespace net {
+
+namespace NeckoCommonInternal {
+  bool gSecurityDisabled = true;
+  bool gRegisteredBool = false;
+}
+
+} // namespace net
+} // namespace mozilla
--- a/netwerk/ipc/NeckoCommon.h
+++ b/netwerk/ipc/NeckoCommon.h
@@ -77,29 +77,32 @@ IsNeckoChild()
     const char * e = PR_GetEnv("NECKO_SEPARATE_STACKS");
     if (!e) 
       amChild = (XRE_GetProcessType() == GeckoProcessType_Content);
     didCheck = true;
   }
   return amChild;
 }
 
+namespace NeckoCommonInternal {
+  extern bool gSecurityDisabled;
+  extern bool gRegisteredBool;
+}
+
 // This should always return true unless xpcshell tests are being used
 inline bool
 UsingNeckoIPCSecurity()
 {
-  static bool securityDisabled = true;
-  static bool registeredBool = false;
 
-  if (!registeredBool) {
-    Preferences::AddBoolVarCache(&securityDisabled,
+  if (!NeckoCommonInternal::gRegisteredBool) {
+    Preferences::AddBoolVarCache(&NeckoCommonInternal::gSecurityDisabled,
                                  "network.disable.ipc.security");
-    registeredBool = true;
+    NeckoCommonInternal::gRegisteredBool = true;
   }
-  return !securityDisabled;
+  return !NeckoCommonInternal::gSecurityDisabled;
 }
 
 inline bool
 MissingRequiredTabChild(mozilla::dom::TabChild* tabChild,
                         const char* context)
 {
   if (UsingNeckoIPCSecurity()) {
     // Bug 833935: during navigation away from page some loads may lack