GLContext no longer holds a pointer to a GLSurface.

This is part of an ongoing effort to treat GL contexts and GL surfaces as independent entities.

TEST=run WebGL on mac, windows and linux, trybots
BUG=none
Review URL: http://codereview.chromium.org/7021014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86332 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/gpu/gpu_info_collector.cc b/content/gpu/gpu_info_collector.cc
index 07a5f1c15..80c98fa 100644
--- a/content/gpu/gpu_info_collector.cc
+++ b/content/gpu/gpu_info_collector.cc
@@ -18,13 +18,7 @@
 
 namespace {
 
-// This creates an offscreen GL context for gl queries.  Returned GLContext
-// should be deleted in FinalizeGLContext.
-gfx::GLContext* InitializeGLContext() {
-  if (!gfx::GLSurface::InitializeOneOff()) {
-    LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed";
-    return NULL;
-  }
+gfx::GLSurface* InitializeGLSurface() {
   scoped_ptr<gfx::GLSurface> surface(gfx::GLSurface::CreateOffscreenGLSurface(
       gfx::Size(1, 1)));
   if (!surface.get()) {
@@ -32,15 +26,19 @@
     return NULL;
   }
 
-  scoped_ptr<gfx::GLContext> context(gfx::GLContext::CreateGLContext(
-      surface.release(),
-      NULL));
+  return surface.release();
+}
+
+gfx::GLContext* InitializeGLContext(gfx::GLSurface* surface) {
+
+  scoped_ptr<gfx::GLContext> context(gfx::GLContext::CreateGLContext(NULL,
+                                                                     surface));
   if (!context.get()) {
     LOG(ERROR) << "gfx::GLContext::CreateGLContext failed";
     return NULL;
   }
 
-  if (!context->MakeCurrent()) {
+  if (!context->MakeCurrent(surface)) {
     LOG(ERROR) << "gfx::GLContext::MakeCurrent() failed";
     return NULL;
   }
@@ -81,7 +79,16 @@
 bool CollectGraphicsInfoGL(GPUInfo* gpu_info) {
   DCHECK(gpu_info);
 
-  scoped_ptr<gfx::GLContext> context(InitializeGLContext());
+  if (!gfx::GLSurface::InitializeOneOff()) {
+    LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed";
+    return false;
+  }
+
+  scoped_ptr<gfx::GLSurface> surface(InitializeGLSurface());
+  if (!surface.get())
+    return false;
+
+  scoped_ptr<gfx::GLContext> context(InitializeGLContext(surface.get()));
   if (!context.get())
     return false;