summaryrefslogtreecommitdiffstats
path: root/chrome/browser/plugin_service.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-13 23:16:42 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-13 23:16:42 +0000
commita436d92d5121ebfc9996682cfed4c3ad33313138 (patch)
tree55c32ef45ccc9e808e98074b5a26565239ed06fc /chrome/browser/plugin_service.cc
parentb2ca508afc56d4b7f6d5b036dd721604440210b3 (diff)
downloadchromium_src-a436d92d5121ebfc9996682cfed4c3ad33313138.zip
chromium_src-a436d92d5121ebfc9996682cfed4c3ad33313138.tar.gz
chromium_src-a436d92d5121ebfc9996682cfed4c3ad33313138.tar.bz2
Have ChildProcessInfo contain a list of all running child processes (i.e. instead of Service and other child process service maintain it). In a future change I'll start moving some of the code from PluginProcessHost to ChildProcessInfo.
Review URL: http://codereview.chromium.org/24017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9804 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/plugin_service.cc')
-rw-r--r--chrome/browser/plugin_service.cc64
1 files changed, 12 insertions, 52 deletions
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index d36cc69..87d2aeb 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/plugin_service.h"
#include "base/command_line.h"
-#include "base/singleton.h"
#include "base/thread.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_plugin_host.h"
@@ -30,7 +29,6 @@ PluginService::PluginService()
plugin_shutdown_handler_(new ShutdownHandler) {
// Have the NPAPI plugin list search for Chrome plugins as well.
ChromePluginLib::RegisterPluginsWithNPAPI();
-
// Load the one specified on the command line as well.
const CommandLine* command_line = CommandLine::ForCurrentProcess();
std::wstring path = command_line->GetSwitchValue(switches::kLoadPlugin);
@@ -77,9 +75,13 @@ PluginProcessHost* PluginService::FindPluginProcess(
return NULL;
}
- PluginMap::iterator found = plugin_hosts_.find(plugin_path);
- if (found != plugin_hosts_.end())
- return found->second;
+ for (ChildProcessInfo::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
+ !iter.Done(); ++iter) {
+ PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter);
+ if (plugin->info().path == plugin_path)
+ return plugin;
+ }
+
return NULL;
}
@@ -100,13 +102,13 @@ PluginProcessHost* PluginService::FindOrStartPluginProcess(
}
// This plugin isn't loaded by any plugin process, so create a new process.
- plugin_host = new PluginProcessHost(this);
+ plugin_host = new PluginProcessHost();
if (!plugin_host->Init(info, clsid, ui_locale_)) {
DCHECK(false); // Init is not expected to fail
delete plugin_host;
return NULL;
}
- plugin_hosts_[plugin_path] = plugin_host;
+
return plugin_host;
// TODO(jabdelmalek): adding a new channel means we can have one less
@@ -133,31 +135,6 @@ void PluginService::OpenChannelToPlugin(
}
}
-void PluginService::OnPluginProcessIsShuttingDown(PluginProcessHost* host) {
- RemoveHost(host);
-}
-
-void PluginService::OnPluginProcessExited(PluginProcessHost* host) {
- RemoveHost(host); // in case shutdown was not graceful
- delete host;
-}
-
-void PluginService::RemoveHost(PluginProcessHost* host) {
- DCHECK(MessageLoop::current() ==
- ChromeThread::GetMessageLoop(ChromeThread::IO));
- // Search for the instance rather than lookup by plugin path,
- // there is a small window where two instances for the same
- // plugin path can co-exists.
- PluginMap::iterator i = plugin_hosts_.begin();
- while (i != plugin_hosts_.end()) {
- if (i->second == host) {
- plugin_hosts_.erase(i);
- return;
- }
- i++;
- }
-}
-
FilePath PluginService::GetPluginPath(const GURL& url,
const std::string& mime_type,
const std::string& clsid,
@@ -193,29 +170,12 @@ void PluginService::Shutdown() {
}
void PluginService::OnShutdown() {
- PluginMap::iterator host_index;
- for (host_index = plugin_hosts_.begin(); host_index != plugin_hosts_.end();
- ++host_index) {
- host_index->second->Shutdown();
+ for (ChildProcessInfo::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
+ !iter.Done(); ++iter) {
+ static_cast<PluginProcessHost*>(*iter)->Shutdown();
}
}
-PluginProcessHostIterator::PluginProcessHostIterator()
- : iterator_(PluginService::GetInstance()->plugin_hosts_.begin()),
- end_(PluginService::GetInstance()->plugin_hosts_.end()) {
- DCHECK(MessageLoop::current() ==
- ChromeThread::GetMessageLoop(ChromeThread::IO)) <<
- "PluginProcessHostIterator must be used on the IO thread.";
-}
-
-PluginProcessHostIterator::PluginProcessHostIterator(
- const PluginProcessHostIterator& instance)
- : iterator_(instance.iterator_) {
- DCHECK(MessageLoop::current() ==
- ChromeThread::GetMessageLoop(ChromeThread::IO)) <<
- "PluginProcessHostIterator must be used on the IO thread.";
-}
-
void PluginService::ShutdownHandler::InitiateShutdown() {
g_browser_process->io_thread()->message_loop()->PostTask(
FROM_HERE,