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 webkit::ppapi::PluginModule* BrowserPluginRegistry::GetModule( |
| 12 int guest_process_id) { |
| 13 return modules_.Lookup(guest_process_id); |
| 14 } |
| 15 |
| 16 void BrowserPluginRegistry::AddModule(int guest_process_id, |
| 17 webkit::ppapi::PluginModule* module) { |
| 18 modules_.AddWithID(module, guest_process_id); |
| 19 } |
| 20 |
| 21 void BrowserPluginRegistry::PluginModuleDead( |
| 22 webkit::ppapi::PluginModule* dead_module) { |
| 23 // DANGER: Don't dereference the dead_module pointer! It may be in the |
| 24 // process of being deleted. |
| 25 |
| 26 // Modules aren't destroyed very often and there are normally at most a |
| 27 // couple of them. So for now we just do a brute-force search. |
| 28 IDMap<webkit::ppapi::PluginModule>::iterator iter(&modules_); |
| 29 while (!iter.IsAtEnd()) { |
| 30 if (iter.GetCurrentValue() == dead_module) { |
| 31 modules_.Remove(iter.GetCurrentKey()); |
| 32 return; |
| 33 } |
| 34 iter.Advance(); |
| 35 } |
| 36 NOTREACHED(); // Should have always found the module above. |
| 37 } |
| 38 |
| 39 } // namespace content |
OLD | NEW |