summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-23 22:51:46 +0000
committermpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-23 22:51:46 +0000
commit020f5bad1085d21d6ad912241ae3669ef1a9375f (patch)
treeb20ad4173a6117abe3c5c6b54a550fda49338d90 /chrome
parentd4f7e76644f684d0e9395fa8225e0d1c607de241 (diff)
downloadchromium_src-020f5bad1085d21d6ad912241ae3669ef1a9375f.zip
chromium_src-020f5bad1085d21d6ad912241ae3669ef1a9375f.tar.gz
chromium_src-020f5bad1085d21d6ad912241ae3669ef1a9375f.tar.bz2
Add an accessor to get the CPAPI main plugin thread's MessageLoop. Use that
to fix a crash in renderer/chrome_plugin_host.cc. Review URL: http://codereview.chromium.org/4050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2528 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/common/chrome_plugin_lib.cc8
-rw-r--r--chrome/common/chrome_plugin_lib.h3
-rw-r--r--chrome/renderer/chrome_plugin_host.cc2
3 files changed, 12 insertions, 1 deletions
diff --git a/chrome/common/chrome_plugin_lib.cc b/chrome/common/chrome_plugin_lib.cc
index 402075f..ae8964d 100644
--- a/chrome/common/chrome_plugin_lib.cc
+++ b/chrome/common/chrome_plugin_lib.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/hash_tables.h"
#include "base/histogram.h"
+#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/perftimer.h"
#include "base/registry.h"
@@ -31,6 +32,7 @@ static PluginMap* g_loaded_libs;
// The thread plugins are loaded and used in, lazily initialized upon
// the first creation call.
static DWORD g_plugin_thread_id = 0;
+static MessageLoop* g_plugin_thread_loop = NULL;
static bool IsSingleProcessMode() {
// We don't support ChromePlugins in single-process mode.
@@ -45,6 +47,7 @@ ChromePluginLib* ChromePluginLib::Create(const std::wstring& filename,
if (!g_loaded_libs) {
g_loaded_libs = new PluginMap();
g_plugin_thread_id = ::GetCurrentThreadId();
+ g_plugin_thread_loop = MessageLoop::current();
}
DCHECK(IsPluginThread());
@@ -89,6 +92,11 @@ bool ChromePluginLib::IsPluginThread() {
}
// static
+MessageLoop* ChromePluginLib::GetPluginThreadLoop() {
+ return g_plugin_thread_loop;
+}
+
+// static
void ChromePluginLib::RegisterPluginsWithNPAPI() {
// We don't support ChromePlugins in single-process mode.
if (IsSingleProcessMode())
diff --git a/chrome/common/chrome_plugin_lib.h b/chrome/common/chrome_plugin_lib.h
index 41c672b..f58b9c8 100644
--- a/chrome/common/chrome_plugin_lib.h
+++ b/chrome/common/chrome_plugin_lib.h
@@ -12,6 +12,8 @@
#include "base/scoped_ptr.h"
#include "chrome/common/chrome_plugin_api.h"
+class MessageLoop;
+
// A ChromePluginLib is a single Chrome Plugin Library.
// This class is used in the browser process (IO thread), and the plugin process
// (plugin thread). It should not be accessed on other threads, because it
@@ -23,6 +25,7 @@ class ChromePluginLib : public base::RefCounted<ChromePluginLib> {
static ChromePluginLib* Find(const std::wstring& filename);
static void Destroy(const std::wstring& filename);
static bool IsPluginThread();
+ static MessageLoop* GetPluginThreadLoop();
static ChromePluginLib* FromCPID(CPID id) {
return reinterpret_cast<ChromePluginLib*>(id);
diff --git a/chrome/renderer/chrome_plugin_host.cc b/chrome/renderer/chrome_plugin_host.cc
index 66d4d04..9de6669 100644
--- a/chrome/renderer/chrome_plugin_host.cc
+++ b/chrome/renderer/chrome_plugin_host.cc
@@ -524,7 +524,7 @@ CPError STDCALL CPB_SendSyncMessage(CPID id, const void *data, uint32 data_len,
CPError STDCALL CPB_PluginThreadAsyncCall(CPID id,
void (*func)(void *),
void *user_data) {
- MessageLoop *message_loop = RenderThread::current()->message_loop();
+ MessageLoop *message_loop = ChromePluginLib::GetPluginThreadLoop();
if (!message_loop) {
return CPERR_FAILURE;
}