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

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

Issue 7608030: Convert the PluginResource to be refcounted. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 4 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) 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/memory/linked_ptr.h"
13 #include "ppapi/c/pp_completion_callback.h" 12 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/c/pp_instance.h" 13 #include "ppapi/c/pp_instance.h"
15 #include "ppapi/c/pp_stdint.h" 14 #include "ppapi/c/pp_stdint.h"
16 #include "ppapi/c/pp_resource.h" 15 #include "ppapi/c/pp_resource.h"
17 #include "ppapi/c/pp_var.h" 16 #include "ppapi/c/pp_var.h"
18 #include "ppapi/proxy/host_resource.h" 17 #include "ppapi/proxy/host_resource.h"
19 #include "ppapi/proxy/plugin_var_tracker.h" 18 #include "ppapi/proxy/plugin_var_tracker.h"
20 #include "ppapi/shared_impl/tracker_base.h" 19 #include "ppapi/shared_impl/tracker_base.h"
21 20
22 template<typename T> struct DefaultSingletonTraits; 21 template<typename T> struct DefaultSingletonTraits;
(...skipping 20 matching lines...) Expand all
43 static ::ppapi::TrackerBase* GetTrackerBaseInstance(); 42 static ::ppapi::TrackerBase* GetTrackerBaseInstance();
44 43
45 // Returns the object associated with the given resource ID, or NULL if 44 // Returns the object associated with the given resource ID, or NULL if
46 // there isn't one. 45 // there isn't one.
47 PluginResource* GetResourceObject(PP_Resource pp_resource); 46 PluginResource* GetResourceObject(PP_Resource pp_resource);
48 47
49 // Adds the given resource object to the tracked list, and returns the 48 // Adds the given resource object to the tracked list, and returns the
50 // plugin-local PP_Resource ID that identifies the resource. Note that this 49 // plugin-local PP_Resource ID that identifies the resource. Note that this
51 // PP_Resource is not valid to send to the host, use 50 // PP_Resource is not valid to send to the host, use
52 // PluginResource.host_resource() to get that. 51 // PluginResource.host_resource() to get that.
53 PP_Resource AddResource(linked_ptr<PluginResource> object); 52 //
53 // The resource tracker will take a reference to the given object.
54 PP_Resource AddResource(PluginResource* object);
54 55
55 void AddRefResource(PP_Resource resource); 56 void AddRefResource(PP_Resource resource);
56 void ReleaseResource(PP_Resource resource); 57 void ReleaseResource(PP_Resource resource);
57 58
58 // Given a host resource, maps it to an existing plugin resource ID if it 59 // Given a host resource, maps it to an existing plugin resource ID if it
59 // exists, or returns 0 on failure. 60 // exists, or returns 0 on failure.
60 PP_Resource PluginResourceForHostResource( 61 PP_Resource PluginResourceForHostResource(
61 const HostResource& resource) const; 62 const HostResource& resource) const;
62 63
63 PluginVarTracker& var_tracker() { 64 PluginVarTracker& var_tracker() {
(...skipping 17 matching lines...) Expand all
81 private: 82 private:
82 friend struct DefaultSingletonTraits<PluginResourceTracker>; 83 friend struct DefaultSingletonTraits<PluginResourceTracker>;
83 friend class PluginResourceTrackerTest; 84 friend class PluginResourceTrackerTest;
84 friend class PluginProxyTestHarness; 85 friend class PluginProxyTestHarness;
85 86
86 PluginResourceTracker(); 87 PluginResourceTracker();
87 virtual ~PluginResourceTracker(); 88 virtual ~PluginResourceTracker();
88 89
89 struct ResourceInfo { 90 struct ResourceInfo {
90 ResourceInfo(); 91 ResourceInfo();
91 ResourceInfo(int ref_count, linked_ptr<PluginResource> r); 92 ResourceInfo(int ref_count, PluginResource* r);
92 ResourceInfo(const ResourceInfo& other); 93 ResourceInfo(const ResourceInfo& other);
93 ~ResourceInfo(); 94 ~ResourceInfo();
94 95
95 ResourceInfo& operator=(const ResourceInfo& other); 96 ResourceInfo& operator=(const ResourceInfo& other);
96 97
97 int ref_count; 98 int ref_count;
98 linked_ptr<PluginResource> resource; // May be NULL. 99 scoped_refptr<PluginResource> resource; // May be NULL.
99 }; 100 };
100 101
101 void ReleasePluginResourceRef(const PP_Resource& var, 102 void ReleasePluginResourceRef(const PP_Resource& var,
102 bool notify_browser_on_release); 103 bool notify_browser_on_release);
103 104
104 // Use the var_tracker_test_override_ instead if it's non-NULL. 105 // Use the var_tracker_test_override_ instead if it's non-NULL.
105 // 106 //
106 // TODO(brettw) this should be somehow separated out from here. I'm thinking 107 // TODO(brettw) this should be somehow separated out from here. I'm thinking
107 // of some global object that manages PPAPI globals, including separate var 108 // of some global object that manages PPAPI globals, including separate var
108 // and resource trackers. 109 // and resource trackers.
(...skipping 15 matching lines...) Expand all
124 // duplicates. 125 // duplicates.
125 PP_Resource last_resource_id_; 126 PP_Resource last_resource_id_;
126 127
127 DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker); 128 DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker);
128 }; 129 };
129 130
130 } // namespace proxy 131 } // namespace proxy
131 } // namespace pp 132 } // namespace pp
132 133
133 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_ 134 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698