Bug 1373888 - part3 : rename the topic of the wake lock. r=cpearce
authorAlastor Wu <alwu@mozilla.com>
Tue, 29 Aug 2017 10:54:28 +0800
changeset 426860 0f86a834739363738404000d2be730c4fb10cdc8
parent 426859 e4e4bda4e5cac824b3f665f1e77f5eea79ac5942
child 426861 ecc2c4a42ff9f55d435ca4d602ef0000971f2d01
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1373888
milestone57.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
Bug 1373888 - part3 : rename the topic of the wake lock. r=cpearce 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
dom/html/HTMLMediaElement.cpp
dom/html/HTMLVideoElement.cpp
widget/cocoa/nsAppShell.mm
widget/gtk/WakeLockListener.cpp
widget/windows/nsAppShell.cpp
--- 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);