summaryrefslogtreecommitdiffstats
path: root/content/renderer/browser_plugin/old/browser_plugin_registry.cc
blob: 823fd80e71412d28463ca339d4dad65288e18bd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// 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/old/browser_plugin_registry.h"

#include "base/logging.h"

namespace content {

BrowserPluginRegistry::BrowserPluginRegistry() {
}

BrowserPluginRegistry::~BrowserPluginRegistry() {
}

webkit::ppapi::PluginModule* BrowserPluginRegistry::GetModule(
    int guest_process_id) {
  return modules_.Lookup(guest_process_id);
}

void BrowserPluginRegistry::AddModule(int guest_process_id,
                                      webkit::ppapi::PluginModule* module) {
  modules_.AddWithID(module, guest_process_id);
}

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.
  IDMap<webkit::ppapi::PluginModule>::iterator iter(&modules_);
  while (!iter.IsAtEnd()) {
    if (iter.GetCurrentValue() == dead_module) {
      modules_.Remove(iter.GetCurrentKey());
      return;
    }
    iter.Advance();
  }
  NOTREACHED();  // Should have always found the module above.
}

}  // namespace content