Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10251)

Unified Diff: chrome/renderer/render_thread.cc

Issue 126086: Switch child threads so that current() only works on the correct thread and t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/plugin/plugin_thread.cc ('k') | chrome/renderer/render_thread_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_thread.cc
===================================================================
--- chrome/renderer/render_thread.cc (revision 18344)
+++ chrome/renderer/render_thread.cc (working copy)
@@ -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 @@
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::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 @@
#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 @@
}
notification_service_.reset();
-
ChildThread::CleanUp();
+ lazy_tls.Pointer()->Set(NULL);
// TODO(port)
#if defined(OS_WIN)
« no previous file with comments | « chrome/plugin/plugin_thread.cc ('k') | chrome/renderer/render_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698