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

Unified Diff: content/renderer/browser_plugin/browser_plugin_registry.cc

Issue 9968097: Browser Plugin: Renderer-side changes (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updated after merging with ToT Created 8 years, 7 months 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
Index: content/renderer/browser_plugin/browser_plugin_registry.cc
diff --git a/content/renderer/browser_plugin/browser_plugin_registry.cc b/content/renderer/browser_plugin/browser_plugin_registry.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6dc68353a1cc020572578a4577006cbf7fb4149b
--- /dev/null
+++ b/content/renderer/browser_plugin/browser_plugin_registry.cc
@@ -0,0 +1,42 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/browser_plugin/browser_plugin_registry.h"
+
+#include "base/logging.h"
+
+namespace content {
+
+webkit::ppapi::PluginModule* BrowserPluginRegistry::GetModule(
+ int guest_process_id) {
+ NonOwningModuleMap::iterator it = modules_.find(guest_process_id);
+ if (it == modules_.end())
+ return NULL;
+ return it->second;
+}
+
+void BrowserPluginRegistry::AddModule(int guest_process_id,
+ webkit::ppapi::PluginModule* module) {
+ DCHECK(modules_.find(guest_process_id) == modules_.end());
+ modules_[guest_process_id] = module;
+}
+
+void BrowserPluginRegistry::PluginModuleDead(
+ webkit::ppapi::PluginModule* dead_module) {
+ // DANGER: Don't dereference the dead_module pointer! It may be in the
+ // process of being deleted.
+
+ // Modules aren't destroyed very often and there are normally at most a
+ // couple of them. So for now we just do a brute-force search.
+ for (NonOwningModuleMap::iterator i = modules_.begin();
+ i != modules_.end(); ++i) {
+ if (i->second == dead_module) {
+ modules_.erase(i);
+ return;
+ }
+ }
+ NOTREACHED(); // Should have always found the module above.
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698