Skip to content

Commit

Permalink
Bug 1259335 - Part 1.5: Collect use count telemetry for Battery Statu…
Browse files Browse the repository at this point in the history
…s API. r=baku
  • Loading branch information
cpeterso committed Jun 3, 2016
1 parent 1a83f50 commit 2fef1eb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dom/base/Navigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ Navigator::Init()

Navigator::Navigator(nsPIDOMWindowInner* aWindow)
: mWindow(aWindow)
, mBatteryTelemetryReported(false)
{
MOZ_ASSERT(aWindow->IsInnerWindow(), "Navigator must get an inner window!");
}
Expand Down Expand Up @@ -307,6 +308,7 @@ Navigator::Invalidate()
}

mBatteryPromise = nullptr;
mBatteryTelemetryReported = false;

#ifdef MOZ_B2G_FM
if (mFMRadio) {
Expand Down Expand Up @@ -1587,6 +1589,10 @@ Navigator::GetBattery(ErrorResult& aRv)
}
mBatteryPromise = batteryPromise;

// We just initialized mBatteryPromise, so we know this is the first time
// this page has accessed navigator.getBattery(). 1 = navigator.getBattery()
Telemetry::Accumulate(Telemetry::BATTERY_STATUS_COUNT, 1);

if (!mBatteryManager) {
mBatteryManager = new battery::BatteryManager(mWindow);
mBatteryManager->Init();
Expand Down
2 changes: 2 additions & 0 deletions dom/base/Navigator.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ class Navigator final : public nsIDOMNavigator

nsTArray<RefPtr<Promise> > mVRGetDevicesPromises;
nsTArray<uint32_t> mRequestedVibrationPattern;

bool mBatteryTelemetryReported;
};

} // namespace dom
Expand Down
8 changes: 8 additions & 0 deletions toolkit/components/telemetry/Histograms.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@
"n_values": 21,
"description": "Maximum number of concurrent threads reached during a given download session"
},
"BATTERY_STATUS_COUNT": {
"alert_emails": ["cpeterson@mozilla.com"],
"bug_numbers": [1259335],
"expires_in_version": "52",
"kind": "enumerated",
"n_values": 10,
"description": "Number of pages that use the Battery Status API: 0=navigator.battery, 1=navigator.getBattery()"
},
"BLOCKLIST_SYNC_FILE_LOAD": {
"alert_emails": ["rvitillo@mozilla.com"],
"expires_in_version": "35",
Expand Down

0 comments on commit 2fef1eb

Please sign in to comment.