Bug 1442313 part 1. Make xpc::IsInAutomation a bit faster. r=bholley
☠☠ backed out by accb1b3cf593 ☠ ☠
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 01 Mar 2018 14:24:17 -0500
changeset 461137 8fc2c103027ba37bd50dec5e2fe8b79d3d68c28c
parent 461136 cf67ac6f58d0fc08af06d9bd6f0247e9288e0568
child 461138 9788a46b8874dbc1a785e9eef091a9fc2e0b4f36
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [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();