Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(969)

Unified Diff: third_party/WebKit/Source/modules/wake_lock/ScreenWakeLock.cpp

Issue 1883493003: [OnionSoup] Moving WakeLock Service to Blink (2/2): removing WebWakeLockClient and WakeLockDispatch… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/wake_lock/ScreenWakeLock.cpp
diff --git a/third_party/WebKit/Source/modules/wake_lock/ScreenWakeLock.cpp b/third_party/WebKit/Source/modules/wake_lock/ScreenWakeLock.cpp
index 331e672b50e8610b5a72b99e986333bd2ca7b1de..65b645360b16c23395794dbb4d31cb1a75309ddb 100644
--- a/third_party/WebKit/Source/modules/wake_lock/ScreenWakeLock.cpp
+++ b/third_party/WebKit/Source/modules/wake_lock/ScreenWakeLock.cpp
@@ -8,7 +8,7 @@
#include "core/frame/Screen.h"
#include "core/page/PageVisibilityState.h"
#include "platform/RuntimeEnabledFeatures.h"
-#include "public/platform/modules/wake_lock/WebWakeLockClient.h"
+#include "public/platform/ServiceRegistry.h"
namespace blink {
@@ -26,16 +26,8 @@ bool ScreenWakeLock::keepAwake(Screen& screen)
void ScreenWakeLock::setKeepAwake(Screen& screen, bool keepAwake)
{
ScreenWakeLock* screenWakeLock = fromScreen(screen);
- if (!screenWakeLock)
- return;
-
- screenWakeLock->setKeepAwake(keepAwake);
-}
-
-void ScreenWakeLock::setKeepAwake(bool keepAwake)
-{
- m_keepAwake = keepAwake;
- notifyClient();
+ if (screenWakeLock)
+ screenWakeLock->setKeepAwake(keepAwake);
}
// static
@@ -51,13 +43,13 @@ ScreenWakeLock* ScreenWakeLock::from(LocalFrame* frame)
}
// static
-void ScreenWakeLock::provideTo(LocalFrame& frame, WebWakeLockClient* client)
+void ScreenWakeLock::provideTo(LocalFrame& frame, ServiceRegistry* registry)
{
- ASSERT(RuntimeEnabledFeatures::wakeLockEnabled());
+ DCHECK(RuntimeEnabledFeatures::wakeLockEnabled());
Supplement<LocalFrame>::provideTo(
frame,
ScreenWakeLock::supplementName(),
- new ScreenWakeLock(frame, client));
+ registry ? new ScreenWakeLock(frame, registry) : nullptr);
esprehn 2016/04/15 22:38:13 hmm, why would you ever get a null registry?
mcasas 2016/04/16 00:34:14 See below.
}
void ScreenWakeLock::pageVisibilityChanged()
@@ -68,14 +60,13 @@ void ScreenWakeLock::pageVisibilityChanged()
void ScreenWakeLock::didCommitLoad(LocalFrame* committedFrame)
{
// Reset wake lock flag for this frame if it is the one being navigated.
- if (committedFrame == frame()) {
+ if (committedFrame == frame())
setKeepAwake(false);
- }
}
void ScreenWakeLock::willDetachFrameHost()
{
- m_client = nullptr;
+ setKeepAwake(false);
}
DEFINE_TRACE(ScreenWakeLock)
@@ -85,12 +76,25 @@ DEFINE_TRACE(ScreenWakeLock)
LocalFrameLifecycleObserver::trace(visitor);
}
-ScreenWakeLock::ScreenWakeLock(LocalFrame& frame, WebWakeLockClient* client)
+ScreenWakeLock::ScreenWakeLock(LocalFrame& frame, ServiceRegistry* registry)
esprehn 2016/04/15 22:38:13 pass a reference
mcasas 2016/04/16 00:34:14 See below.
: PageLifecycleObserver(frame.page())
, LocalFrameLifecycleObserver(&frame)
- , m_client(client)
, m_keepAwake(false)
{
+ DCHECK(!m_service.is_bound());
+ DCHECK(registry);
esprehn 2016/04/15 22:38:13 remove dcheck and just use a reference?
mcasas 2016/04/16 00:34:14 ServiceRegistry should not be null, but the caller
+ registry->connectToRemoteService(mojo::GetProxy(&m_service));
+}
+
+bool ScreenWakeLock::keepAwake() const
+{
+ return m_keepAwake;
+}
+
+void ScreenWakeLock::setKeepAwake(bool keepAwake)
+{
+ m_keepAwake = keepAwake;
+ notifyClient();
}
// static
@@ -101,10 +105,13 @@ ScreenWakeLock* ScreenWakeLock::fromScreen(Screen& screen)
void ScreenWakeLock::notifyClient()
esprehn 2016/04/15 22:38:13 does this need a new name?
mcasas 2016/04/16 00:34:14 Done.
{
- if (!m_client)
+ if (!m_service)
return;
- m_client->requestKeepScreenAwake(m_keepAwake && page() && page()->isPageVisible());
+ if (m_keepAwake && frame()->page() && frame()->page()->isPageVisible())
+ m_service->RequestWakeLock();
+ else
+ m_service->CancelWakeLock();
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698