mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 1589554 - Part 5: Screen Wake Lock telemetry. r=dom-core,edgar
Depends on D189511 Differential Revision: https://phabricator.services.mozilla.com/D189512
This commit is contained in:
parent
f8b00513bf
commit
6f5f80d733
@ -5,6 +5,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/TelemetryHistogramEnums.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/EventBinding.h"
|
||||
@ -27,6 +29,17 @@ void WakeLockSentinel::NotifyLockReleased() {
|
||||
MOZ_ASSERT(!mReleased);
|
||||
mReleased = true;
|
||||
|
||||
Telemetry::AccumulateTimeDelta(Telemetry::SCREENWAKELOCK_HELD_DURATION_MS,
|
||||
mCreationTime);
|
||||
|
||||
hal::BatteryInformation batteryInfo;
|
||||
hal::GetCurrentBatteryInformation(&batteryInfo);
|
||||
if (!batteryInfo.charging()) {
|
||||
uint32_t level = static_cast<uint32_t>(100 * batteryInfo.level());
|
||||
Telemetry::Accumulate(
|
||||
Telemetry::SCREENWAKELOCK_RELEASE_BATTERY_LEVEL_DISCHARGING, level);
|
||||
}
|
||||
|
||||
if (mHoldsActualLock) {
|
||||
MOZ_ASSERT(mType == WakeLockType::Screen);
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction("ReleaseWakeLock", []() {
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/dom/WakeLockBinding.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
@ -23,7 +24,9 @@ namespace mozilla::dom {
|
||||
class WakeLockSentinel final : public DOMEventTargetHelper {
|
||||
public:
|
||||
WakeLockSentinel(nsIGlobalObject* aOwnerWindow, WakeLockType aType)
|
||||
: DOMEventTargetHelper(aOwnerWindow), mType(aType) {}
|
||||
: DOMEventTargetHelper(aOwnerWindow),
|
||||
mType(aType),
|
||||
mCreationTime(TimeStamp::Now()) {}
|
||||
|
||||
protected:
|
||||
~WakeLockSentinel() {
|
||||
@ -67,8 +70,8 @@ class WakeLockSentinel final : public DOMEventTargetHelper {
|
||||
*/
|
||||
bool mHoldsActualLock = false;
|
||||
|
||||
// Time when this object was created / the wake lock acquired.
|
||||
TimeStamp mAcquireTime;
|
||||
// Time when this object was created
|
||||
TimeStamp mCreationTime;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
@ -18173,5 +18173,29 @@
|
||||
"record_in_processes": ["all"],
|
||||
"labels": ["inits"],
|
||||
"releaseChannelCollection": "opt-out"
|
||||
},
|
||||
"SCREENWAKELOCK_HELD_DURATION_MS": {
|
||||
"record_in_processes": ["content"],
|
||||
"products": ["firefox"],
|
||||
"alert_emails": ["vhilla@mozilla.com"],
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"low": 240000,
|
||||
"high": 28800000,
|
||||
"n_buckets": 50,
|
||||
"bug_numbers": [1589554],
|
||||
"description": "How long a screen wake lock was held in ms"
|
||||
},
|
||||
"SCREENWAKELOCK_RELEASE_BATTERY_LEVEL_DISCHARGING": {
|
||||
"record_in_processes": ["content"],
|
||||
"products": ["firefox"],
|
||||
"alert_emails": ["vhilla@mozilla.com"],
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"low": 1,
|
||||
"high": 100,
|
||||
"n_buckets": 50,
|
||||
"bug_numbers": [1589554],
|
||||
"description": "Battery level when discharging and the wake lock was released"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user