Bug 1373888 - part2 : remove the timer which was used for b2g. r=cpearce

The timer was added for the b2g issue, now we can remove it.

MozReview-Commit-ID: BNjIghImCzC
This commit is contained in:
Alastor Wu
2017-08-29 10:54:25 +08:00
parent 2bc6bce6d1
commit 07f2b0f9cf
3 changed files with 4 additions and 45 deletions

View File

@@ -4165,56 +4165,21 @@ HTMLMediaElement::WakeLockBoolWrapper::operator=(bool val)
return *this;
}
HTMLMediaElement::WakeLockBoolWrapper::~WakeLockBoolWrapper()
{
if (mTimer) {
mTimer->Cancel();
}
}
void
HTMLMediaElement::WakeLockBoolWrapper::UpdateWakeLock()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mOuter) {
return;
}
MOZ_ASSERT(mOuter);
bool playing = !mValue;
if (playing) {
if (mTimer) {
mTimer->Cancel();
mTimer = nullptr;
}
mOuter->WakeLockCreate();
} else if (!mTimer) {
// Don't release the wake lock immediately; instead, release it after a
// grace period.
int timeout = Preferences::GetInt("media.wakelock_timeout", 2000);
mTimer = do_CreateInstance("@mozilla.org/timer;1");
if (mTimer) {
mTimer->SetTarget(mOuter->MainThreadEventTarget());
mTimer->InitWithNamedFuncCallback(
TimerCallback,
this,
timeout,
nsITimer::TYPE_ONE_SHOT,
"dom::HTMLMediaElement::WakeLockBoolWrapper::UpdateWakeLock");
}
} else {
mOuter->WakeLockRelease();
}
}
void
HTMLMediaElement::WakeLockBoolWrapper::TimerCallback(nsITimer* aTimer,
void* aClosure)
{
WakeLockBoolWrapper* wakeLock = static_cast<WakeLockBoolWrapper*>(aClosure);
wakeLock->mOuter->WakeLockRelease();
wakeLock->mTimer = nullptr;
}
void
HTMLMediaElement::WakeLockCreate()
{