Bug 1259335 - Part 1.5b: Report telemetry for navigator.battery use. r=baku a=lizzard
authorChris Peterson <cpeterson@mozilla.com>
Sun, 05 Jun 2016 23:54:34 -0700
changeset 341611 a11eb3fab3c603e2b13f8185db8e1815b44d8692
parent 341610 1ae7a82e2b1d2b18ccfa9a578040b46c774bc501
child 341612 4f016f425e7544b228b4a099e78008b4f3b7c7cd
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, lizzard
bugs1259335
milestone49.0a2
Bug 1259335 - Part 1.5b: Report telemetry for navigator.battery use. r=baku a=lizzard
dom/base/Navigator.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1619,16 +1619,23 @@ Navigator::GetDeprecatedBattery(ErrorRes
     mBatteryManager->Init();
   }
 
   nsIDocument* doc = mWindow->GetDoc();
   if (doc) {
     doc->WarnOnceAbout(nsIDocument::eNavigatorBattery);
   }
 
+  // Is this the first time this page has accessed navigator.battery?
+  if (!mBatteryTelemetryReported) {
+    // sample value 0 = navigator.battery
+    Telemetry::Accumulate(Telemetry::BATTERY_STATUS_COUNT, 0);
+    mBatteryTelemetryReported = true;
+  }
+
   return mBatteryManager;
 }
 
 already_AddRefed<Promise>
 Navigator::PublishServer(const nsAString& aName,
                          const FlyWebPublishOptions& aOptions,
                          ErrorResult& aRv)
 {