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

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

Issue 8342016: Revert 106142 - Add a new globals object for PPAPI tracking information. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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/plugin_globals.cc ('k') | ppapi/proxy/plugin_resource_tracker.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_RESOURCE_TRACKER_H_ 5 #ifndef PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_
6 #define PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_ 6 #define PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "ppapi/c/pp_completion_callback.h" 13 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/c/pp_instance.h" 14 #include "ppapi/c/pp_instance.h"
15 #include "ppapi/c/pp_stdint.h" 15 #include "ppapi/c/pp_stdint.h"
16 #include "ppapi/c/pp_resource.h" 16 #include "ppapi/c/pp_resource.h"
17 #include "ppapi/c/pp_var.h" 17 #include "ppapi/c/pp_var.h"
18 #include "ppapi/proxy/plugin_var_tracker.h"
18 #include "ppapi/proxy/ppapi_proxy_export.h" 19 #include "ppapi/proxy/ppapi_proxy_export.h"
19 #include "ppapi/shared_impl/host_resource.h" 20 #include "ppapi/shared_impl/host_resource.h"
20 #include "ppapi/shared_impl/resource_tracker.h" 21 #include "ppapi/shared_impl/resource_tracker.h"
21 #include "ppapi/shared_impl/tracker_base.h" 22 #include "ppapi/shared_impl/tracker_base.h"
22 23
23 template<typename T> struct DefaultSingletonTraits; 24 template<typename T> struct DefaultSingletonTraits;
24 25
25 namespace ppapi { 26 namespace ppapi {
26 27
27 class Var; 28 class Var;
28 29
29 namespace proxy { 30 namespace proxy {
30 31
31 class PluginDispatcher; 32 class PluginDispatcher;
32 33
33 class PPAPI_PROXY_EXPORT PluginResourceTracker : public TrackerBase, 34 class PPAPI_PROXY_EXPORT PluginResourceTracker : public TrackerBase,
34 public ResourceTracker { 35 public ResourceTracker {
35 public: 36 public:
36 PluginResourceTracker(); 37 // Called by tests that want to specify a specific ResourceTracker. This
37 virtual ~PluginResourceTracker(); 38 // allows them to use a unique one each time and avoids singletons sticking
39 // around across tests.
40 static void SetInstanceForTest(PluginResourceTracker* tracker);
38 41
42 // Returns the global singleton resource tracker for the plugin.
43 static PluginResourceTracker* GetInstance();
39 static TrackerBase* GetTrackerBaseInstance(); 44 static TrackerBase* GetTrackerBaseInstance();
40 45
41 // Given a host resource, maps it to an existing plugin resource ID if it 46 // Given a host resource, maps it to an existing plugin resource ID if it
42 // exists, or returns 0 on failure. 47 // exists, or returns 0 on failure.
43 PP_Resource PluginResourceForHostResource( 48 PP_Resource PluginResourceForHostResource(
44 const HostResource& resource) const; 49 const HostResource& resource) const;
45 50
51 PluginVarTracker& var_tracker() {
52 return var_tracker_test_override_ ? *var_tracker_test_override_
53 : var_tracker_;
54 }
55
56 void set_var_tracker_test_override(PluginVarTracker* t) {
57 var_tracker_test_override_ = t;
58 }
59
46 // TrackerBase. 60 // TrackerBase.
47 virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst, 61 virtual FunctionGroupBase* GetFunctionAPI(PP_Instance inst,
48 InterfaceID id) OVERRIDE; 62 InterfaceID id) OVERRIDE;
63 virtual VarTracker* GetVarTracker() OVERRIDE;
64 virtual ResourceTracker* GetResourceTracker() OVERRIDE;
49 virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE; 65 virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE;
50 66
51 protected: 67 protected:
52 // ResourceTracker overrides. 68 // ResourceTracker overrides.
53 virtual PP_Resource AddResource(Resource* object) OVERRIDE; 69 virtual PP_Resource AddResource(Resource* object) OVERRIDE;
54 virtual void RemoveResource(Resource* object) OVERRIDE; 70 virtual void RemoveResource(Resource* object) OVERRIDE;
55 71
56 private: 72 private:
73 friend struct DefaultSingletonTraits<PluginResourceTracker>;
74 friend class PluginResourceTrackerTest;
75 friend class PluginProxyTestHarness;
76
77 PluginResourceTracker();
78 virtual ~PluginResourceTracker();
79
80 // Use the var_tracker_test_override_ instead if it's non-NULL.
81 //
82 // TODO(brettw) this should be somehow separated out from here. I'm thinking
83 // of some global object that manages PPAPI globals, including separate var
84 // and resource trackers.
85 PluginVarTracker var_tracker_;
86
87 // Non-owning pointer to a var tracker mock used by tests. NULL when no
88 // test implementation is provided.
89 PluginVarTracker* var_tracker_test_override_;
90
57 // Map of host instance/resource pairs to a plugin resource ID. 91 // Map of host instance/resource pairs to a plugin resource ID.
58 typedef std::map<HostResource, PP_Resource> HostResourceMap; 92 typedef std::map<HostResource, PP_Resource> HostResourceMap;
59 HostResourceMap host_resource_map_; 93 HostResourceMap host_resource_map_;
60 94
61 // The global lock for the plugin side of the proxy. 95 // The global lock for the plugin side of the proxy.
62 base::Lock proxy_lock_; 96 base::Lock proxy_lock_;
63 97
64 DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker); 98 DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker);
65 }; 99 };
66 100
67 } // namespace proxy 101 } // namespace proxy
68 } // namespace ppapi 102 } // namespace ppapi
69 103
70 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_ 104 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/plugin_globals.cc ('k') | ppapi/proxy/plugin_resource_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698