Roll Chrome into Mojo.

This roll corresponds to:
https://chromium.googlesource.com/chromium/src/+/d3cf92cac313434de99ae66f6e3e12d27ab536ef

GN now requires python_binary_module to be undefined rather than an empty string.

Context lines in cc_strip_video.patch changed.

Minor edits were required for sky:
Change to Skia header file organization.
SkRect::intersect now warns if ignored.

BUG=https://code.google.com/p/chromium/issues/detail?id=401761
R=jamesr@chromium.org

Review URL: https://codereview.chromium.org/839143002
diff --git a/ui/gl/gl_context_egl.cc b/ui/gl/gl_context_egl.cc
index 5dd1aaf..076de98 100644
--- a/ui/gl/gl_context_egl.cc
+++ b/ui/gl/gl_context_egl.cc
@@ -29,7 +29,8 @@
       context_(NULL),
       display_(NULL),
       config_(NULL),
-      unbind_fbo_on_makecurrent_(false) {
+      unbind_fbo_on_makecurrent_(false),
+      swap_interval_(1) {
 }
 
 bool GLContextEGL::Initialize(
@@ -125,6 +126,8 @@
     return false;
   }
 
+  surface->OnSetSwapInterval(swap_interval_);
+
   release_current.Cancel();
   return true;
 }
@@ -183,6 +186,9 @@
   if (!eglSwapInterval(display_, interval)) {
     LOG(ERROR) << "eglSwapInterval failed with error "
                << GetLastEGLErrorString();
+  } else {
+    swap_interval_ = interval;
+    GLSurface::GetCurrent()->OnSetSwapInterval(interval);
   }
 }
 
diff --git a/ui/gl/gl_context_egl.h b/ui/gl/gl_context_egl.h
index 99a4481..39b26d0 100644
--- a/ui/gl/gl_context_egl.h
+++ b/ui/gl/gl_context_egl.h
@@ -45,6 +45,7 @@
   EGLDisplay display_;
   EGLConfig config_;
   bool unbind_fbo_on_makecurrent_;
+  int swap_interval_;
 
   DISALLOW_COPY_AND_ASSIGN(GLContextEGL);
 };
diff --git a/ui/gl/gl_context_osmesa.cc b/ui/gl/gl_context_osmesa.cc
index d41a493..f08189c 100644
--- a/ui/gl/gl_context_osmesa.cc
+++ b/ui/gl/gl_context_osmesa.cc
@@ -7,7 +7,7 @@
 #include <GL/osmesa.h>
 
 #include "base/logging.h"
-#include "ui/gfx/size.h"
+#include "ui/gfx/geometry/size.h"
 #include "ui/gl/gl_bindings.h"
 #include "ui/gl/gl_surface.h"
 
diff --git a/ui/gl/gl_image.h b/ui/gl/gl_image.h
index 1dc99c3..2142413 100644
--- a/ui/gl/gl_image.h
+++ b/ui/gl/gl_image.h
@@ -6,11 +6,11 @@
 #define UI_GL_GL_IMAGE_H_
 
 #include "base/memory/ref_counted.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/rect_f.h"
+#include "ui/gfx/geometry/size.h"
 #include "ui/gfx/native_widget_types.h"
 #include "ui/gfx/overlay_transform.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/rect_f.h"
-#include "ui/gfx/size.h"
 #include "ui/gl/gl_export.h"
 
 namespace gfx {
diff --git a/ui/gl/gl_image_glx.h b/ui/gl/gl_image_glx.h
index f6031e2..1f4e819 100644
--- a/ui/gl/gl_image_glx.h
+++ b/ui/gl/gl_image_glx.h
@@ -5,7 +5,7 @@
 #ifndef UI_GL_GL_IMAGE_GLX_H_
 #define UI_GL_GL_IMAGE_GLX_H_
 
-#include "ui/gfx/size.h"
+#include "ui/gfx/geometry/size.h"
 #include "ui/gfx/x/x11_types.h"
 #include "ui/gl/gl_export.h"
 #include "ui/gl/gl_image.h"
diff --git a/ui/gl/gl_surface.cc b/ui/gl/gl_surface.cc
index f4cb61c..1ae458a 100644
--- a/ui/gl/gl_surface.cc
+++ b/ui/gl/gl_surface.cc
@@ -291,6 +291,9 @@
   return extensions.find(delimited_name) != std::string::npos;
 }
 
+void GLSurface::OnSetSwapInterval(int interval) {
+}
+
 GLSurfaceAdapter::GLSurfaceAdapter(GLSurface* surface) : surface_(surface) {}
 
 bool GLSurfaceAdapter::Initialize() {
diff --git a/ui/gl/gl_surface.h b/ui/gl/gl_surface.h
index 220bda6..48d7cd2 100644
--- a/ui/gl/gl_surface.h
+++ b/ui/gl/gl_surface.h
@@ -10,11 +10,11 @@
 #include "base/callback.h"
 #include "base/memory/ref_counted.h"
 #include "build/build_config.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/rect_f.h"
+#include "ui/gfx/geometry/size.h"
 #include "ui/gfx/native_widget_types.h"
 #include "ui/gfx/overlay_transform.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/rect_f.h"
-#include "ui/gfx/size.h"
 #include "ui/gl/gl_export.h"
 #include "ui/gl/gl_implementation.h"
 
@@ -162,6 +162,9 @@
 
   static GLSurface* GetCurrent();
 
+  // Called when the swap interval for the associated context changes.
+  virtual void OnSetSwapInterval(int interval);
+
  protected:
   virtual ~GLSurface();
   static bool InitializeOneOffImplementation(GLImplementation impl,
diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc
index 193eebf..1b670e1 100644
--- a/ui/gl/gl_surface_egl.cc
+++ b/ui/gl/gl_surface_egl.cc
@@ -57,6 +57,14 @@
 
 namespace gfx {
 
+#if defined(OS_WIN)
+unsigned int NativeViewGLSurfaceEGL::current_swap_generation_ = 0;
+unsigned int NativeViewGLSurfaceEGL::swaps_this_generation_ = 0;
+unsigned int NativeViewGLSurfaceEGL::last_multiswap_generation_ = 0;
+
+const unsigned int MULTISWAP_FRAME_VSYNC_THRESHOLD = 60;
+#endif
+
 namespace {
 
 EGLConfig g_config;
@@ -341,13 +349,16 @@
       surface_(NULL),
       supports_post_sub_buffer_(false),
       config_(NULL),
-      size_(1, 1) {
+      size_(1, 1),
+      swap_interval_(1) {
 #if defined(OS_ANDROID)
   if (window)
     ANativeWindow_acquire(window);
 #endif
 
 #if defined(OS_WIN)
+  vsync_override_ = false;
+  swap_generation_ = 0;
   RECT windowRect;
   if (GetClientRect(window_, &windowRect))
     size_ = gfx::Rect(windowRect).size();
@@ -505,6 +516,41 @@
       "width", GetSize().width(),
       "height", GetSize().height());
 
+#if defined(OS_WIN)
+  if (swap_interval_ != 0) {
+    // This code is a simple way of enforcing that we only vsync if one surface
+    // is swapping per frame. This provides single window cases a stable refresh
+    // while allowing multi-window cases to not slow down due to multiple syncs
+    // on a single thread. A better way to fix this problem would be to have
+    // each surface present on its own thread.
+
+    if (current_swap_generation_ == swap_generation_) {
+      if (swaps_this_generation_ > 1)
+        last_multiswap_generation_ = current_swap_generation_;
+      swaps_this_generation_ = 0;
+      current_swap_generation_++;
+    }
+
+    swap_generation_ = current_swap_generation_;
+
+    if (swaps_this_generation_ != 0 ||
+        (current_swap_generation_ - last_multiswap_generation_ <
+            MULTISWAP_FRAME_VSYNC_THRESHOLD)) {
+      // Override vsync settings and switch it off
+      if (!vsync_override_) {
+        eglSwapInterval(GetDisplay(), 0);
+        vsync_override_ = true;
+      }
+    } else if (vsync_override_) {
+      // Only one window swapping, so let the normal vsync setting take over
+      eglSwapInterval(GetDisplay(), swap_interval_);
+      vsync_override_ = false;
+    }
+
+    swaps_this_generation_++;
+  }
+#endif
+
   if (!eglSwapBuffers(GetDisplay(), surface_)) {
     DVLOG(1) << "eglSwapBuffers failed with error "
              << GetLastEGLErrorString();
@@ -585,6 +631,10 @@
   return vsync_provider_.get();
 }
 
+void NativeViewGLSurfaceEGL::OnSetSwapInterval(int interval) {
+  swap_interval_ = interval;
+}
+
 NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() {
   Destroy();
 #if defined(OS_ANDROID)
diff --git a/ui/gl/gl_surface_egl.h b/ui/gl/gl_surface_egl.h
index 720c7dd..b05f9bf 100644
--- a/ui/gl/gl_surface_egl.h
+++ b/ui/gl/gl_surface_egl.h
@@ -13,7 +13,7 @@
 
 #include "base/compiler_specific.h"
 #include "base/time/time.h"
-#include "ui/gfx/size.h"
+#include "ui/gfx/geometry/size.h"
 #include "ui/gfx/vsync_provider.h"
 #include "ui/gl/gl_bindings.h"
 #include "ui/gl/gl_surface.h"
@@ -83,6 +83,8 @@
 
   EGLNativeWindowType window_;
 
+  void OnSetSwapInterval(int interval) override;
+
  private:
   EGLSurface surface_;
   bool supports_post_sub_buffer_;
@@ -91,6 +93,17 @@
 
   scoped_ptr<VSyncProvider> vsync_provider_;
 
+  int swap_interval_;
+
+#if defined(OS_WIN)
+  bool vsync_override_;
+
+  unsigned int swap_generation_;
+  static unsigned int current_swap_generation_;
+  static unsigned int swaps_this_generation_;
+  static unsigned int last_multiswap_generation_;
+#endif
+
   DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL);
 };
 
diff --git a/ui/gl/gl_surface_glx.h b/ui/gl/gl_surface_glx.h
index 631d054..c1fca60 100644
--- a/ui/gl/gl_surface_glx.h
+++ b/ui/gl/gl_surface_glx.h
@@ -9,8 +9,8 @@
 
 #include "base/compiler_specific.h"
 #include "ui/events/platform/platform_event_dispatcher.h"
+#include "ui/gfx/geometry/size.h"
 #include "ui/gfx/native_widget_types.h"
-#include "ui/gfx/size.h"
 #include "ui/gfx/vsync_provider.h"
 #include "ui/gfx/x/x11_types.h"
 #include "ui/gl/gl_export.h"
diff --git a/ui/gl/gl_surface_osmesa.h b/ui/gl/gl_surface_osmesa.h
index 80d1087..cd65e65 100644
--- a/ui/gl/gl_surface_osmesa.h
+++ b/ui/gl/gl_surface_osmesa.h
@@ -6,7 +6,7 @@
 #define UI_GL_GL_SURFACE_OSMESA_H_
 
 #include "base/memory/scoped_ptr.h"
-#include "ui/gfx/size.h"
+#include "ui/gfx/geometry/size.h"
 #include "ui/gl/gl_surface.h"
 
 namespace gfx {
diff --git a/ui/gl/gl_surface_ozone.cc b/ui/gl/gl_surface_ozone.cc
index 67ab131..eecd064 100644
--- a/ui/gl/gl_surface_ozone.cc
+++ b/ui/gl/gl_surface_ozone.cc
@@ -30,10 +30,10 @@
         ozone_surface_(ozone_surface.Pass()),
         widget_(widget) {}
 
-  virtual bool Initialize() override {
+  bool Initialize() override {
     return Initialize(ozone_surface_->CreateVSyncProvider());
   }
-  virtual bool Resize(const gfx::Size& size) override {
+  bool Resize(const gfx::Size& size) override {
     if (!ozone_surface_->ResizeNativeWindow(size)) {
       if (!ReinitializeNativeSurface() ||
           !ozone_surface_->ResizeNativeWindow(size))
@@ -42,17 +42,17 @@
 
     return NativeViewGLSurfaceEGL::Resize(size);
   }
-  virtual bool SwapBuffers() override {
+  bool SwapBuffers() override {
     if (!NativeViewGLSurfaceEGL::SwapBuffers())
       return false;
 
     return ozone_surface_->OnSwapBuffers();
   }
-  virtual bool ScheduleOverlayPlane(int z_order,
-                                    OverlayTransform transform,
-                                    GLImage* image,
-                                    const Rect& bounds_rect,
-                                    const RectF& crop_rect) override {
+  bool ScheduleOverlayPlane(int z_order,
+                            OverlayTransform transform,
+                            GLImage* image,
+                            const Rect& bounds_rect,
+                            const RectF& crop_rect) override {
     return image->ScheduleOverlayPlane(
         widget_, z_order, transform, bounds_rect, crop_rect);
   }
@@ -60,7 +60,7 @@
  private:
   using NativeViewGLSurfaceEGL::Initialize;
 
-  virtual ~GLSurfaceOzoneEGL() {
+  ~GLSurfaceOzoneEGL() override {
     Destroy();  // EGL surface must be destroyed before SurfaceOzone
   }
 
@@ -107,7 +107,7 @@
         ozone_surface_(ozone_surface.Pass()),
         widget_(widget) {}
 
-  virtual bool Initialize() override {
+  bool Initialize() override {
     if (!SurfacelessEGL::Initialize())
       return false;
     vsync_provider_ = ozone_surface_->CreateVSyncProvider();
@@ -115,38 +115,48 @@
       return false;
     return true;
   }
-  virtual bool Resize(const gfx::Size& size) override {
+  bool Resize(const gfx::Size& size) override {
     if (!ozone_surface_->ResizeNativeWindow(size))
       return false;
 
     return SurfacelessEGL::Resize(size);
   }
-  virtual bool SwapBuffers() override {
+  bool SwapBuffers() override {
     // TODO: this should be replaced by a fence when supported by the driver.
     glFlush();
     return ozone_surface_->OnSwapBuffers();
   }
-  virtual bool ScheduleOverlayPlane(int z_order,
-                                    OverlayTransform transform,
-                                    GLImage* image,
-                                    const Rect& bounds_rect,
-                                    const RectF& crop_rect) override {
+  bool ScheduleOverlayPlane(int z_order,
+                            OverlayTransform transform,
+                            GLImage* image,
+                            const Rect& bounds_rect,
+                            const RectF& crop_rect) override {
     return image->ScheduleOverlayPlane(
         widget_, z_order, transform, bounds_rect, crop_rect);
   }
-  virtual bool IsOffscreen() override { return false; }
-  virtual VSyncProvider* GetVSyncProvider() override {
-    return vsync_provider_.get();
-  }
-  virtual bool SupportsPostSubBuffer() override { return true; }
-  virtual bool PostSubBuffer(int x, int y, int width, int height) override {
+  bool IsOffscreen() override { return false; }
+  VSyncProvider* GetVSyncProvider() override { return vsync_provider_.get(); }
+  bool SupportsPostSubBuffer() override { return true; }
+  bool PostSubBuffer(int x, int y, int width, int height) override {
     // The actual sub buffer handling is handled at higher layers.
     SwapBuffers();
     return true;
   }
+  bool SwapBuffersAsync(const SwapCompletionCallback& callback) override {
+    // TODO: this should be replaced by a fence when supported by the driver.
+    glFlush();
+    return ozone_surface_->OnSwapBuffersAsync(callback);
+  }
+  bool PostSubBufferAsync(int x,
+                          int y,
+                          int width,
+                          int height,
+                          const SwapCompletionCallback& callback) override {
+    return SwapBuffersAsync(callback);
+  }
 
  private:
-  virtual ~GLSurfaceOzoneSurfaceless() {
+  ~GLSurfaceOzoneSurfaceless() override {
     Destroy();  // EGL surface must be destroyed before SurfaceOzone
   }