Move ownership of PowerSaveBlocker from WakeLockServiceContext to WakeLockServiceImpl

This is the first step of "Allowing WakeLock to Serve Browser Process Clients"
Design doc by [email protected]:
https://docs.google.com/document/d/1AEmiwtEj1nfTCmqSneht0xad2k3huxZQsIRHvVz0S8c

In this CL:

1) Move ownership of PowerSaveBlocker from WakeLockServiceContext to
   WakeLockServiceImpl.
2) Refactor WakeLockServiceImpl, one WakeLockServiceImpl supports managing
   multiple client bindings.
3) Make WebContentsImpl coalesce multiple client requests into one
   WakeLockServiceImpl.

The concrete motivation for this move is to make it trivial to implement a
generalization of the GetWakeLock() API that passes in the parameters for the
PowerSaveBlocker (needed by browser process clients). That interface extension
would be complex to implement in the current architecture, which is multiplexing
one PowerSaveBlocker for multiple WakeLockServiceImpl instances.

BUG=689410
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation

Review-Url: https://codereview.chromium.org/2843353003
Cr-Commit-Position: refs/heads/master@{#470241}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index a107c23..6cee92c 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2622,12 +2622,26 @@
   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();
 }
 
+device::mojom::WakeLockService* WebContentsImpl::GetRendererWakeLock() {
+  // WebContents creates a long-lived connection to one WakeLockServiceImpl.
+  // All the frames' requests will be added into the BindingSet of
+  // WakeLockServiceImpl via this connection.
+  if (!renderer_wake_lock_) {
+    device::mojom::WakeLockContext* wake_lock_context = GetWakeLockContext();
+    if (!wake_lock_context) {
+      return nullptr;
+    }
+    wake_lock_context->GetWakeLock(mojo::MakeRequest(&renderer_wake_lock_));
+  }
+  return renderer_wake_lock_.get();
+}
+
 void WebContentsImpl::OnShowValidationMessage(
     RenderViewHostImpl* source,
     const gfx::Rect& anchor_in_root_view,