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

Side by Side Diff: src/shared/ppapi_proxy/plugin_resource_tracker.h

Issue 7395005: Proxy PPB_Input_Event, PPP_Input_Event, and associated IFs. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Another gyp fix, windows build fix Created 9 years, 5 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
OLDNEW
1 // Copyright (c) 2010 The Native Client Authors. All rights reserved. 1 // Copyright (c) 2010 The Native Client 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 WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_ 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_ 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 25 matching lines...) Expand all
36 // Increment resource's plugin refcount. See ResourceAndRefCount. 36 // Increment resource's plugin refcount. See ResourceAndRefCount.
37 bool AddRefResource(PP_Resource res); 37 bool AddRefResource(PP_Resource res);
38 bool UnrefResource(PP_Resource res); 38 bool UnrefResource(PP_Resource res);
39 39
40 private: 40 private:
41 friend class PluginResource; 41 friend class PluginResource;
42 42
43 // Prohibit creation other then by the Singleton class. 43 // Prohibit creation other then by the Singleton class.
44 PluginResourceTracker(); 44 PluginResourceTracker();
45 45
46 // Adds the given resource to the tracker and assigns it a resource ID and 46 // Adds the given resource to the tracker and assigns it a resource ID, local
47 // refcount of 1. Used only by the Resource class. 47 // refcount of 1, and initializes the browser reference count to
48 void AddResource(PluginResource* resource, PP_Resource id); 48 // |browser_refcount|. Used only by the Resource class.
49 void AddResource(PluginResource* resource, PP_Resource id,
50 size_t browser_refcount);
49 51
50 // The returned pointer will be NULL if there is no resource. Note that this 52 // The returned pointer will be NULL if there is no resource. Note that this
51 // return value is a scoped_refptr so that we ensure the resource is valid 53 // return value is a scoped_refptr so that we ensure the resource is valid
52 // from the point of the lookup to the point that the calling code needs it. 54 // from the point of the lookup to the point that the calling code needs it.
53 // Otherwise, the plugin could Release() the resource on another thread and 55 // Otherwise, the plugin could Release() the resource on another thread and
54 // the object will get deleted out from under us. 56 // the object will get deleted out from under us.
55 scoped_refptr<PluginResource> GetExistingResource(PP_Resource res) const; 57 scoped_refptr<PluginResource> GetExistingResource(PP_Resource res) const;
56 58
57 // Get or create a new PluginResource from a browser resource. 59 // Get or create a new PluginResource from a browser resource.
58 // If we are already tracking this resource, we bump its browser_refcount to 60 // If we are already tracking this resource, we bump its browser_refcount to
59 // reflect that we took ownership of it. If this is a new resource, we create 61 // reflect that we took ownership of it. If this is a new resource, we create
60 // a PluginResource for it with browser_refcount 1. 62 // a PluginResource for it with the given browser_refcount.
61 template<typename T> scoped_refptr<T> AdoptBrowserResource(PP_Resource res); 63 template<typename T> scoped_refptr<T> AdoptBrowserResource(
64 PP_Resource res, size_t browser_refcount);
62 65
63 // Try to get a browser-side refcount for an existing resource. 66 // Try to get a browser-side refcount for an existing resource.
64 void ObtainBrowserResource(PP_Resource res); 67 void ObtainBrowserResource(PP_Resource res);
65 68
66 // Release browser-side refcount. 69 // Release browser-side refcount.
67 void ReleaseBrowserResource(PP_Resource res, size_t refcount); 70 void ReleaseBrowserResource(PP_Resource res, size_t refcount);
68 71
69 // Last assigned resource ID. 72 // Last assigned resource ID.
70 PP_Resource last_id_; 73 PP_Resource last_id_;
71 74
72 struct ResourceAndRefCounts { 75 struct ResourceAndRefCounts {
73 scoped_refptr<PluginResource> resource; 76 scoped_refptr<PluginResource> resource;
74 size_t browser_refcount; 77 size_t browser_refcount;
75 size_t plugin_refcount; 78 size_t plugin_refcount;
76 explicit ResourceAndRefCounts(PluginResource* r); 79 explicit ResourceAndRefCounts(PluginResource* r, size_t browser_refcount);
sehr (please use chromium) 2011/07/20 00:33:41 Nit. explicit isn't strictly necessary for a binar
dmichael (off chromium) 2011/07/20 03:50:22 Done.
77 ~ResourceAndRefCounts(); 80 ~ResourceAndRefCounts();
78 }; 81 };
79 typedef std::map<PP_Resource, ResourceAndRefCounts> ResourceMap; 82 typedef std::map<PP_Resource, ResourceAndRefCounts> ResourceMap;
80 ResourceMap live_resources_; 83 ResourceMap live_resources_;
81 84
82 DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker); 85 DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker);
83 }; 86 };
84 87
85 } // namespace ppapi_proxy 88 } // namespace ppapi_proxy
86 89
87 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_ 90 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
88 91
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698