Chromium Code Reviews| 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..62d819e958fa5df5a6d716828001263b23106e3e |
| --- /dev/null |
| +++ b/content/renderer/browser_plugin/browser_plugin_manager.cc |
| @@ -0,0 +1,49 @@ |
| +// 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 { |
| +namespace browser_plugin { |
| + |
| +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()); |
|
Charlie Reis
2012/08/03 18:06:02
This sounds like it would return true on any valid
Fady Samuel
2012/08/03 19:34:43
Not quite: See base/threading/thread_checker_impl.
Charlie Reis
2012/08/03 20:01:00
Great, thanks for confirming.
|
| + 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 browser_plugin |
| +} // namespace content |