diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-15 18:30:30 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-15 18:30:30 +0000 |
commit | 94f9a0f686619656ca4ff2b6511179dc2132cc5d (patch) | |
tree | 26051806295528d68b4e5e65a0f39eaac18f7a24 /chrome/renderer/render_thread.cc | |
parent | 1b5d23dfa22d8858dc9ab35d373fcf328aadbcba (diff) | |
download | chromium_src-94f9a0f686619656ca4ff2b6511179dc2132cc5d.zip chromium_src-94f9a0f686619656ca4ff2b6511179dc2132cc5d.tar.gz chromium_src-94f9a0f686619656ca4ff2b6511179dc2132cc5d.tar.bz2 |
Switch child threads so that current() only works on the correct thread and the correct process.
Review URL: http://codereview.chromium.org/126086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18409 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_thread.cc')
-rw-r--r-- | chrome/renderer/render_thread.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 1f72aed..e615a49 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -8,8 +8,10 @@ #include <vector> #include "base/command_line.h" +#include "base/lazy_instance.h" #include "base/shared_memory.h" #include "base/stats_table.h" +#include "base/thread_local.h" #include "chrome/common/app_cache/app_cache_context_impl.h" #include "chrome/common/app_cache/app_cache_dispatcher.h" #include "chrome/common/chrome_switches.h" @@ -57,6 +59,9 @@ using WebKit::WebString; static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */; +static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls( + base::LINKER_INITIALIZED); + //----------------------------------------------------------------------------- // Methods below are only called on the owner's thread: @@ -81,8 +86,7 @@ RenderThread::~RenderThread() { } RenderThread* RenderThread::current() { - DCHECK(!IsPluginProcess()); - return static_cast<RenderThread*>(ChildThread::current()); + return lazy_tls.Pointer()->Get(); } void RenderThread::AddFilter(IPC::ChannelProxy::MessageFilter* filter) { @@ -128,6 +132,7 @@ class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter { #endif void RenderThread::Init() { + lazy_tls.Pointer()->Set(this); #if defined(OS_WIN) // If you are running plugins in this thread you need COM active but in // the normal case you don't. @@ -172,8 +177,8 @@ void RenderThread::CleanUp() { } notification_service_.reset(); - ChildThread::CleanUp(); + lazy_tls.Pointer()->Set(NULL); // TODO(port) #if defined(OS_WIN) |