[email protected] | 7309756 | 2012-01-12 19:38:55 | [diff] [blame^] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 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> | ||||
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 9 | #include <utility> |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 10 | |
[email protected] | cd910b9 | 2011-06-01 07:19:31 | [diff] [blame] | 11 | #include "base/compiler_specific.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 12 | #include "ppapi/c/pp_completion_callback.h" |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 13 | #include "ppapi/c/pp_instance.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 14 | #include "ppapi/c/pp_stdint.h" |
15 | #include "ppapi/c/pp_resource.h" | ||||
16 | #include "ppapi/c/pp_var.h" | ||||
[email protected] | f0a04c4 | 2011-08-26 22:43:20 | [diff] [blame] | 17 | #include "ppapi/proxy/ppapi_proxy_export.h" |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 18 | #include "ppapi/shared_impl/host_resource.h" |
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 19 | #include "ppapi/shared_impl/resource_tracker.h" |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 20 | |
[email protected] | 4614f19 | 2011-01-21 00:26:43 | [diff] [blame] | 21 | template<typename T> struct DefaultSingletonTraits; |
22 | |||||
[email protected] | ce701cd | 2011-08-01 21:47:04 | [diff] [blame] | 23 | namespace ppapi { |
[email protected] | ce701cd | 2011-08-01 21:47:04 | [diff] [blame] | 24 | |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 25 | namespace proxy { |
26 | |||||
[email protected] | 2f59e38 | 2011-10-20 22:51:01 | [diff] [blame] | 27 | class PPAPI_PROXY_EXPORT PluginResourceTracker : public ResourceTracker { |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 28 | public: |
[email protected] | 794d83cd | 2011-10-20 19:09:20 | [diff] [blame] | 29 | PluginResourceTracker(); |
30 | virtual ~PluginResourceTracker(); | ||||
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 31 | |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 32 | // Given a host resource, maps it to an existing plugin resource ID if it |
33 | // exists, or returns 0 on failure. | ||||
34 | PP_Resource PluginResourceForHostResource( | ||||
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 35 | const HostResource& resource) const; |
[email protected] | 799d1ab | 2010-11-09 17:16:28 | [diff] [blame] | 36 | |
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 37 | protected: |
38 | // ResourceTracker overrides. | ||||
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 39 | virtual PP_Resource AddResource(Resource* object) OVERRIDE; |
40 | virtual void RemoveResource(Resource* object) OVERRIDE; | ||||
[email protected] | 6239d34 | 2011-05-06 22:55:47 | [diff] [blame] | 41 | |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 42 | private: |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 43 | // Map of host instance/resource pairs to a plugin resource ID. |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 44 | typedef std::map<HostResource, PP_Resource> HostResourceMap; |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 45 | HostResourceMap host_resource_map_; |
46 | |||||
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 47 | DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker); |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 48 | }; |
49 | |||||
50 | } // namespace proxy | ||||
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 51 | } // namespace ppapi |
[email protected] | c2932f5e | 2010-11-03 03:22:33 | [diff] [blame] | 52 | |
53 | #endif // PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_ |