Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2316)

Unified Diff: content/renderer/pepper/pepper_plugin_registry.cc

Issue 69363002: Pepper: Tighten GetLiveModule in PluginRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/pepper_plugin_registry.cc
diff --git a/content/renderer/pepper/pepper_plugin_registry.cc b/content/renderer/pepper/pepper_plugin_registry.cc
index c40294bfbcfc9fc78419b1fdfa85aa79a30739fb..5939ce16d23c3827909b38f283c9337bac643321 100644
--- a/content/renderer/pepper/pepper_plugin_registry.cc
+++ b/content/renderer/pepper/pepper_plugin_registry.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "content/common/pepper_plugin_list.h"
+#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
#include "content/renderer/pepper/plugin_module.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
@@ -43,10 +44,29 @@ const PepperPluginInfo* PepperPluginRegistry::GetInfoForPlugin(
}
PluginModule* PepperPluginRegistry::GetLiveModule(const base::FilePath& path) {
- NonOwningModuleMap::iterator it = live_modules_.find(path);
- if (it == live_modules_.end())
+ NonOwningModuleMap::iterator module_iter = live_modules_.find(path);
+ if (module_iter == live_modules_.end())
return NULL;
- return it->second;
+
+ // Check the instances for the module to see if they've all been Delete()d.
+ // We don't want to return a PluginModule in that case, since the plugin may
+ // have exited already.
+ const PluginModule::PluginInstanceSet& instance_set =
+ module_iter->second->GetAllInstances();
+
+ // If instance_set is empty, InstanceCreated() hasn't been called yet, so
+ // it's safe to return the PluginModule.
+ if (instance_set.empty())
+ return module_iter->second;
+
+ PluginModule::PluginInstanceSet::const_iterator instance_iter =
+ instance_set.begin();
+ while (instance_iter != instance_set.end()) {
+ if (!(*instance_iter)->is_deleted())
+ return module_iter->second;
+ ++instance_iter;
+ }
+ return NULL;
}
void PepperPluginRegistry::AddLiveModule(const base::FilePath& path,
« no previous file with comments | « content/renderer/pepper/pepper_plugin_instance_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698