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

Unified Diff: chrome/renderer/render_thread.cc

Issue 1660: Move a bunch of code from the old to new TLS interface. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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/renderer/render_thread.h ('k') | no next file » | 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 1894)
+++ chrome/renderer/render_thread.cc (working copy)
@@ -7,7 +7,9 @@
#include "chrome/renderer/render_thread.h"
+#include "base/lazy_instance.h"
#include "base/shared_memory.h"
+#include "base/thread_local.h"
#include "chrome/common/ipc_logging.h"
#include "chrome/common/notification_service.h"
#include "chrome/plugin/plugin_channel.h"
@@ -22,13 +24,17 @@
// V8 needs a 1MB stack size.
static const size_t kStackSize = 1024 * 1024;
-// TODO(evanm): don't rely on static initialization.
-// static
-TLSSlot RenderThread::tls_index_;
+static base::LazyInstance<base::ThreadLocalPointer<RenderThread> >
+ lazy_tls_ptr(base::LINKER_INITIALIZED);
//-----------------------------------------------------------------------------
// Methods below are only called on the owner's thread:
+// static
+RenderThread* RenderThread::current() {
+ return lazy_tls_ptr.Pointer()->Get();
+}
+
RenderThread::RenderThread(const std::wstring& channel_name)
: Thread("Chrome_RenderThread"),
channel_name_(channel_name),
@@ -99,7 +105,7 @@
IPC::Channel::MODE_CLIENT, this, NULL, owner_loop_, true,
RenderProcess::GetShutDownEvent()));
- tls_index_.Set(this);
+ lazy_tls_ptr.Pointer()->Set(this);
// The renderer thread should wind-up COM.
CoInitialize(0);
« no previous file with comments | « chrome/renderer/render_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698