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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698