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

Side by Side Diff: ppapi/proxy/plugin_globals.h

Issue 9034035: Make it possible to have 1 PpapiGlobals per thread. Update unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments, shared fixes Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/host_var_serialization_rules.cc ('k') | ppapi/proxy/plugin_globals.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 if (plugin_globals_)
32 return plugin_globals_;
33 return static_cast<PluginGlobals*>(PpapiGlobals::Get());
piman 2012/01/11 19:23:25 Could we add a way to DCHECK that the cast is safe
dmichael (off chromium) 2012/01/12 04:42:23 Good ideas. Done.
34 }
29 35
30 // PpapiGlobals implementation. 36 // PpapiGlobals implementation.
31 virtual ResourceTracker* GetResourceTracker() OVERRIDE; 37 virtual ResourceTracker* GetResourceTracker() OVERRIDE;
32 virtual VarTracker* GetVarTracker() OVERRIDE; 38 virtual VarTracker* GetVarTracker() OVERRIDE;
33 virtual CallbackTracker* GetCallbackTrackerForInstance( 39 virtual CallbackTracker* GetCallbackTrackerForInstance(
34 PP_Instance instance) OVERRIDE; 40 PP_Instance instance) OVERRIDE;
35 virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst, 41 virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst,
36 ApiID id) OVERRIDE; 42 ApiID id) OVERRIDE;
37 virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE; 43 virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE;
44 virtual base::Lock* GetProxyLock() OVERRIDE;
38 45
39 // Getters for the plugin-specific versions. 46 // Getters for the plugin-specific versions.
40 PluginResourceTracker* plugin_resource_tracker() { 47 PluginResourceTracker* plugin_resource_tracker() {
41 return &plugin_resource_tracker_; 48 return &plugin_resource_tracker_;
42 } 49 }
43 PluginVarTracker* plugin_var_tracker() { 50 PluginVarTracker* plugin_var_tracker() {
44 return &plugin_var_tracker_; 51 return &plugin_var_tracker_;
45 } 52 }
46 53
47 // The embedder should call set_proxy_delegate during startup. 54 // The embedder should call set_proxy_delegate during startup.
48 PluginProxyDelegate* plugin_proxy_delegate() { 55 PluginProxyDelegate* plugin_proxy_delegate() {
49 return plugin_proxy_delegate_; 56 return plugin_proxy_delegate_;
50 } 57 }
51 void set_plugin_proxy_delegate(PluginProxyDelegate* d) { 58 void set_plugin_proxy_delegate(PluginProxyDelegate* d) {
52 plugin_proxy_delegate_ = d; 59 plugin_proxy_delegate_ = d;
53 } 60 }
54 61
55 private: 62 private:
56 static PluginGlobals* plugin_globals_; 63 static PluginGlobals* plugin_globals_;
57 64
58 PluginProxyDelegate* plugin_proxy_delegate_; 65 PluginProxyDelegate* plugin_proxy_delegate_;
59 PluginResourceTracker plugin_resource_tracker_; 66 PluginResourceTracker plugin_resource_tracker_;
60 PluginVarTracker plugin_var_tracker_; 67 PluginVarTracker plugin_var_tracker_;
61 scoped_refptr<CallbackTracker> callback_tracker_; 68 scoped_refptr<CallbackTracker> callback_tracker_;
69 base::Lock proxy_lock_;
62 70
63 DISALLOW_COPY_AND_ASSIGN(PluginGlobals); 71 DISALLOW_COPY_AND_ASSIGN(PluginGlobals);
64 }; 72 };
65 73
66 } // namespace proxy 74 } // namespace proxy
67 } // namespace ppapi 75 } // namespace ppapi
68 76
69 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_ 77 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/host_var_serialization_rules.cc ('k') | ppapi/proxy/plugin_globals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698