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

Unified Diff: chrome/plugin/plugin_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 | « no previous file | chrome/renderer/render_thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/plugin/plugin_thread.cc
===================================================================
--- chrome/plugin/plugin_thread.cc (revision 18344)
+++ chrome/plugin/plugin_thread.cc (working copy)
@@ -12,7 +12,9 @@
#endif
#include "base/command_line.h"
+#include "base/lazy_instance.h"
#include "base/process_util.h"
+#include "base/thread_local.h"
#include "chrome/common/child_process.h"
#include "chrome/common/chrome_plugin_lib.h"
#include "chrome/common/chrome_switches.h"
@@ -26,6 +28,8 @@
#include "webkit/glue/plugins/plugin_lib.h"
#include "webkit/glue/webkit_glue.h"
+static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls(
+ base::LINKER_INITIALIZED);
PluginThread::PluginThread()
: ChildThread(base::Thread::Options(MessageLoop::TYPE_UI, 0)),
@@ -38,8 +42,7 @@
}
PluginThread* PluginThread::current() {
- DCHECK(IsPluginProcess());
- return static_cast<PluginThread*>(ChildThread::current());
+ return lazy_tls.Pointer()->Get();
}
void PluginThread::OnControlMessageReceived(const IPC::Message& msg) {
@@ -50,6 +53,7 @@
}
void PluginThread::Init() {
+ lazy_tls.Pointer()->Set(this);
ChildThread::Init();
PatchNPNFunctions();
@@ -95,6 +99,7 @@
// in some of the above cleanup.
// See http://code.google.com/p/chromium/issues/detail?id=8980
ChildThread::CleanUp();
+ lazy_tls.Pointer()->Set(NULL);
}
void PluginThread::OnCreateChannel(int process_id, bool off_the_record) {
« no previous file with comments | « no previous file | chrome/renderer/render_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698