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

Unified Diff: content/renderer/browser_plugin/browser_plugin_manager.cc

Issue 10830072: Browser Plugin: New Implementation (Renderer Side) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initialize content shell resources Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/browser_plugin/browser_plugin_manager.cc
diff --git a/content/renderer/browser_plugin/browser_plugin_manager.cc b/content/renderer/browser_plugin/browser_plugin_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..06fe358292692ba93518e4b056c7100420fee5eb
--- /dev/null
+++ b/content/renderer/browser_plugin/browser_plugin_manager.cc
@@ -0,0 +1,47 @@
+// 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/browser_plugin_manager.h"
+
+#include "base/lazy_instance.h"
+#include "base/threading/thread_local.h"
+#include "content/public/renderer/render_thread.h"
+#include "content/renderer/browser_plugin/browser_plugin.h"
+
+namespace content {
+
+static base::LazyInstance<base::ThreadLocalPointer<
+ BrowserPluginManager> > lazy_tls = LAZY_INSTANCE_INITIALIZER;
+
+BrowserPluginManager* BrowserPluginManager::Get() {
+ return lazy_tls.Pointer()->Get();
+}
+
+BrowserPluginManager::BrowserPluginManager() {
+ lazy_tls.Pointer()->Set(this);
+ RenderThread::Get()->AddObserver(this);
+}
+
+BrowserPluginManager::~BrowserPluginManager() {
+ lazy_tls.Pointer()->Set(NULL);
+}
+
+void BrowserPluginManager::AddBrowserPlugin(
+ int instance_id,
+ BrowserPlugin* browser_plugin) {
+ DCHECK(CalledOnValidThread());
+ instances_.AddWithID(browser_plugin, instance_id);
+}
+
+void BrowserPluginManager::RemoveBrowserPlugin(int instance_id) {
+ DCHECK(CalledOnValidThread());
+ instances_.Remove(instance_id);
+}
+
+BrowserPlugin* BrowserPluginManager::GetBrowserPlugin(int instance_id) const {
+ DCHECK(CalledOnValidThread());
+ return instances_.Lookup(instance_id);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698