summaryrefslogtreecommitdiffstats
path: root/chrome/plugin
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-15 18:30:30 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-15 18:30:30 +0000
commit94f9a0f686619656ca4ff2b6511179dc2132cc5d (patch)
tree26051806295528d68b4e5e65a0f39eaac18f7a24 /chrome/plugin
parent1b5d23dfa22d8858dc9ab35d373fcf328aadbcba (diff)
downloadchromium_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/plugin')
-rw-r--r--chrome/plugin/plugin_thread.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc
index 08c96c9..cb92de4 100644
--- a/chrome/plugin/plugin_thread.cc
+++ b/chrome/plugin/plugin_thread.cc
@@ -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() {
}
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::OnControlMessageReceived(const IPC::Message& msg) {
}
void PluginThread::Init() {
+ lazy_tls.Pointer()->Set(this);
ChildThread::Init();
PatchNPNFunctions();
@@ -95,6 +99,7 @@ void PluginThread::CleanUp() {
// 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) {