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 NonOwningModuleMap::iterator it = modules_.find(guest_process_id); |
| 14 if (it == modules_.end()) |
| 15 return NULL; |
| 16 return it->second; |
| 17 } |
| 18 |
| 19 void BrowserPluginRegistry::AddModule(int guest_process_id, |
| 20 webkit::ppapi::PluginModule* module) { |
| 21 DCHECK(modules_.find(guest_process_id) == modules_.end()); |
| 22 modules_[guest_process_id] = module; |
| 23 } |
| 24 |
| 25 void BrowserPluginRegistry::PluginModuleDead( |
| 26 webkit::ppapi::PluginModule* dead_module) { |
| 27 // DANGER: Don't dereference the dead_module pointer! It may be in the |
| 28 // process of being deleted. |
| 29 |
| 30 // Modules aren't destroyed very often and there are normally at most a |
| 31 // couple of them. So for now we just do a brute-force search. |
| 32 for (NonOwningModuleMap::iterator i = modules_.begin(); |
| 33 i != modules_.end(); ++i) { |
| 34 if (i->second == dead_module) { |
| 35 modules_.erase(i); |
| 36 return; |
| 37 } |
| 38 } |
| 39 NOTREACHED(); // Should have always found the module above. |
| 40 } |
| 41 |
| 42 } // namespace content |
OLD | NEW |