Bug 1373888 - part3 : rename the topic of the wake lock.
For knowing the wake lock usage more clearly, we should use more specific topic name.
In OSX, you can use "$ pmset -g assertions" to check all the wakelock.
In Windows, using "$ powser -energy" to generate the energy report.
MozReview-Commit-ID: rAXnkxTvLc
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4184,17 +4184,17 @@ void
HTMLMediaElement::WakeLockCreate()
{
if (!mWakeLock) {
RefPtr<power::PowerManagerService> pmService =
power::PowerManagerService::GetInstance();
NS_ENSURE_TRUE_VOID(pmService);
ErrorResult rv;
- mWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("cpu"),
+ mWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("audio-playing"),
OwnerDoc()->GetInnerWindow(),
rv);
}
}
void
HTMLMediaElement::WakeLockRelease()
{
--- a/dom/html/HTMLVideoElement.cpp
+++ b/dom/html/HTMLVideoElement.cpp
@@ -329,17 +329,17 @@ HTMLVideoElement::UpdateScreenWakeLock()
}
if (!mScreenWakeLock && !mPaused && !hidden && HasVideo()) {
RefPtr<power::PowerManagerService> pmService =
power::PowerManagerService::GetInstance();
NS_ENSURE_TRUE_VOID(pmService);
ErrorResult rv;
- mScreenWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("screen"),
+ mScreenWakeLock = pmService->NewWakeLock(NS_LITERAL_STRING("video-playing"),
OwnerDoc()->GetInnerWindow(),
rv);
}
}
void
HTMLVideoElement::Init()
{
--- a/widget/cocoa/nsAppShell.mm
+++ b/widget/cocoa/nsAppShell.mm
@@ -55,17 +55,19 @@ public:
NS_DECL_ISUPPORTS;
private:
~MacWakeLockListener() {}
IOPMAssertionID mAssertionID = kIOPMNullAssertionID;
NS_IMETHOD Callback(const nsAString& aTopic, const nsAString& aState) override {
- if (!aTopic.EqualsASCII("screen")) {
+ if (!aTopic.EqualsASCII("screen") &&
+ !aTopic.EqualsASCII("audio-playing") &&
+ !aTopic.EqualsASCII("video-playing")) {
return NS_OK;
}
// Note the wake lock code ensures that we're not sent duplicate
// "locked-foreground" notifications when multiple wake locks are held.
if (aState.EqualsASCII("locked-foreground")) {
// Prevent screen saver.
CFStringRef cf_topic =
::CFStringCreateWithCharacters(kCFAllocatorDefault,
--- a/widget/gtk/WakeLockListener.cpp
+++ b/widget/gtk/WakeLockListener.cpp
@@ -338,17 +338,19 @@ WakeLockListener::Shutdown()
nsresult
WakeLockListener::Callback(const nsAString& topic, const nsAString& state)
{
if (!mConnection) {
return NS_ERROR_FAILURE;
}
- if(!topic.Equals(NS_LITERAL_STRING("screen")))
+ if(!topic.Equals(NS_LITERAL_STRING("screen")) &&
+ !topic.Equals(NS_LITERAL_STRING("audio-playing")) &&
+ !topic.Equals(NS_LITERAL_STRING("video-playing")))
return NS_OK;
WakeLockTopic* topicLock = mTopics.Get(topic);
if (!topicLock) {
topicLock = new WakeLockTopic(topic, mConnection);
mTopics.Put(topic, topicLock);
}
--- a/widget/windows/nsAppShell.cpp
+++ b/widget/windows/nsAppShell.cpp
@@ -46,17 +46,19 @@ class WinWakeLockListener final : public
{
public:
NS_DECL_ISUPPORTS;
private:
~WinWakeLockListener() {}
NS_IMETHOD Callback(const nsAString& aTopic, const nsAString& aState) {
- if (!aTopic.EqualsASCII("screen")) {
+ if (!aTopic.EqualsASCII("screen") &&
+ !aTopic.EqualsASCII("audio-playing") &&
+ !aTopic.EqualsASCII("video-playing")) {
return NS_OK;
}
// Note the wake lock code ensures that we're not sent duplicate
// "locked-foreground" notifications when multiple wake locks are held.
if (aState.EqualsASCII("locked-foreground")) {
WAKE_LOCK_LOG("WinWakeLock: Blocking screen saver");
// Prevent the display turning off and block the screen saver.
SetThreadExecutionState(ES_DISPLAY_REQUIRED|ES_CONTINUOUS);