OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_ |
| 6 #define PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/linked_ptr.h" |
| 11 #include "ppapi/c/pp_completion_callback.h" |
| 12 #include "ppapi/c/pp_stdint.h" |
| 13 #include "ppapi/c/pp_resource.h" |
| 14 #include "ppapi/c/pp_var.h" |
| 15 |
| 16 namespace pp { |
| 17 namespace proxy { |
| 18 |
| 19 class PluginDispatcher; |
| 20 class PluginResource; |
| 21 |
| 22 class PluginResourceTracker { |
| 23 public: |
| 24 PluginResourceTracker(PluginDispatcher* dispatcher); |
| 25 ~PluginResourceTracker(); |
| 26 |
| 27 // Returns the object associated with the given resource ID, or NULL if |
| 28 // there isn't one. |
| 29 PluginResource* GetResourceObject(PP_Resource pp_resource); |
| 30 |
| 31 void AddResource(PP_Resource pp_resource, linked_ptr<PluginResource> object); |
| 32 |
| 33 void AddRefResource(PP_Resource resource); |
| 34 void ReleaseResource(PP_Resource resource); |
| 35 |
| 36 private: |
| 37 struct ResourceInfo { |
| 38 ResourceInfo(); |
| 39 ResourceInfo(int ref_count, linked_ptr<PluginResource> r); |
| 40 ResourceInfo(const ResourceInfo& other); |
| 41 ~ResourceInfo(); |
| 42 |
| 43 ResourceInfo& operator=(const ResourceInfo& other); |
| 44 |
| 45 int ref_count; |
| 46 linked_ptr<PluginResource> resource; // May be NULL. |
| 47 }; |
| 48 |
| 49 void ReleasePluginResourceRef(const PP_Resource& var, |
| 50 bool notify_browser_on_release); |
| 51 |
| 52 // Pointer to the dispatcher that owns us. |
| 53 PluginDispatcher* dispatcher_; |
| 54 |
| 55 typedef std::map<PP_Resource, ResourceInfo> ResourceMap; |
| 56 ResourceMap resource_map_; |
| 57 }; |
| 58 |
| 59 } // namespace proxy |
| 60 } // namespace pp |
| 61 |
| 62 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_ |
OLD | NEW |