author | Gerald Squelart <gsquelart@mozilla.com> |
Tue, 19 Jul 2016 17:46:38 +1000 | |
changeset 306050 | bd2f3939764154062cf4d65c8a39bd461df10c44 |
parent 306049 | 3f4268be982986a087206a5bc950fa5f17a4c09a |
child 306051 | c2f35c2580918891cfabc6ddaa84b535a43a6469 |
push id | 79765 |
push user | cbook@mozilla.com |
push date | Thu, 21 Jul 2016 14:26:34 +0000 |
treeherder | mozilla-inbound@ab54bfc55266 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | cpearce |
bugs | 1287712 |
milestone | 50.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
|
--- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -1570,44 +1570,57 @@ protected: // tree before. ELEMENT_NOT_INTREE_HAD_INTREE }; ElementInTreeState mElementInTreeState; public: // Helper class to measure times for MSE telemetry stats - class TimeDurationAccumulator { + class TimeDurationAccumulator + { public: TimeDurationAccumulator() : mCount(0) + {} + void Start() { - } - void Start() { if (IsStarted()) { return; } mStartTime = TimeStamp::Now(); } - void Pause() { + void Pause() + { if (!IsStarted()) { return; } mSum += (TimeStamp::Now() - mStartTime); mCount++; mStartTime = TimeStamp(); } - bool IsStarted() const { + bool IsStarted() const + { return !mStartTime.IsNull(); } - double Total() const { - return mSum.ToSeconds(); + double Total() const + { + if (!IsStarted()) { + return mSum.ToSeconds(); + } + // Add current running time until now, but keep it running. + return (mSum + (TimeStamp::Now() - mStartTime)).ToSeconds(); } - uint32_t Count() const { - return mCount; + uint32_t Count() const + { + if (!IsStarted()) { + return mCount; + } + // Count current run in this report, without increasing the stored count. + return mCount + 1; } private: TimeStamp mStartTime; TimeDuration mSum; uint32_t mCount; }; private: // Total time a video has spent playing.