Add monitor information to the telemetry environment. (bug 1175005 part 5, r=gfritzsche)
authorDavid Anderson <danderson@mozilla.com>
Wed, 17 Jun 2015 23:12:19 -0700
changeset 267609 d9c8c1d140371a48de0c7e0a9bb724ba517301c7
parent 267608 f081c464c1e2fe7d3f8aa4c23a6efdfe9156db68
child 267610 2f789a4def0a7c18443039df41a2d5d9c82b5692
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-esr52@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1175005
milestone41.0a1
Add monitor information to the telemetry environment. (bug 1175005 part 5, r=gfritzsche)
toolkit/components/telemetry/TelemetryEnvironment.jsm
toolkit/components/telemetry/docs/environment.rst
toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
--- a/toolkit/components/telemetry/TelemetryEnvironment.jsm
+++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm
@@ -1122,18 +1122,28 @@ EnvironmentCache.prototype = {
   _getGFXData: function () {
     let gfxData = {
       D2DEnabled: getGfxField("D2DEnabled", null),
       DWriteEnabled: getGfxField("DWriteEnabled", null),
       // The following line is disabled due to main thread jank and will be enabled
       // again as part of bug 1154500.
       //DWriteVersion: getGfxField("DWriteVersion", null),
       adapters: [],
+      monitors: [],
     };
 
+#if !defined(MOZ_WIDGET_GONK) && !defined(MOZ_WIDGET_ANDROID)
+    let gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+    try {
+      gfxData.monitors = gfxInfo.getMonitors();
+    } catch (e) {
+      this._log.error("nsIGfxInfo.getMonitors() caught error", e);
+    }
+#endif
+
     // GfxInfo does not yet expose a way to iterate through all the adapters.
     gfxData.adapters.push(getGfxAdapter(""));
     gfxData.adapters[0].GPUActive = true;
 
     // If we have a second adapter add it to the gfxData.adapters section.
     let hasGPU2 = getGfxField("adapterDeviceID2", null) !== null;
     if (!hasGPU2) {
       this._log.trace("_getGFXData - Only one display adapter detected.");
--- a/toolkit/components/telemetry/docs/environment.rst
+++ b/toolkit/components/telemetry/docs/environment.rst
@@ -128,16 +128,28 @@ Structure::
                 RAM: <number>, // in MB, null on failure
                 driver: <string>, // null on failure
                 driverVersion: <string>, // null on failure
                 driverDate: <string>, // null on failure
                 GPUActive: <bool>, // currently always true for the first adapter
               },
               ...
             ],
+            // Note: currently only added on Desktop. On Linux, only a single
+            // monitor is returned representing the entire virtual screen.
+            monitors: [
+              {
+                screenWidth: <number>,  // screen width in pixels
+                screenHeight: <number>, // screen height in pixels
+                refreshRate: <number>,  // refresh rate in hertz (present on Windows only)
+                pseudoDisplay: <bool>,  // networked screen (present on Windows only)
+                scale: <number>,        // backing scale factor (present on Mac only)
+              },
+              ...
+            ],
           },
       },
       addons: {
         activeAddons: { // the currently enabled addons
           <addon id>: {
             blocklisted: <bool>,
             description: <string>, // null if not available
             name: <string>,
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
@@ -411,16 +411,30 @@ function checkSystemSection(data) {
   Assert.ok("adapters" in gfxData);
   Assert.ok(gfxData.adapters.length > 0, "There must be at least one GFX adapter.");
   for (let adapter of gfxData.adapters) {
     checkGfxAdapter(adapter);
   }
   Assert.equal(typeof gfxData.adapters[0].GPUActive, "boolean");
   Assert.ok(gfxData.adapters[0].GPUActive, "The first GFX adapter must be active.");
 
+  Assert.ok(Array.isArray(gfxData.monitors));
+  if (gIsWindows || gIsMac) {
+    Assert.ok(gfxData.monitors.length >= 1, "There is at least one monitor.");
+    Assert.equal(typeof gfxData.monitors[0].screenWidth, "number");
+    Assert.equal(typeof gfxData.monitors[0].screenHeight, "number");
+    if (gIsWindows) {
+      Assert.equal(typeof gfxData.monitors[0].refreshRate, "number");
+      Assert.equal(typeof gfxData.monitors[0].pseudoDisplay, "boolean");
+    }
+    if (gIsMac) {
+      Assert.equal(typeof gfxData.monitors[0].scale, "number");
+    }
+  }
+
   try {
     // If we've not got nsIGfxInfoDebug, then this will throw and stop us doing
     // this test.
     let gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfoDebug);
 
     if (gIsWindows || gIsMac) {
       Assert.equal(GFX_VENDOR_ID, gfxData.adapters[0].vendorID);
       Assert.equal(GFX_DEVICE_ID, gfxData.adapters[0].deviceID);