Cleanse mojo/services/gles2 of InterfaceImpl

Now we use StrongBinding, which is the new hotness.

R=jamesr@chromium.org

Review URL: https://codereview.chromium.org/734273002
diff --git a/mojo/services/gles2/command_buffer_impl.cc b/mojo/services/gles2/command_buffer_impl.cc
index cd805e4..18d2f61 100644
--- a/mojo/services/gles2/command_buffer_impl.cc
+++ b/mojo/services/gles2/command_buffer_impl.cc
@@ -44,15 +44,18 @@
 }  // anonymous namespace
 
 CommandBufferImpl::CommandBufferImpl(
+    InterfaceRequest<CommandBuffer> request,
     gfx::GLShareGroup* share_group,
     gpu::gles2::MailboxManager* mailbox_manager)
-    : widget_(gfx::kNullAcceleratedWidget),
-      size_(1, 1),
-      share_group_(share_group),
-      mailbox_manager_(mailbox_manager) {
+    : CommandBufferImpl(request.Pass(),
+                        gfx::kNullAcceleratedWidget,
+                        gfx::Size(1, 1),
+                        share_group,
+                        mailbox_manager) {
 }
 
 CommandBufferImpl::CommandBufferImpl(
+    InterfaceRequest<CommandBuffer> request,
     gfx::AcceleratedWidget widget,
     const gfx::Size& size,
     gfx::GLShareGroup* share_group,
@@ -60,11 +63,12 @@
     : widget_(widget),
       size_(size),
       share_group_(share_group),
-      mailbox_manager_(mailbox_manager) {
+      mailbox_manager_(mailbox_manager),
+      binding_(this, request.Pass()) {
 }
 
 CommandBufferImpl::~CommandBufferImpl() {
-  client()->DidDestroy();
+  binding_.client()->DidDestroy();
   if (decoder_) {
     bool have_context = decoder_->MakeCurrent();
     decoder_->Destroy(have_context);
@@ -159,7 +163,7 @@
 void CommandBufferImpl::Flush(int32_t put_offset) {
   if (!context_->MakeCurrent(surface_.get())) {
     DLOG(WARNING) << "Context lost";
-    client()->LostContext(gpu::error::kUnknown);
+    binding_.client()->LostContext(gpu::error::kUnknown);
     return;
   }
   command_buffer_->Flush(put_offset);
@@ -196,7 +200,7 @@
 
 void CommandBufferImpl::OnParseError() {
   gpu::CommandBuffer::State state = command_buffer_->GetLastState();
-  client()->LostContext(state.context_lost_reason);
+  binding_.client()->LostContext(state.context_lost_reason);
 }
 
 void CommandBufferImpl::OnResize(gfx::Size size, float scale_factor) {
diff --git a/mojo/services/gles2/command_buffer_impl.h b/mojo/services/gles2/command_buffer_impl.h
index c67effa..fd133a8 100644
--- a/mojo/services/gles2/command_buffer_impl.h
+++ b/mojo/services/gles2/command_buffer_impl.h
@@ -8,6 +8,7 @@
 #include "base/macros.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/timer/timer.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
 #include "mojo/public/cpp/system/core.h"
 #include "mojo/services/public/interfaces/gpu/command_buffer.mojom.h"
 #include "ui/gfx/native_widget_types.h"
@@ -31,13 +32,15 @@
 
 namespace mojo {
 
-class CommandBufferImpl : public InterfaceImpl<CommandBuffer> {
+class CommandBufferImpl : public CommandBuffer {
  public:
   // Offscreen.
-  CommandBufferImpl(gfx::GLShareGroup* share_group,
+  CommandBufferImpl(InterfaceRequest<CommandBuffer> request,
+                    gfx::GLShareGroup* share_group,
                     gpu::gles2::MailboxManager* mailbox_manager);
   // Onscreen.
-  CommandBufferImpl(gfx::AcceleratedWidget widget,
+  CommandBufferImpl(InterfaceRequest<CommandBuffer> request,
+                    gfx::AcceleratedWidget widget,
                     const gfx::Size& size,
                     gfx::GLShareGroup* share_group,
                     gpu::gles2::MailboxManager* mailbox_manager);
@@ -73,6 +76,8 @@
   scoped_refptr<gfx::GLShareGroup> share_group_;
   scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_;
 
+  StrongBinding<CommandBuffer> binding_;
+
   DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl);
 };
 
diff --git a/mojo/services/gles2/gpu_impl.cc b/mojo/services/gles2/gpu_impl.cc
index f6df3d0..5cb89a7 100644
--- a/mojo/services/gles2/gpu_impl.cc
+++ b/mojo/services/gles2/gpu_impl.cc
@@ -12,9 +12,12 @@
 namespace mojo {
 
 GpuImpl::GpuImpl(
+    InterfaceRequest<Gpu> request,
     const scoped_refptr<gfx::GLShareGroup>& share_group,
     const scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager)
-    : share_group_(share_group), mailbox_manager_(mailbox_manager) {
+    : share_group_(share_group),
+      mailbox_manager_(mailbox_manager),
+      binding_(this, request.Pass()) {
 }
 
 GpuImpl::~GpuImpl() {
@@ -23,21 +26,17 @@
 void GpuImpl::CreateOnscreenGLES2Context(
     uint64_t native_viewport_id,
     SizePtr size,
-    InterfaceRequest<CommandBuffer> command_buffer_request) {
+    InterfaceRequest<CommandBuffer> request) {
   gfx::AcceleratedWidget widget = bit_cast<gfx::AcceleratedWidget>(
       static_cast<uintptr_t>(native_viewport_id));
-  BindToRequest(new CommandBufferImpl(widget,
-                                      size.To<gfx::Size>(),
-                                      share_group_.get(),
-                                      mailbox_manager_.get()),
-                &command_buffer_request);
+  new CommandBufferImpl(request.Pass(), widget, size.To<gfx::Size>(),
+                        share_group_.get(), mailbox_manager_.get());
 }
 
 void GpuImpl::CreateOffscreenGLES2Context(
-    InterfaceRequest<CommandBuffer> command_buffer_request) {
-  BindToRequest(
-      new CommandBufferImpl(share_group_.get(), mailbox_manager_.get()),
-      &command_buffer_request);
+    InterfaceRequest<CommandBuffer> request) {
+  new CommandBufferImpl(request.Pass(), share_group_.get(),
+                        mailbox_manager_.get());
 }
 
 }  // namespace mojo
diff --git a/mojo/services/gles2/gpu_impl.h b/mojo/services/gles2/gpu_impl.h
index 0949f74..62a8af6 100644
--- a/mojo/services/gles2/gpu_impl.h
+++ b/mojo/services/gles2/gpu_impl.h
@@ -4,8 +4,8 @@
 
 #include "base/macros.h"
 #include "base/memory/ref_counted.h"
-#include "mojo/public/cpp/bindings/interface_impl.h"
 #include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
 #include "mojo/services/public/interfaces/geometry/geometry.mojom.h"
 #include "mojo/services/public/interfaces/gpu/command_buffer.mojom.h"
 #include "mojo/services/public/interfaces/gpu/gpu.mojom.h"
@@ -22,9 +22,10 @@
 
 namespace mojo {
 
-class GpuImpl : public InterfaceImpl<Gpu> {
+class GpuImpl : public Gpu {
  public:
-  GpuImpl(const scoped_refptr<gfx::GLShareGroup>& share_group,
+  GpuImpl(InterfaceRequest<Gpu> request,
+          const scoped_refptr<gfx::GLShareGroup>& share_group,
           const scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager);
 
   ~GpuImpl() override;
@@ -43,6 +44,8 @@
   scoped_refptr<gfx::GLShareGroup> share_group_;
   scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_;
 
+  StrongBinding<Gpu> binding_;
+
   DISALLOW_COPY_AND_ASSIGN(GpuImpl);
 };
 
diff --git a/mojo/services/native_viewport/main.cc b/mojo/services/native_viewport/main.cc
index 6b6a9af..7146270 100644
--- a/mojo/services/native_viewport/main.cc
+++ b/mojo/services/native_viewport/main.cc
@@ -61,8 +61,7 @@
   // InterfaceFactory<Gpu> implementation.
   void Create(ApplicationConnection* connection,
               InterfaceRequest<Gpu> request) override {
-    BindToRequest(new GpuImpl(share_group_.get(), mailbox_manager_.get()),
-                  &request);
+    new GpuImpl(request.Pass(), share_group_.get(), mailbox_manager_.get());
   }
 
   ApplicationImpl* app_;
diff --git a/mojo/shell/context.cc b/mojo/shell/context.cc
index c9fa227..5771fb6 100644
--- a/mojo/shell/context.cc
+++ b/mojo/shell/context.cc
@@ -164,8 +164,7 @@
   // InterfaceFactory<Gpu> implementation.
   virtual void Create(ApplicationConnection* connection,
                       InterfaceRequest<Gpu> request) override {
-    BindToRequest(new GpuImpl(share_group_.get(), mailbox_manager_.get()),
-                  &request);
+    new GpuImpl(request.Pass(), share_group_.get(), mailbox_manager_.get());
   }
 
   scoped_refptr<gfx::GLShareGroup> share_group_;