OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_PROXY_PLUGIN_GLOBALS_H_ | 5 #ifndef PPAPI_PROXY_PLUGIN_GLOBALS_H_ |
6 #define PPAPI_PROXY_PLUGIN_GLOBALS_H_ | 6 #define PPAPI_PROXY_PLUGIN_GLOBALS_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/synchronization/lock.h" |
9 #include "ppapi/proxy/plugin_resource_tracker.h" | 10 #include "ppapi/proxy/plugin_resource_tracker.h" |
10 #include "ppapi/proxy/plugin_var_tracker.h" | 11 #include "ppapi/proxy/plugin_var_tracker.h" |
11 #include "ppapi/proxy/ppapi_proxy_export.h" | 12 #include "ppapi/proxy/ppapi_proxy_export.h" |
12 #include "ppapi/shared_impl/callback_tracker.h" | 13 #include "ppapi/shared_impl/callback_tracker.h" |
13 #include "ppapi/shared_impl/ppapi_globals.h" | 14 #include "ppapi/shared_impl/ppapi_globals.h" |
14 | 15 |
15 namespace ppapi { | 16 namespace ppapi { |
16 namespace proxy { | 17 namespace proxy { |
17 | 18 |
18 class PluginProxyDelegate; | 19 class PluginProxyDelegate; |
19 | 20 |
20 class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { | 21 class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { |
21 public: | 22 public: |
22 PluginGlobals(); | 23 PluginGlobals(); |
| 24 PluginGlobals(PpapiGlobals::ForTest); |
23 virtual ~PluginGlobals(); | 25 virtual ~PluginGlobals(); |
24 | 26 |
25 // Getter for the global singleton. Generally, you should use | 27 // Getter for the global singleton. Generally, you should use |
26 // PpapiGlobals::Get() when possible. Use this only when you need some | 28 // PpapiGlobals::Get() when possible. Use this only when you need some |
27 // plugin-specific functionality. | 29 // plugin-specific functionality. |
28 inline static PluginGlobals* Get() { return plugin_globals_; } | 30 inline static PluginGlobals* Get() { |
| 31 DCHECK(PpapiGlobals::Get()->IsPluginGlobals()); |
| 32 return static_cast<PluginGlobals*>(PpapiGlobals::Get()); |
| 33 } |
29 | 34 |
30 // PpapiGlobals implementation. | 35 // PpapiGlobals implementation. |
31 virtual ResourceTracker* GetResourceTracker() OVERRIDE; | 36 virtual ResourceTracker* GetResourceTracker() OVERRIDE; |
32 virtual VarTracker* GetVarTracker() OVERRIDE; | 37 virtual VarTracker* GetVarTracker() OVERRIDE; |
33 virtual CallbackTracker* GetCallbackTrackerForInstance( | 38 virtual CallbackTracker* GetCallbackTrackerForInstance( |
34 PP_Instance instance) OVERRIDE; | 39 PP_Instance instance) OVERRIDE; |
35 virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst, | 40 virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst, |
36 ApiID id) OVERRIDE; | 41 ApiID id) OVERRIDE; |
37 virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE; | 42 virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE; |
| 43 virtual base::Lock* GetProxyLock() OVERRIDE; |
38 | 44 |
39 // Getters for the plugin-specific versions. | 45 // Getters for the plugin-specific versions. |
40 PluginResourceTracker* plugin_resource_tracker() { | 46 PluginResourceTracker* plugin_resource_tracker() { |
41 return &plugin_resource_tracker_; | 47 return &plugin_resource_tracker_; |
42 } | 48 } |
43 PluginVarTracker* plugin_var_tracker() { | 49 PluginVarTracker* plugin_var_tracker() { |
44 return &plugin_var_tracker_; | 50 return &plugin_var_tracker_; |
45 } | 51 } |
46 | 52 |
47 // The embedder should call set_proxy_delegate during startup. | 53 // The embedder should call set_proxy_delegate during startup. |
48 PluginProxyDelegate* plugin_proxy_delegate() { | 54 PluginProxyDelegate* plugin_proxy_delegate() { |
49 return plugin_proxy_delegate_; | 55 return plugin_proxy_delegate_; |
50 } | 56 } |
51 void set_plugin_proxy_delegate(PluginProxyDelegate* d) { | 57 void set_plugin_proxy_delegate(PluginProxyDelegate* d) { |
52 plugin_proxy_delegate_ = d; | 58 plugin_proxy_delegate_ = d; |
53 } | 59 } |
54 | 60 |
55 private: | 61 private: |
| 62 // PpapiGlobals overrides. |
| 63 virtual bool IsPluginGlobals() const OVERRIDE; |
| 64 |
56 static PluginGlobals* plugin_globals_; | 65 static PluginGlobals* plugin_globals_; |
57 | 66 |
58 PluginProxyDelegate* plugin_proxy_delegate_; | 67 PluginProxyDelegate* plugin_proxy_delegate_; |
59 PluginResourceTracker plugin_resource_tracker_; | 68 PluginResourceTracker plugin_resource_tracker_; |
60 PluginVarTracker plugin_var_tracker_; | 69 PluginVarTracker plugin_var_tracker_; |
61 scoped_refptr<CallbackTracker> callback_tracker_; | 70 scoped_refptr<CallbackTracker> callback_tracker_; |
| 71 base::Lock proxy_lock_; |
62 | 72 |
63 DISALLOW_COPY_AND_ASSIGN(PluginGlobals); | 73 DISALLOW_COPY_AND_ASSIGN(PluginGlobals); |
64 }; | 74 }; |
65 | 75 |
66 } // namespace proxy | 76 } // namespace proxy |
67 } // namespace ppapi | 77 } // namespace ppapi |
68 | 78 |
69 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_ | 79 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_ |
OLD | NEW |