summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-12 19:51:22 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-12 19:51:22 +0000
commit9193034b79e3dea131a859e136302cf5ec3e44ff (patch)
treecc0250a101b32c945172ae4108e1ad1b26474a37
parent6dfa3014196eb06386074ea2a15906921ce12e4f (diff)
downloadchromium_src-9193034b79e3dea131a859e136302cf5ec3e44ff.zip
chromium_src-9193034b79e3dea131a859e136302cf5ec3e44ff.tar.gz
chromium_src-9193034b79e3dea131a859e136302cf5ec3e44ff.tar.bz2
Fix --single-process mode issues with GpuChannelHostFactory
GpuChannelHostFactory itself is no longer a singleton, we pass it explicitly to WebGraphicsContext3DCommandBufferImpl. That prevents RenderThreadImpl and BrowserGpuChannelHostFactory from stomping on each other in --single-process mode BUG=117594 TEST=see bug Review URL: http://codereview.chromium.org/9667012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126194 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/gpu/browser_gpu_channel_host_factory.cc13
-rw-r--r--content/browser/gpu/browser_gpu_channel_host_factory.h6
-rw-r--r--content/browser/in_process_webkit/browser_webkitplatformsupport_impl.cc8
-rw-r--r--content/browser/in_process_webkit/browser_webkitplatformsupport_impl.h5
-rw-r--r--content/browser/renderer_host/image_transport_factory.cc9
-rw-r--r--content/common/gpu/client/gpu_channel_host.cc6
-rw-r--r--content/common/gpu/client/gpu_channel_host.h11
-rw-r--r--content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc10
-rw-r--r--content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h5
-rw-r--r--content/common/webkitplatformsupport_impl.cc11
-rw-r--r--content/common/webkitplatformsupport_impl.h5
-rw-r--r--content/renderer/render_thread_impl.cc2
-rw-r--r--content/renderer/render_view_impl.cc2
-rw-r--r--content/renderer/renderer_webkitplatformsupport_impl.cc5
-rw-r--r--content/renderer/renderer_webkitplatformsupport_impl.h3
15 files changed, 61 insertions, 40 deletions
diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.cc b/content/browser/gpu/browser_gpu_channel_host_factory.cc
index 687ef0c..5f20475 100644
--- a/content/browser/gpu/browser_gpu_channel_host_factory.cc
+++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc
@@ -15,6 +15,8 @@
namespace content {
+BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL;
+
BrowserGpuChannelHostFactory::CreateRequest::CreateRequest()
: event(false, false),
route_id(MSG_ROUTING_NONE) {
@@ -32,27 +34,22 @@ BrowserGpuChannelHostFactory::EstablishRequest::~EstablishRequest() {
}
void BrowserGpuChannelHostFactory::Initialize() {
- new BrowserGpuChannelHostFactory();
+ instance_ = new BrowserGpuChannelHostFactory();
}
void BrowserGpuChannelHostFactory::Terminate() {
- delete instance();
-}
-
-BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::Get() {
- return static_cast<BrowserGpuChannelHostFactory*>(instance());
+ delete instance_;
+ instance_ = NULL;
}
BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory()
: gpu_client_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()),
shutdown_event_(new base::WaitableEvent(true, false)),
gpu_host_id_(0) {
- set_instance(this);
}
BrowserGpuChannelHostFactory::~BrowserGpuChannelHostFactory() {
shutdown_event_->Signal();
- set_instance(NULL);
}
bool BrowserGpuChannelHostFactory::IsMainThread() {
diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.h b/content/browser/gpu/browser_gpu_channel_host_factory.h
index f9a7bd6..cfb4e6a 100644
--- a/content/browser/gpu/browser_gpu_channel_host_factory.h
+++ b/content/browser/gpu/browser_gpu_channel_host_factory.h
@@ -19,7 +19,7 @@ class BrowserGpuChannelHostFactory : public GpuChannelHostFactory {
public:
static void Initialize();
static void Terminate();
- static BrowserGpuChannelHostFactory* Get();
+ static BrowserGpuChannelHostFactory* instance() { return instance_; }
// GpuChannelHostFactory implementation.
virtual bool IsMainThread() OVERRIDE;
@@ -35,8 +35,6 @@ class BrowserGpuChannelHostFactory : public GpuChannelHostFactory {
virtual GpuChannelHost* EstablishGpuChannelSync(
CauseForGpuLaunch cause_for_gpu_launch) OVERRIDE;
- int gpu_client_id() { return gpu_client_id_; }
-
private:
struct CreateRequest {
CreateRequest();
@@ -75,6 +73,8 @@ class BrowserGpuChannelHostFactory : public GpuChannelHostFactory {
scoped_refptr<GpuChannelHost> gpu_channel_;
int gpu_host_id_;
+ static BrowserGpuChannelHostFactory* instance_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory);
};
diff --git a/content/browser/in_process_webkit/browser_webkitplatformsupport_impl.cc b/content/browser/in_process_webkit/browser_webkitplatformsupport_impl.cc
index 58e6322..73c15a7 100644
--- a/content/browser/in_process_webkit/browser_webkitplatformsupport_impl.cc
+++ b/content/browser/in_process_webkit/browser_webkitplatformsupport_impl.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,6 +6,7 @@
#include "base/file_util.h"
#include "base/logging.h"
+#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
#include "content/browser/in_process_webkit/dom_storage_message_filter.h"
#include "content/browser/in_process_webkit/indexed_db_key_utility_client.h"
#include "content/common/indexed_db/indexed_db_key.h"
@@ -176,3 +177,8 @@ BrowserWebKitPlatformSupportImpl::injectIDBKeyIntoSerializedValue(
return IndexedDBKeyUtilityClient::InjectIDBKeyIntoSerializedValue(
IndexedDBKey(key), content::SerializedScriptValue(value), keyPath);
}
+
+GpuChannelHostFactory*
+BrowserWebKitPlatformSupportImpl::GetGpuChannelHostFactory() {
+ return content::BrowserGpuChannelHostFactory::instance();
+}
diff --git a/content/browser/in_process_webkit/browser_webkitplatformsupport_impl.h b/content/browser/in_process_webkit/browser_webkitplatformsupport_impl.h
index fe95b3b..c1ebe39 100644
--- a/content/browser/in_process_webkit/browser_webkitplatformsupport_impl.h
+++ b/content/browser/in_process_webkit/browser_webkitplatformsupport_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -56,6 +56,9 @@ class BrowserWebKitPlatformSupportImpl :
const WebKit::WebSerializedScriptValue& value,
const WebKit::WebString& keyPath);
+ protected:
+ virtual GpuChannelHostFactory* GetGpuChannelHostFactory() OVERRIDE;
+
private:
webkit_glue::WebFileUtilitiesImpl file_utilities_;
};
diff --git a/content/browser/renderer_host/image_transport_factory.cc b/content/browser/renderer_host/image_transport_factory.cc
index cb074a5..b8b79ed 100644
--- a/content/browser/renderer_host/image_transport_factory.cc
+++ b/content/browser/renderer_host/image_transport_factory.cc
@@ -12,6 +12,7 @@
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "content/browser/gpu/gpu_surface_tracker.h"
+#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
#include "content/browser/renderer_host/image_transport_client.h"
#include "content/common/gpu/client/command_buffer_proxy.h"
#include "content/common/gpu/client/gpu_channel_host.h"
@@ -26,6 +27,8 @@
#include "ui/gfx/size.h"
#include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
+using content::BrowserGpuChannelHostFactory;
+
namespace {
ImageTransportFactory* g_factory;
@@ -233,9 +236,10 @@ class GpuProcessTransportFactory : public ui::ContextFactory,
WebKit::WebGraphicsContext3D::Attributes attrs;
attrs.shareResources = true;
+ GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance();
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
new WebGraphicsContext3DCommandBufferImpl(
- data->surface_id, GURL(), data->swap_client->AsWeakPtr()));
+ data->surface_id, GURL(), factory, data->swap_client->AsWeakPtr()));
if (!context->Initialize(attrs))
return NULL;
return context.release();
@@ -362,10 +366,11 @@ class GpuProcessTransportFactory : public ui::ContextFactory,
data->swap_client.reset(new CompositorSwapClient(compositor, this));
+ GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance();
WebKit::WebGraphicsContext3D::Attributes attrs;
attrs.shareResources = true;
data->shared_context.reset(new WebGraphicsContext3DCommandBufferImpl(
- data->surface_id, GURL(), data->swap_client->AsWeakPtr()));
+ data->surface_id, GURL(), factory, data->swap_client->AsWeakPtr()));
if (!data->shared_context->Initialize(attrs)) {
// If we can't recreate contexts, we won't be able to show the UI. Better
// crash at this point.
diff --git a/content/common/gpu/client/gpu_channel_host.cc b/content/common/gpu/client/gpu_channel_host.cc
index 1a83423..bb9ccd6 100644
--- a/content/common/gpu/client/gpu_channel_host.cc
+++ b/content/common/gpu/client/gpu_channel_host.cc
@@ -12,12 +12,6 @@
#include "googleurl/src/gurl.h"
#include "ipc/ipc_sync_message_filter.h"
-GpuChannelHostFactory* GpuChannelHostFactory::instance_ = NULL;
-
-GpuChannelHostFactory::~GpuChannelHostFactory() {
- DCHECK(!instance_);
-}
-
using base::AutoLock;
using base::MessageLoopProxy;
diff --git a/content/common/gpu/client/gpu_channel_host.h b/content/common/gpu/client/gpu_channel_host.h
index ef8e438..0a4e178 100644
--- a/content/common/gpu/client/gpu_channel_host.h
+++ b/content/common/gpu/client/gpu_channel_host.h
@@ -51,8 +51,7 @@ struct GpuListenerInfo {
class CONTENT_EXPORT GpuChannelHostFactory {
public:
- virtual ~GpuChannelHostFactory();
- static GpuChannelHostFactory* instance() { return instance_; }
+ virtual ~GpuChannelHostFactory() {}
virtual bool IsMainThread() = 0;
virtual bool IsIOThread() = 0;
@@ -64,14 +63,6 @@ class CONTENT_EXPORT GpuChannelHostFactory {
int32 surface_id, const GPUCreateCommandBufferConfig& init_params) = 0;
virtual GpuChannelHost* EstablishGpuChannelSync(
content::CauseForGpuLaunch) = 0;
-
- protected:
- static void set_instance(GpuChannelHostFactory* instance) {
- instance_ = instance;
- }
-
- private:
- static GpuChannelHostFactory* instance_;
};
// Encapsulates an IPC channel between the client and one GPU process.
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
index c2f6d60..6ce0afa 100644
--- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
+++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc
@@ -48,8 +48,10 @@ void ClearSharedContexts() {
WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
int surface_id,
const GURL& active_url,
+ GpuChannelHostFactory* factory,
const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client)
: initialize_failed_(false),
+ factory_(factory),
context_(NULL),
gl_(NULL),
host_(NULL),
@@ -88,8 +90,7 @@ bool WebGraphicsContext3DCommandBufferImpl::Initialize(
const WebGraphicsContext3D::Attributes& attributes) {
DCHECK(!context_);
TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::initialize");
- GpuChannelHostFactory* factory = GpuChannelHostFactory::instance();
- if (!factory)
+ if (!factory_)
return false;
if (attributes.preferDiscreteGPU)
@@ -99,7 +100,7 @@ bool WebGraphicsContext3DCommandBufferImpl::Initialize(
// Note similar code in Pepper PlatformContext3DImpl::Init.
do {
- host_ = factory->EstablishGpuChannelSync(
+ host_ = factory_->EstablishGpuChannelSync(
content::
CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE);
if (!host_)
@@ -1113,8 +1114,7 @@ void WebGraphicsContext3DCommandBufferImpl::deleteTexture(WebGLId texture) {
}
bool WebGraphicsContext3DCommandBufferImpl::ShouldUseSwapClient() {
- GpuChannelHostFactory* factory = GpuChannelHostFactory::instance();
- return factory && factory->IsMainThread() && swap_client_.get();
+ return factory_ && factory_->IsMainThread() && swap_client_.get();
}
void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() {
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
index 31a5c81..7b0755b 100644
--- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
+++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h
@@ -24,6 +24,7 @@
#endif
class GpuChannelHost;
+class GpuChannelHostFactory;
namespace gpu {
namespace gles2 {
@@ -61,6 +62,7 @@ class WebGraphicsContext3DCommandBufferImpl
WebGraphicsContext3DCommandBufferImpl(
int surface_id,
const GURL& active_url,
+ GpuChannelHostFactory* factory,
const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client);
virtual ~WebGraphicsContext3DCommandBufferImpl();
@@ -509,6 +511,9 @@ class WebGraphicsContext3DCommandBufferImpl
bool initialize_failed_;
+ // The channel factory to talk to the GPU process
+ GpuChannelHostFactory* factory_;
+
// The context we use for OpenGL rendering.
ContentGLContext* context_;
// The GLES2Implementation we use for OpenGL rendering.
diff --git a/content/common/webkitplatformsupport_impl.cc b/content/common/webkitplatformsupport_impl.cc
index 0b83378..7d7cd79 100644
--- a/content/common/webkitplatformsupport_impl.cc
+++ b/content/common/webkitplatformsupport_impl.cc
@@ -61,12 +61,21 @@ WebKitPlatformSupportImpl::createOffscreenGraphicsContext3D(
attributes, false);
} else {
base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> null_client;
+ GpuChannelHostFactory* factory = GetGpuChannelHostFactory();
+ if (!factory)
+ return NULL;
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
- new WebGraphicsContext3DCommandBufferImpl(0, GURL(), null_client));
+ new WebGraphicsContext3DCommandBufferImpl(
+ 0, GURL(), factory, null_client));
if (!context->Initialize(attributes))
return NULL;
return context.release();
}
}
+GpuChannelHostFactory* WebKitPlatformSupportImpl::GetGpuChannelHostFactory() {
+ NOTREACHED();
+ return NULL;
+}
+
} // namespace content
diff --git a/content/common/webkitplatformsupport_impl.h b/content/common/webkitplatformsupport_impl.h
index 6cadfde..d92d4b4 100644
--- a/content/common/webkitplatformsupport_impl.h
+++ b/content/common/webkitplatformsupport_impl.h
@@ -10,6 +10,8 @@
#include "content/common/content_export.h"
#include "webkit/glue/webkitplatformsupport_impl.h"
+class GpuChannelHostFactory;
+
namespace content {
// This is a specialization of WebKitPlatformSupportImpl that implements the
@@ -32,6 +34,9 @@ class CONTENT_EXPORT WebKitPlatformSupportImpl
webkit_glue::WebSocketStreamHandleDelegate* delegate) OVERRIDE;
virtual WebKit::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
const WebKit::WebGraphicsContext3D::Attributes& attributes);
+
+ protected:
+ virtual GpuChannelHostFactory* GetGpuChannelHostFactory();
};
} // namespace content
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 273508e3..aa0c55e 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -184,7 +184,6 @@ void RenderThreadImpl::Init() {
#endif
lazy_tls.Pointer()->Set(this);
- GpuChannelHostFactory::set_instance(this);
#if defined(OS_WIN)
// If you are running plugins in this thread you need COM active but in
@@ -282,7 +281,6 @@ RenderThreadImpl::~RenderThreadImpl() {
if (webkit_platform_support_.get())
WebKit::shutdown();
- GpuChannelHostFactory::set_instance(NULL);
lazy_tls.Pointer()->Set(NULL);
// TODO(port)
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 336e296..57eb84f 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -1570,7 +1570,7 @@ WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D(
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
new WebGraphicsContext3DCommandBufferImpl(
- surface, url, swap_client));
+ surface, url, RenderThreadImpl::current(), swap_client));
if (!context->Initialize(attributes))
return NULL;
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc
index be296d0..b8df27a 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -677,3 +677,8 @@ RendererWebKitPlatformSupportImpl::createMediaStreamCenter(
return NULL;
return render_thread->CreateMediaStreamCenter(client);
}
+
+GpuChannelHostFactory*
+RendererWebKitPlatformSupportImpl::GetGpuChannelHostFactory() {
+ return RenderThreadImpl::current();
+}
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.h b/content/renderer/renderer_webkitplatformsupport_impl.h
index ce4a61c..929c312 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.h
+++ b/content/renderer/renderer_webkitplatformsupport_impl.h
@@ -97,6 +97,9 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
virtual WebKit::WebMediaStreamCenter* createMediaStreamCenter(
WebKit::WebMediaStreamCenterClient* client) OVERRIDE;
+ protected:
+ virtual GpuChannelHostFactory* GetGpuChannelHostFactory() OVERRIDE;
+
private:
bool CheckPreparsedJsCachingEnabled() const;