Bug 833935 - Stop using one static var per compilation unit. r=jdm
authorJason Duell <jduell.mcbugs@gmail.com>
Fri, 25 Jan 2013 19:28:00 +0000
changeset 126031 629d2d1485e291ceebb21837e2aeab9c72c6ebc1
parent 126030 1bcf7ce80feceeffdff0ec5da5f79c2dd8826ba9
child 126032 045c314c045b64715fe20cd8302c890972502338
push id3384
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:42:39 +0000
treeherdermozilla-aurora@d8c97bae8521 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
bugs833935
milestone21.0a1
Bug 833935 - Stop using one static var per compilation unit. r=jdm
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
@@ -95,29 +95,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