Bug 729154 - Telemetry for a11y instantiation by unknown cause. r=tbsaunde f=surkov
authorDavid Bolter <dbolter@mozilla.com>
Mon, 16 Apr 2012 11:04:53 -0400
changeset 95081 7a74a4a363fc601917524d8e1ab01a521fa76e72
parent 95080 3adacc7b151f419a447899498157fd64ddb4f709
child 95082 f7668b976d64c473e566d110d5bf2e820ef66382
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs729154
milestone14.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 729154 - Telemetry for a11y instantiation by unknown cause. r=tbsaunde f=surkov This change includes a small refactor, combining our compat and telemetry data structures. We get all fancy pants with bitflags and such.
accessible/src/msaa/Compatibility.cpp
accessible/src/msaa/Compatibility.h
toolkit/components/telemetry/TelemetryHistograms.h
--- a/accessible/src/msaa/Compatibility.cpp
+++ b/accessible/src/msaa/Compatibility.cpp
@@ -75,64 +75,67 @@ IsModuleVersionLessThan(HMODULE aModuleH
     (dwLeftMost == aMajor && dwSecondRight < aMinor));
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // Compatibility
 ////////////////////////////////////////////////////////////////////////////////
 
-PRUint32 Compatibility::sMode = Compatibility::NoCompatibilityMode;
+PRUint32 Compatibility::sConsumers = Compatibility::UNKNOWN;
 
 void
 Compatibility::Init()
 {
   // Note we collect some AT statistics/telemetry here for convenience.
 
   HMODULE jawsHandle = ::GetModuleHandleW(L"jhook");
-  if (jawsHandle) {
-    sMode |= JAWSMode;
-    // IA2 off mode for JAWS versions below 8.0.2173.
-    if (IsModuleVersionLessThan(jawsHandle, 8, 2173)) {
-      sMode |= IA2OffMode;
-      statistics::A11yConsumers(OLDJAWS);
-    } else {
-      statistics::A11yConsumers(JAWS);
-    }
-  }
+  if (jawsHandle)
+    sConsumers |= (IsModuleVersionLessThan(jawsHandle, 8, 2173)) ?
+                   OLDJAWS : JAWS;
 
-  if (::GetModuleHandleW(L"gwm32inc")) {
-    sMode |= WEMode;
-    statistics::A11yConsumers(WE);
-  }
-  if (::GetModuleHandleW(L"dolwinhk")) {
-    sMode |= DolphinMode;
-    statistics::A11yConsumers(DOLPHIN);
-  }
+  if (::GetModuleHandleW(L"gwm32inc"))
+    sConsumers |= WE;
+
+  if (::GetModuleHandleW(L"dolwinhk"))
+    sConsumers |= DOLPHIN;
 
   if (::GetModuleHandleW(L"STSA32"))
-    statistics::A11yConsumers(SEROTEK);
+    sConsumers |= SEROTEK;
 
   if (::GetModuleHandleW(L"nvdaHelperRemote"))
-    statistics::A11yConsumers(NVDA);
+    sConsumers |= NVDA;
 
   if (::GetModuleHandleW(L"OsmHooks"))
-    statistics::A11yConsumers(COBRA);
+    sConsumers |= COBRA;
 
   if (::GetModuleHandleW(L"WebFinderRemote"))
-    statistics::A11yConsumers(ZOOMTEXT);
+    sConsumers |= ZOOMTEXT;
 
   if (::GetModuleHandleW(L"Kazahook"))
-    statistics::A11yConsumers(KAZAGURU);
+    sConsumers |= KAZAGURU;
 
   if (::GetModuleHandleW(L"TextExtractorImpl32") ||
       ::GetModuleHandleW(L"TextExtractorImpl64"))
-    statistics::A11yConsumers(YOUDAO);
+    sConsumers |= YOUDAO;
+
+  // If we have a known consumer remove the unknown bit.
+  if (sConsumers != Compatibility::UNKNOWN)
+    sConsumers ^= Compatibility::UNKNOWN;
+
+  // Gather telemetry
+  PRUint32 temp = sConsumers;
+  for (int i = 0; temp; i++) {
+    if (temp & 0x1)
+      statistics::A11yConsumers(i);
+
+    temp >>= 1;
+  }
 
   // Turn off new tab switching for Jaws and WE.
-  if (sMode & JAWSMode || sMode & WEMode) {
+  if (sConsumers & (JAWS | OLDJAWS | WE)) {
     // Check to see if the pref for disallowing CtrlTab is already set. If so,
     // bail out (respect the user settings). If not, set it.
     if (!Preferences::HasUserValue("browser.ctrlTab.disallowForScreenReaders"))
       Preferences::SetBool("browser.ctrlTab.disallowForScreenReaders", true);
   }
 }
 
--- a/accessible/src/msaa/Compatibility.h
+++ b/accessible/src/msaa/Compatibility.h
@@ -52,72 +52,62 @@ namespace a11y {
  * start up time and aren't changed during lifetime.
  */
 class Compatibility
 {
 public:
   /**
    * Return true if IAccessible2 disabled.
    */
-  static bool IsIA2Off() { return sMode & IA2OffMode; }
+  static bool IsIA2Off() { return !!(sConsumers & OLDJAWS); }
 
   /**
    * Return true if JAWS mode is enabled.
    */
-  static bool IsJAWS() { return sMode & JAWSMode; }
+  static bool IsJAWS() { return !!(sConsumers & (JAWS | OLDJAWS)); }
 
   /**
    * Return true if WE mode is enabled.
    */
-  static bool IsWE() { return sMode & WEMode; }
+  static bool IsWE() { return !!(sConsumers & WE); }
 
   /**
    * Return true if Dolphin mode is enabled.
    */
-  static bool IsDolphin() { return sMode & DolphinMode; }
+  static bool IsDolphin() { return !!(sConsumers & DOLPHIN); }
 
 private:
   Compatibility();
   Compatibility(const Compatibility&);
   Compatibility& operator = (const Compatibility&);
 
   /**
    * Initialize compatibility mode. Called by nsAccessNodeWrap during
    * accessibility initialization.
    */
   static void Init();
   friend class nsAccessNodeWrap;
 
   /**
-   * List of compatibility modes.
+   * List of detected consumers of a11y (used for statistics/telemetry and compat)
    */
   enum {
-    NoCompatibilityMode = 0,
-    JAWSMode = 1 << 0,
-    WEMode = 1 << 1,
-    DolphinMode = 1 << 2,
-    IA2OffMode = 1 << 3
-  };
-
-  /**
-   * List of detected consumers of a11y (used for statistics/telemetry)
-   */
-  enum {
-    NVDA = 0,
-    JAWS = 1,
-    OLDJAWS = 2,
-    WE = 3,
-    DOLPHIN = 4,
-    SEROTEK = 5,
-    COBRA = 6,
-    ZOOMTEXT = 7,
-    KAZAGURU = 8,
-    YOUDAO = 9
+    NVDA = 1 << 0,
+    JAWS = 1 << 1,
+    OLDJAWS = 1 << 2,
+    WE = 1 << 3,
+    DOLPHIN = 1 << 4,
+    SEROTEK = 1 << 5,
+    COBRA = 1 << 6,
+    ZOOMTEXT = 1 << 7,
+    KAZAGURU = 1 << 8,
+    YOUDAO = 1 << 9,
+    UNKNOWN = 1 << 10
   };
 
 private:
-  static PRUint32 sMode;
+  static PRUint32 sConsumers;
 };
 
 } // a11y namespace
 } // mozilla namespace
 
 #endif
--- a/toolkit/components/telemetry/TelemetryHistograms.h
+++ b/toolkit/components/telemetry/TelemetryHistograms.h
@@ -56,17 +56,17 @@
 /* Convenience macro for LINEAR histograms where we want buckets from 1 to N, inclusive. */
 #define HISTOGRAM_ENUMERATED_VALUES(id, n, message) \
   HISTOGRAM(id, 1, n, n+1, LINEAR, message)
 
 /**
  * a11y telemetry
  */
 HISTOGRAM_FLAG(A11Y_INSTANTIATED_FLAG, "has accessibility support been instantiated")
-HISTOGRAM_ENUMERATED_VALUES(A11Y_CONSUMERS, 9, "Accessibility client by enum id")
+HISTOGRAM_ENUMERATED_VALUES(A11Y_CONSUMERS, 10, "Accessibility client by enum id")
 HISTOGRAM_FLAG(A11Y_ISIMPLEDOM_USAGE_FLAG, "have the ISimpleDOM* accessibility interfaces been used")
 HISTOGRAM_FLAG(A11Y_IATABLE_USAGE_FLAG, "has the IAccessibleTable accessibility interface been used")
 HISTOGRAM_FLAG(A11Y_XFORMS_USAGE_FLAG, "has XForms accessibility been instantiated")
 
 /**
  * Cycle collector telemetry
  */
 HISTOGRAM(CYCLE_COLLECTOR, 1, 10000, 50, EXPONENTIAL, "Time spent on one cycle collection (ms)")