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_manager.h" | |
6 | |
7 #include "base/lazy_instance.h" | |
8 #include "base/threading/thread_local.h" | |
9 #include "content/public/renderer/render_thread.h" | |
10 #include "content/renderer/browser_plugin/browser_plugin.h" | |
11 | |
12 namespace content { | |
13 namespace browser_plugin { | |
14 | |
15 static base::LazyInstance<base::ThreadLocalPointer< | |
16 BrowserPluginManager> > lazy_tls = LAZY_INSTANCE_INITIALIZER; | |
17 | |
18 BrowserPluginManager* BrowserPluginManager::Get() { | |
19 return lazy_tls.Pointer()->Get(); | |
20 } | |
21 | |
22 BrowserPluginManager::BrowserPluginManager() { | |
23 lazy_tls.Pointer()->Set(this); | |
24 RenderThread::Get()->AddObserver(this); | |
25 } | |
26 | |
27 BrowserPluginManager::~BrowserPluginManager() { | |
28 lazy_tls.Pointer()->Set(NULL); | |
29 } | |
30 | |
31 void BrowserPluginManager::AddBrowserPlugin( | |
32 int instance_id, | |
33 BrowserPlugin* browser_plugin) { | |
34 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.
| |
35 instances_.AddWithID(browser_plugin, instance_id); | |
36 } | |
37 | |
38 void BrowserPluginManager::RemoveBrowserPlugin(int instance_id) { | |
39 DCHECK(CalledOnValidThread()); | |
40 instances_.Remove(instance_id); | |
41 } | |
42 | |
43 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin(int instance_id) const { | |
44 DCHECK(CalledOnValidThread()); | |
45 return instances_.Lookup(instance_id); | |
46 } | |
47 | |
48 } // namespace browser_plugin | |
49 } // namespace content | |
OLD | NEW |