mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
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 --HG-- extra : rebase_source : c5490d417b2d40619eb7092dfc21b19a99982a1c
This commit is contained in:
parent
f570c3c5ec
commit
71ad2fdb83
@ -4165,56 +4165,21 @@ HTMLMediaElement::WakeLockBoolWrapper::operator=(bool val)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTMLMediaElement::WakeLockBoolWrapper::~WakeLockBoolWrapper()
|
|
||||||
{
|
|
||||||
if (mTimer) {
|
|
||||||
mTimer->Cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
HTMLMediaElement::WakeLockBoolWrapper::UpdateWakeLock()
|
HTMLMediaElement::WakeLockBoolWrapper::UpdateWakeLock()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
MOZ_ASSERT(mOuter);
|
||||||
if (!mOuter) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool playing = !mValue;
|
bool playing = !mValue;
|
||||||
|
|
||||||
if (playing) {
|
if (playing) {
|
||||||
if (mTimer) {
|
|
||||||
mTimer->Cancel();
|
|
||||||
mTimer = nullptr;
|
|
||||||
}
|
|
||||||
mOuter->WakeLockCreate();
|
mOuter->WakeLockCreate();
|
||||||
} else if (!mTimer) {
|
} else {
|
||||||
// Don't release the wake lock immediately; instead, release it after a
|
mOuter->WakeLockRelease();
|
||||||
// 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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
HTMLMediaElement::WakeLockBoolWrapper::TimerCallback(nsITimer* aTimer,
|
|
||||||
void* aClosure)
|
|
||||||
{
|
|
||||||
WakeLockBoolWrapper* wakeLock = static_cast<WakeLockBoolWrapper*>(aClosure);
|
|
||||||
wakeLock->mOuter->WakeLockRelease();
|
|
||||||
wakeLock->mTimer = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
HTMLMediaElement::WakeLockCreate()
|
HTMLMediaElement::WakeLockCreate()
|
||||||
{
|
{
|
||||||
|
@ -822,7 +822,7 @@ protected:
|
|||||||
, mOuter(nullptr)
|
, mOuter(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~WakeLockBoolWrapper();
|
~WakeLockBoolWrapper() {};
|
||||||
|
|
||||||
void SetOuter(HTMLMediaElement* outer) { mOuter = outer; }
|
void SetOuter(HTMLMediaElement* outer) { mOuter = outer; }
|
||||||
|
|
||||||
@ -832,14 +832,11 @@ protected:
|
|||||||
|
|
||||||
bool operator !() const { return !mValue; }
|
bool operator !() const { return !mValue; }
|
||||||
|
|
||||||
static void TimerCallback(nsITimer* aTimer, void* aClosure);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateWakeLock();
|
void UpdateWakeLock();
|
||||||
|
|
||||||
bool mValue;
|
bool mValue;
|
||||||
HTMLMediaElement* mOuter;
|
HTMLMediaElement* mOuter;
|
||||||
nsCOMPtr<nsITimer> mTimer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Holds references to the DOM wrappers for the MediaStreams that we're
|
// Holds references to the DOM wrappers for the MediaStreams that we're
|
||||||
|
@ -349,9 +349,6 @@ pref("media.throttle-regardless-of-download-rate", false);
|
|||||||
// Master HTML5 media volume scale.
|
// Master HTML5 media volume scale.
|
||||||
pref("media.volume_scale", "1.0");
|
pref("media.volume_scale", "1.0");
|
||||||
|
|
||||||
// Timeout for wakelock release
|
|
||||||
pref("media.wakelock_timeout", 2000);
|
|
||||||
|
|
||||||
// Whether we should play videos opened in a "video document", i.e. videos
|
// Whether we should play videos opened in a "video document", i.e. videos
|
||||||
// opened as top-level documents, as opposed to inside a media element.
|
// opened as top-level documents, as opposed to inside a media element.
|
||||||
pref("media.play-stand-alone", true);
|
pref("media.play-stand-alone", true);
|
||||||
|
Loading…
Reference in New Issue
Block a user