summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-13 01:43:34 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-13 01:43:34 +0000
commit7951bfe3854423b11bee1d40bf83843b64f082ad (patch)
tree45ece678eb129d1b9dfc24f0bb205d73a6f8355f /content/browser
parent4d90d439351de6a038b7e6e75f17e4ab31aa7056 (diff)
downloadchromium_src-7951bfe3854423b11bee1d40bf83843b64f082ad.zip
chromium_src-7951bfe3854423b11bee1d40bf83843b64f082ad.tar.gz
chromium_src-7951bfe3854423b11bee1d40bf83843b64f082ad.tar.bz2
Restore thread safety to GpuChannelHost.
RefCountedThreadSafe + SupportsWeakPtr is generally a bad combo. This changes how thread safety is handled in GpuChannelHost: - Shared data/state set by the IO thread is moved onto the MessageFilter, protected by a lock. - MessageFilter doesn't need to post tasks to the GpuChannelHost on the main thread. - Most of the GpuChannelHost fields are constant, the remaining ones are atomic or protected by a lock. It also includes various cleanup: - Reduced the scope of some locks. In particular we mostly avoid taking locks while sending messages. - Removed GpuChannelHostFactory::IsIOThread which isn't used. - Simplifies channel state. We always are "connected" until we are "lost". A behavior change is that the "lost" state is set directly on the IO thread, as soon as we receive the channel error. This makes recreation logic less dependent on precise task order. BUG=242826 R=apatrick@chromium.org Review URL: https://codereview.chromium.org/16228004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205992 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/gpu/browser_gpu_channel_host_factory.cc15
-rw-r--r--content/browser/gpu/browser_gpu_channel_host_factory.h1
2 files changed, 4 insertions, 12 deletions
diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.cc b/content/browser/gpu/browser_gpu_channel_host_factory.cc
index cda1c34..05159d2 100644
--- a/content/browser/gpu/browser_gpu_channel_host_factory.cc
+++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc
@@ -62,10 +62,6 @@ bool BrowserGpuChannelHostFactory::IsMainThread() {
return BrowserThread::CurrentlyOn(BrowserThread::UI);
}
-bool BrowserGpuChannelHostFactory::IsIOThread() {
- return BrowserThread::CurrentlyOn(BrowserThread::IO);
-}
-
base::MessageLoop* BrowserGpuChannelHostFactory::GetMainLoop() {
return BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::UI);
}
@@ -253,7 +249,7 @@ GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync(
CauseForGpuLaunch cause_for_gpu_launch) {
if (gpu_channel_.get()) {
// Recreate the channel if it has been lost.
- if (gpu_channel_->state() == GpuChannelHost::kLost)
+ if (gpu_channel_->IsLost())
gpu_channel_ = NULL;
else
return gpu_channel_.get();
@@ -281,13 +277,10 @@ GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync(
if (request.channel_handle.name.empty())
return NULL;
- gpu_channel_ = new GpuChannelHost(this, request.gpu_host_id, gpu_client_id_);
- gpu_channel_->set_gpu_info(request.gpu_info);
GetContentClient()->SetGpuInfo(request.gpu_info);
-
- // Connect to the GPU process if a channel name was received.
- gpu_channel_->Connect(request.channel_handle);
-
+ gpu_channel_ = GpuChannelHost::Create(
+ this, request.gpu_host_id, gpu_client_id_,
+ request.gpu_info, request.channel_handle);
return gpu_channel_.get();
}
diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.h b/content/browser/gpu/browser_gpu_channel_host_factory.h
index 5a28fad..abd7483 100644
--- a/content/browser/gpu/browser_gpu_channel_host_factory.h
+++ b/content/browser/gpu/browser_gpu_channel_host_factory.h
@@ -22,7 +22,6 @@ class BrowserGpuChannelHostFactory : public GpuChannelHostFactory {
// GpuChannelHostFactory implementation.
virtual bool IsMainThread() OVERRIDE;
- virtual bool IsIOThread() OVERRIDE;
virtual base::MessageLoop* GetMainLoop() OVERRIDE;
virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() OVERRIDE;
virtual base::WaitableEvent* GetShutDownEvent() OVERRIDE;