OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/renderer/browser_plugin/browser_plugin_registry.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 |
| 9 namespace content { |
| 10 |
| 11 BrowserPluginRegistry::BrowserPluginRegistry() { |
| 12 } |
| 13 |
| 14 BrowserPluginRegistry::~BrowserPluginRegistry() { |
| 15 } |
| 16 |
| 17 webkit::ppapi::PluginModule* BrowserPluginRegistry::GetModule( |
| 18 int guest_process_id) { |
| 19 return modules_.Lookup(guest_process_id); |
| 20 } |
| 21 |
| 22 void BrowserPluginRegistry::AddModule(int guest_process_id, |
| 23 webkit::ppapi::PluginModule* module) { |
| 24 modules_.AddWithID(module, guest_process_id); |
| 25 } |
| 26 |
| 27 void BrowserPluginRegistry::PluginModuleDead( |
| 28 webkit::ppapi::PluginModule* dead_module) { |
| 29 // DANGER: Don't dereference the dead_module pointer! It may be in the |
| 30 // process of being deleted. |
| 31 |
| 32 // Modules aren't destroyed very often and there are normally at most a |
| 33 // couple of them. So for now we just do a brute-force search. |
| 34 IDMap<webkit::ppapi::PluginModule>::iterator iter(&modules_); |
| 35 while (!iter.IsAtEnd()) { |
| 36 if (iter.GetCurrentValue() == dead_module) { |
| 37 modules_.Remove(iter.GetCurrentKey()); |
| 38 return; |
| 39 } |
| 40 iter.Advance(); |
| 41 } |
| 42 NOTREACHED(); // Should have always found the module above. |
| 43 } |
| 44 |
| 45 } // namespace content |
OLD | NEW |