Disable rendering when suspending on chrome os

New chrome os devices are going to make more frequent use of the dark
resume state - a hybrid power state where several hardware devices are
left off to save power.  One of these is the display.  Unfortunately
this creates issues with chrome, which believes that the display is on
and attempts to render things to the screen.  These calls fail in the
kernel and trigger a logical memory leak in the error handling code in
the GPU process.

In order to make this interaction more robust, have chrome stop sending
rendering requests at suspend time and restart them at resume time.
There are a few things to watch out for here.  If the user has requested
that the screen be locked at suspend time then rendering cannot be
stopped until the screen locker is visible.  Otherwise the contents of
the user's screen will be visible at resume time, which is a security
issue.  Additionally, the suspend must be delayed until any pending
requests have been handled by the GPU process to prevent a race where
the system suspends before all requests have been processed and they end
up being processed when the system later enters dark resume, triggering
the memory leak mentioned in the previous paragraph.

BUG=chrome-os-partner:35699

Review URL: https://codereview.chromium.org/910393002

Cr-Commit-Position: refs/heads/master@{#316946}
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index ea04b8c..5f2a43b 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -224,6 +224,10 @@
   host_->SetNeedsCommit();
 }
 
+void Compositor::FinishAllRendering() {
+  host_->FinishAllRendering();
+}
+
 void Compositor::DisableSwapUntilResize() {
   host_->FinishAllRendering();
   context_factory_->ResizeDisplay(this, gfx::Size());
@@ -260,6 +264,10 @@
   host_->SetVisible(visible);
 }
 
+bool Compositor::IsVisible() {
+  return host_->visible();
+}
+
 scoped_refptr<CompositorVSyncManager> Compositor::vsync_manager() const {
   return vsync_manager_;
 }