Bug 1442313 part 1. Make xpc::IsInAutomation a bit faster. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 01 Mar 2018 14:24:17 -0500
changeset 406273 cb363ac1897a78d1d8c4cbd0b2f4b7636097547c
parent 406272 9552b5f236a56a89edbe0625231502b3d8fe5bcd
child 406274 0d9766eb6f0f77235b0184a5fbc41e1dfa1e2320
push id33551
push userbzbarsky@mozilla.com
push dateFri, 02 Mar 2018 17:28:07 +0000
treeherdermozilla-central@9caf14e0b300 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1442313
milestone60.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 1442313 part 1. Make xpc::IsInAutomation a bit faster. r=bholley MozReview-Commit-ID: HTs3RwEOmZ4
js/xpconnect/src/xpcpublic.h
--- a/js/xpconnect/src/xpcpublic.h
+++ b/js/xpconnect/src/xpcpublic.h
@@ -672,20 +672,26 @@ AreNonLocalConnectionsDisabled()
         }
     }
     return disabledForTest;
 }
 
 inline bool
 IsInAutomation()
 {
-    const char* prefName =
-      "security.turn_off_all_security_so_that_viruses_can_take_over_this_computer";
-    return mozilla::Preferences::GetBool(prefName) &&
-        AreNonLocalConnectionsDisabled();
+    static bool sAutomationPrefIsSet;
+    static bool sPrefCacheAdded = false;
+    if (!sPrefCacheAdded) {
+        mozilla::Preferences::AddBoolVarCache(
+          &sAutomationPrefIsSet,
+          "security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
+          false);
+        sPrefCacheAdded = true;
+    }
+    return sAutomationPrefIsSet && AreNonLocalConnectionsDisabled();
 }
 
 void
 CreateCooperativeContext();
 
 void
 DestroyCooperativeContext();