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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2843353003: Move ownership of PowerSaveBlocker from WakeLockServiceContext to WakeLockServiceImpl (Closed)
Patch Set: error fix, non-frame client. Created 3 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: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 919d333fd105979beff2e770c0b3535e76e4ca82..05982d6aea295220055ba3ef665ce9e68c841399 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2600,12 +2600,31 @@ WebContentsImpl::GetGeolocationServiceContext() {
return geolocation_service_context_.get();
}
-device::mojom::WakeLockContext* WebContentsImpl::GetWakeLockServiceContext() {
+device::mojom::WakeLockContext* WebContentsImpl::GetWakeLockContext() {
if (!wake_lock_context_host_)
wake_lock_context_host_.reset(new WakeLockContextHost(this));
return wake_lock_context_host_->GetWakeLockContext();
}
+void WebContentsImpl::ConnectToBlinkWakeLock(
+ device::mojom::WakeLockServiceRequest request) {
+ // WebContents creates a long-lived connection to one WakeLockServiceImpl.
+ // All the frames' requests are added into the BindingSet of
+ // WakeLockServiceImpl via this connection.
+ if (!blink_wake_lock_) {
+ device::mojom::WakeLockContext* wake_lock_context = GetWakeLockContext();
+ if (!wake_lock_context) {
+ return;
+ }
+ wake_lock_context->GetWakeLock(
+ device::PowerSaveBlocker::PowerSaveBlockerType::
+ kPowerSaveBlockPreventDisplaySleep,
+ device::PowerSaveBlocker::Reason::kReasonOther, "Wake Lock API",
+ mojo::MakeRequest(&blink_wake_lock_));
+ }
+ blink_wake_lock_->AddClient(std::move(request));
+}
+
void WebContentsImpl::OnShowValidationMessage(
RenderViewHostImpl* source,
const gfx::Rect& anchor_in_root_view,

Powered by Google App Engine
This is Rietveld 408576698