diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-20 22:20:20 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-20 22:20:20 +0000 |
commit | f717ea6403554cc60a5dd9312fe585cdf64a8815 (patch) | |
tree | 523186875fe4c36bcc1c6905b3da36943a174318 /chrome/plugin/plugin_thread.cc | |
parent | e74b81de4f2785b5cff5cb0cc85e76b3d434248e (diff) | |
download | chromium_src-f717ea6403554cc60a5dd9312fe585cdf64a8815.zip chromium_src-f717ea6403554cc60a5dd9312fe585cdf64a8815.tar.gz chromium_src-f717ea6403554cc60a5dd9312fe585cdf64a8815.tar.bz2 |
Switch the first thread in a child process to be the main thread, and make the IO thread be the second thread. The change is needed for plugins on mac.
Review URL: http://codereview.chromium.org/149558
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21117 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/plugin_thread.cc')
-rw-r--r-- | chrome/plugin/plugin_thread.cc | 56 |
1 files changed, 15 insertions, 41 deletions
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc index a595776..552362d 100644 --- a/chrome/plugin/plugin_thread.cc +++ b/chrome/plugin/plugin_thread.cc @@ -6,11 +6,6 @@ #include "build/build_config.h" -#if defined(OS_WIN) -#include <windows.h> -#include <objbase.h> -#endif - #include "base/command_line.h" #include "base/lazy_instance.h" #include "base/process_util.h" @@ -18,7 +13,6 @@ #include "chrome/common/child_process.h" #include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/notification_service.h" #include "chrome/common/plugin_messages.h" #include "chrome/common/render_messages.h" #include "chrome/plugin/chrome_plugin_host.h" @@ -32,27 +26,10 @@ static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls( base::LINKER_INITIALIZED); PluginThread::PluginThread() - : ChildThread(base::Thread::Options(MessageLoop::TYPE_UI, 0)), - preloaded_plugin_module_(NULL) { + : preloaded_plugin_module_(NULL) { plugin_path_ = FilePath::FromWStringHack( CommandLine::ForCurrentProcess()->GetSwitchValue(switches::kPluginPath)); -} - -PluginThread::~PluginThread() { -} - -PluginThread* PluginThread::current() { - return lazy_tls.Pointer()->Get(); -} - -void PluginThread::OnControlMessageReceived(const IPC::Message& msg) { - IPC_BEGIN_MESSAGE_MAP(PluginThread, msg) - IPC_MESSAGE_HANDLER(PluginProcessMsg_CreateChannel, OnCreateChannel) - IPC_MESSAGE_HANDLER(PluginProcessMsg_PluginMessage, OnPluginMessage) - IPC_END_MESSAGE_MAP() -} -void PluginThread::Init() { lazy_tls.Pointer()->Set(this); #if defined(OS_LINUX) { @@ -75,14 +52,8 @@ void PluginThread::Init() { } } #endif - ChildThread::Init(); PatchNPNFunctions(); -#if defined(OS_WIN) - CoInitialize(NULL); -#endif - - notification_service_.reset(new NotificationService); // Preload the library to avoid loading, unloading then reloading preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path_); @@ -100,7 +71,7 @@ void PluginThread::Init() { message_loop()->set_exception_restoration(true); } -void PluginThread::CleanUp() { +PluginThread::~PluginThread() { if (preloaded_plugin_module_) { base::UnloadNativeLibrary(preloaded_plugin_module_); preloaded_plugin_module_ = NULL; @@ -108,26 +79,29 @@ void PluginThread::CleanUp() { PluginChannelBase::CleanupChannels(); NPAPI::PluginLib::UnloadAllPlugins(); ChromePluginLib::UnloadAllPlugins(); - notification_service_.reset(); -#if defined(OS_WIN) - CoUninitialize(); -#endif if (webkit_glue::ShouldForcefullyTerminatePluginProcess()) base::KillProcess(base::GetCurrentProcessHandle(), 0, /* wait= */ false); - // Call this last because it deletes the ResourceDispatcher, which is used - // in some of the above cleanup. - // See http://code.google.com/p/chromium/issues/detail?id=8980 - ChildThread::CleanUp(); lazy_tls.Pointer()->Set(NULL); } +PluginThread* PluginThread::current() { + return lazy_tls.Pointer()->Get(); +} + +void PluginThread::OnControlMessageReceived(const IPC::Message& msg) { + IPC_BEGIN_MESSAGE_MAP(PluginThread, msg) + IPC_MESSAGE_HANDLER(PluginProcessMsg_CreateChannel, OnCreateChannel) + IPC_MESSAGE_HANDLER(PluginProcessMsg_PluginMessage, OnPluginMessage) + IPC_END_MESSAGE_MAP() +} + void PluginThread::OnCreateChannel( int process_id, bool off_the_record) { - scoped_refptr<PluginChannel> channel = - PluginChannel::GetPluginChannel(process_id, owner_loop()); + scoped_refptr<PluginChannel> channel = PluginChannel::GetPluginChannel( + process_id, ChildProcess::current()->io_message_loop()); IPC::ChannelHandle channel_handle; if (channel.get()) { channel_handle.name = channel->channel_name(); |