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

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

Issue 6905088: New thunk system for Pepper proxy and implementation (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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_resource.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/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "ppapi/c/pp_completion_callback.h" 12 #include "ppapi/c/pp_completion_callback.h"
13 #include "ppapi/c/pp_instance.h" 13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_stdint.h" 14 #include "ppapi/c/pp_stdint.h"
15 #include "ppapi/c/pp_resource.h" 15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/pp_var.h" 16 #include "ppapi/c/pp_var.h"
17 #include "ppapi/proxy/host_resource.h" 17 #include "ppapi/proxy/host_resource.h"
18 #include "ppapi/shared_impl/tracker_base.h"
18 19
19 template<typename T> struct DefaultSingletonTraits; 20 template<typename T> struct DefaultSingletonTraits;
20 21
21 namespace pp { 22 namespace pp {
22 namespace proxy { 23 namespace proxy {
23 24
24 class PluginDispatcher; 25 class PluginDispatcher;
25 class PluginResource; 26 class PluginResource;
26 27
27 class PluginResourceTracker { 28 class PluginResourceTracker : public ::ppapi::shared_impl::TrackerBase {
28 public: 29 public:
29 // Called by tests that want to specify a specific ResourceTracker. This 30 // Called by tests that want to specify a specific ResourceTracker. This
30 // allows them to use a unique one each time and avoids singletons sticking 31 // allows them to use a unique one each time and avoids singletons sticking
31 // around across tests. 32 // around across tests.
32 static void SetInstanceForTest(PluginResourceTracker* tracker); 33 static void SetInstanceForTest(PluginResourceTracker* tracker);
33 34
34 // Returns the global singleton resource tracker for the plugin. 35 // Returns the global singleton resource tracker for the plugin.
35 static PluginResourceTracker* GetInstance(); 36 static PluginResourceTracker* GetInstance();
37 static ::ppapi::shared_impl::TrackerBase* GetTrackerBaseInstance();
36 38
37 // Returns the object associated with the given resource ID, or NULL if 39 // Returns the object associated with the given resource ID, or NULL if
38 // there isn't one. 40 // there isn't one.
39 PluginResource* GetResourceObject(PP_Resource pp_resource); 41 PluginResource* GetResourceObject(PP_Resource pp_resource);
40 42
41 // Adds the given resource object to the tracked list, and returns the 43 // Adds the given resource object to the tracked list, and returns the
42 // plugin-local PP_Resource ID that identifies the resource. Note that this 44 // plugin-local PP_Resource ID that identifies the resource. Note that this
43 // PP_Resource is not valid to send to the host, use 45 // PP_Resource is not valid to send to the host, use
44 // PluginResource.host_resource() to get that. 46 // PluginResource.host_resource() to get that.
45 PP_Resource AddResource(linked_ptr<PluginResource> object); 47 PP_Resource AddResource(linked_ptr<PluginResource> object);
46 48
47 void AddRefResource(PP_Resource resource); 49 void AddRefResource(PP_Resource resource);
48 void ReleaseResource(PP_Resource resource); 50 void ReleaseResource(PP_Resource resource);
49 51
50 // Given a host resource, maps it to an existing plugin resource ID if it 52 // Given a host resource, maps it to an existing plugin resource ID if it
51 // exists, or returns 0 on failure. 53 // exists, or returns 0 on failure.
52 PP_Resource PluginResourceForHostResource( 54 PP_Resource PluginResourceForHostResource(
53 const HostResource& resource) const; 55 const HostResource& resource) const;
54 56
57 // TrackerBase.
58 virtual ::ppapi::shared_impl::ResourceObjectBase* GetResourceAPI(
59 PP_Resource res);
60 virtual ::ppapi::shared_impl::FunctionGroupBase* GetFunctionAPI(
61 PP_Instance inst,
62 pp::proxy::InterfaceID id);
63
55 private: 64 private:
56 friend struct DefaultSingletonTraits<PluginResourceTracker>; 65 friend struct DefaultSingletonTraits<PluginResourceTracker>;
57 friend class PluginResourceTrackerTest; 66 friend class PluginResourceTrackerTest;
58 friend class PluginProxyTest; 67 friend class PluginProxyTest;
59 68
60 PluginResourceTracker(); 69 PluginResourceTracker();
61 ~PluginResourceTracker(); 70 ~PluginResourceTracker();
62 71
63 struct ResourceInfo { 72 struct ResourceInfo {
64 ResourceInfo(); 73 ResourceInfo();
(...skipping 22 matching lines...) Expand all
87 // duplicates. 96 // duplicates.
88 PP_Resource last_resource_id_; 97 PP_Resource last_resource_id_;
89 98
90 DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker); 99 DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker);
91 }; 100 };
92 101
93 } // namespace proxy 102 } // namespace proxy
94 } // namespace pp 103 } // namespace pp
95 104
96 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_ 105 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/plugin_resource.cc ('k') | ppapi/proxy/plugin_resource_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698