aura: Allow in process ContextProvider to hold onscreen contexts.

This will allow us to use them in an OutputSurface. For the
common offscreen context case, we want to still share code
so add a CreateOffscreen() method to the context provider
so we don't have to replicate the WGC3D::Attributes decisions
around the codebase.

[email protected]
BUG=258625

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217677 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/webkit/common/gpu/context_provider_in_process.h b/webkit/common/gpu/context_provider_in_process.h
index b427abeb..169a1a8f 100644
--- a/webkit/common/gpu/context_provider_in_process.h
+++ b/webkit/common/gpu/context_provider_in_process.h
@@ -19,17 +19,21 @@
 namespace webkit {
 namespace gpu {
 class GrContextForWebGraphicsContext3D;
+class WebGraphicsContext3DInProcessCommandBufferImpl;
 
 class WEBKIT_GPU_EXPORT ContextProviderInProcess
     : NON_EXPORTED_BASE(public cc::ContextProvider) {
  public:
-  static scoped_refptr<ContextProviderInProcess> Create() {
-    scoped_refptr<ContextProviderInProcess> provider =
-        new ContextProviderInProcess;
-    if (!provider->InitializeOnMainThread())
-      return NULL;
-    return provider;
-  }
+  typedef base::Callback<
+      scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(void)>
+      CreateCallback;
+
+  static scoped_refptr<ContextProviderInProcess> Create(
+      const CreateCallback& create_callback);
+
+  // Calls Create() with a default factory method for creating an offscreen
+  // context.
+  static scoped_refptr<ContextProviderInProcess> CreateOffscreen();
 
   virtual bool BindToCurrentThread() OVERRIDE;
   virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE;
@@ -43,7 +47,8 @@
   ContextProviderInProcess();
   virtual ~ContextProviderInProcess();
 
-  bool InitializeOnMainThread();
+  bool InitializeOnMainThread(
+      const CreateCallback& create_callback);
 
   void OnLostContext();
   void OnMemoryAllocationChanged(bool nonzero_allocation);