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

Side by Side Diff: ppapi/shared_impl/resource_tracker.h

Issue 9455083: Proxy the PPP_Printing interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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/shared_impl/api_id.h ('k') | ppapi/shared_impl/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_SHARED_IMPL_RESOURCE_TRACKER_H_ 5 #ifndef PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_
6 #define PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ 6 #define PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/hash_tables.h" 11 #include "base/hash_tables.h"
12 #include "base/memory/linked_ptr.h" 12 #include "base/memory/linked_ptr.h"
13 #include "base/memory/weak_ptr.h"
13 #include "ppapi/c/pp_instance.h" 14 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_resource.h" 15 #include "ppapi/c/pp_resource.h"
15 #include "ppapi/shared_impl/ppapi_shared_export.h" 16 #include "ppapi/shared_impl/ppapi_shared_export.h"
16 17
17 namespace ppapi { 18 namespace ppapi {
18 19
19 class Resource; 20 class Resource;
20 21
21 class PPAPI_SHARED_EXPORT ResourceTracker { 22 class PPAPI_SHARED_EXPORT ResourceTracker {
22 public: 23 public:
23 ResourceTracker(); 24 ResourceTracker();
24 virtual ~ResourceTracker(); 25 virtual ~ResourceTracker();
25 26
26 // The returned pointer will be NULL if there is no resource. The reference 27 // The returned pointer will be NULL if there is no resource. The reference
27 // count of the resource is unaffected. 28 // count of the resource is unaffected.
28 Resource* GetResource(PP_Resource res) const; 29 Resource* GetResource(PP_Resource res) const;
29 30
30 void AddRefResource(PP_Resource res); 31 void AddRefResource(PP_Resource res);
31 void ReleaseResource(PP_Resource res); 32 void ReleaseResource(PP_Resource res);
32 33
34 // Releases a reference on the given resource once the message loop returns.
35 void ReleaseResourceSoon(PP_Resource res);
36
33 // Notifies the tracker that a new instance has been created. This must be 37 // Notifies the tracker that a new instance has been created. This must be
34 // called before creating any resources associated with the instance. 38 // called before creating any resources associated with the instance.
35 void DidCreateInstance(PP_Instance instance); 39 void DidCreateInstance(PP_Instance instance);
36 40
37 // Called when an instance is being deleted. All plugin refs for the 41 // Called when an instance is being deleted. All plugin refs for the
38 // associated resources will be force freed, and the resources (if they still 42 // associated resources will be force freed, and the resources (if they still
39 // exist) will be disassociated from the instance. 43 // exist) will be disassociated from the instance.
40 void DidDeleteInstance(PP_Instance instance); 44 void DidDeleteInstance(PP_Instance instance);
41 45
42 // Returns the number of resources associated with the given instance. 46 // Returns the number of resources associated with the given instance.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // behalf of the plugin. When it drops to 0, we free that ref, keeping 87 // behalf of the plugin. When it drops to 0, we free that ref, keeping
84 // the resource in the list. 88 // the resource in the list.
85 // 89 //
86 // A resource will be in this list as long as the object is alive. 90 // A resource will be in this list as long as the object is alive.
87 typedef std::pair<Resource*, int> ResourceAndRefCount; 91 typedef std::pair<Resource*, int> ResourceAndRefCount;
88 typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap; 92 typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap;
89 ResourceMap live_resources_; 93 ResourceMap live_resources_;
90 94
91 int32 last_resource_value_; 95 int32 last_resource_value_;
92 96
97 base::WeakPtrFactory<ResourceTracker> weak_ptr_factory_;
98
93 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); 99 DISALLOW_COPY_AND_ASSIGN(ResourceTracker);
94 }; 100 };
95 101
96 } // namespace ppapi 102 } // namespace ppapi
97 103
98 #endif // PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_ 104 #endif // PPAPI_SHARED_IMPL_RESOURCE_TRACKER_H_
OLDNEW
« no previous file with comments | « ppapi/shared_impl/api_id.h ('k') | ppapi/shared_impl/resource_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698