diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-20 05:23:36 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-20 05:23:36 +0000 |
commit | 514e711ea07b6a1aef47ebf20250a37bd632402c (patch) | |
tree | 632f5e8902cc4231e9c14d0ad28035d63a0c964d /chrome/plugin/plugin_process.cc | |
parent | 4acbad918766b81f1da3f10e2ae8aa2b10bb0593 (diff) | |
download | chromium_src-514e711ea07b6a1aef47ebf20250a37bd632402c.zip chromium_src-514e711ea07b6a1aef47ebf20250a37bd632402c.tar.gz chromium_src-514e711ea07b6a1aef47ebf20250a37bd632402c.tar.bz2 |
Refactor code from RenderThread and PluginThread and move it to ChildThread. ChildProcess now owns the ChildThread, which removes duplicate code and simplifies things.
Clean up ChildProcess, there really was no need for all the templates and statics in it and its subclasses.
Review URL: http://codereview.chromium.org/21502
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10080 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/plugin_process.cc')
-rw-r--r-- | chrome/plugin/plugin_process.cc | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/chrome/plugin/plugin_process.cc b/chrome/plugin/plugin_process.cc index fe19b9b..9d0f567 100644 --- a/chrome/plugin/plugin_process.cc +++ b/chrome/plugin/plugin_process.cc @@ -13,20 +13,6 @@ #include "chrome/common/render_messages.h" #include "webkit/glue/webkit_glue.h" -// Custom factory to allow us to pass additional ctor arguments. -class PluginProcessFactory : public ChildProcessFactoryInterface { - public: - explicit PluginProcessFactory(const FilePath& plugin_path) - : plugin_path_(plugin_path) { - } - - virtual ChildProcess* Create(const std::wstring& channel_name) { - return new PluginProcess(channel_name, plugin_path_); - } - - const FilePath& plugin_path_; -}; - // How long to wait after there are no more plugin instances before killing the // process. static const int kProcessShutdownDelayMs = 10 * 1000; @@ -39,31 +25,21 @@ template <> struct RunnableMethodTraits<PluginProcess> { static void ReleaseCallee(PluginProcess*) {} }; -PluginProcess::PluginProcess(const std::wstring& channel_name, - const FilePath& plugin_path) : - plugin_path_(plugin_path), -#pragma warning(suppress: 4355) // Okay to pass "this" here. - plugin_thread_(this, channel_name) { +PluginProcess::PluginProcess() + : ChildProcess(new PluginThread()) { } PluginProcess::~PluginProcess() { } -bool PluginProcess::GlobalInit(const std::wstring &channel_name, - const FilePath &plugin_path) { - PluginProcessFactory factory(plugin_path); - return ChildProcess::GlobalInit(channel_name, &factory); -} - - // Note: may be called on any thread void PluginProcess::OnFinalRelease() { // We override this to have the process linger for a few seconds to // better accomdate back/forth navigation. This avoids shutting down and // immediately starting a new plugin process. If a new channel is // opened in the interim, the current process will not be shutdown. - main_thread_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod( - this, &PluginProcess::OnProcessShutdownTimeout), + child_thread()->owner_loop()->PostDelayedTask(FROM_HERE, NewRunnableMethod( + this, &PluginProcess::OnProcessShutdownTimeout), kProcessShutdownDelayMs); } @@ -74,25 +50,10 @@ void PluginProcess::OnProcessShutdownTimeout() { // process host instance in the browser to verify if it is ok to shutdown // the plugin process. The browser then sends back a response indicating // whether it is ok to shutdown. - plugin_thread_.Send(new PluginProcessHostMsg_ShutdownRequest); - } -} - -// static -void PluginProcess::ShutdownProcessResponse(bool ok_to_shutdown) { - if (ok_to_shutdown) { - PluginProcess* plugin_process = - static_cast<PluginProcess*>(child_process_); - DCHECK(plugin_process); - plugin_process->Shutdown(); + child_thread()->Send(new PluginProcessHostMsg_ShutdownRequest); } } -void PluginProcess::BrowserShutdown() { - ShutdownProcessResponse(true); -} - void PluginProcess::Shutdown() { ChildProcess::OnFinalRelease(); } - |