blob: 6bed72f4eff776687c6d1d2acea988c0ebcd33ec [file] [log] [blame]
[email protected]73097562012-01-12 19:38:551// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]c2932f5e2010-11-03 03:22:332// 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]f24448db2011-01-27 20:40:399#include <utility>
[email protected]c2932f5e2010-11-03 03:22:3310
[email protected]cd910b92011-06-01 07:19:3111#include "base/compiler_specific.h"
[email protected]c2932f5e2010-11-03 03:22:3312#include "ppapi/c/pp_completion_callback.h"
[email protected]f24448db2011-01-27 20:40:3913#include "ppapi/c/pp_instance.h"
[email protected]c2932f5e2010-11-03 03:22:3314#include "ppapi/c/pp_stdint.h"
15#include "ppapi/c/pp_resource.h"
16#include "ppapi/c/pp_var.h"
[email protected]f0a04c42011-08-26 22:43:2017#include "ppapi/proxy/ppapi_proxy_export.h"
[email protected]be0a84b2011-08-13 04:18:4418#include "ppapi/shared_impl/host_resource.h"
[email protected]7f8b26b2011-08-18 15:41:0119#include "ppapi/shared_impl/resource_tracker.h"
[email protected]c2932f5e2010-11-03 03:22:3320
[email protected]4614f192011-01-21 00:26:4321template<typename T> struct DefaultSingletonTraits;
22
[email protected]ce701cd2011-08-01 21:47:0423namespace ppapi {
[email protected]ce701cd2011-08-01 21:47:0424
[email protected]c2932f5e2010-11-03 03:22:3325namespace proxy {
26
[email protected]2f59e382011-10-20 22:51:0127class PPAPI_PROXY_EXPORT PluginResourceTracker : public ResourceTracker {
[email protected]c2932f5e2010-11-03 03:22:3328 public:
[email protected]794d83cd2011-10-20 19:09:2029 PluginResourceTracker();
30 virtual ~PluginResourceTracker();
[email protected]f24448db2011-01-27 20:40:3931
[email protected]f24448db2011-01-27 20:40:3932 // 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]4d2efd22011-08-18 21:58:0235 const HostResource& resource) const;
[email protected]799d1ab2010-11-09 17:16:2836
[email protected]7f8b26b2011-08-18 15:41:0137 protected:
38 // ResourceTracker overrides.
[email protected]4d2efd22011-08-18 21:58:0239 virtual PP_Resource AddResource(Resource* object) OVERRIDE;
40 virtual void RemoveResource(Resource* object) OVERRIDE;
[email protected]6239d342011-05-06 22:55:4741
[email protected]c2932f5e2010-11-03 03:22:3342 private:
[email protected]f24448db2011-01-27 20:40:3943 // Map of host instance/resource pairs to a plugin resource ID.
[email protected]4d2efd22011-08-18 21:58:0244 typedef std::map<HostResource, PP_Resource> HostResourceMap;
[email protected]f24448db2011-01-27 20:40:3945 HostResourceMap host_resource_map_;
46
[email protected]f24448db2011-01-27 20:40:3947 DISALLOW_COPY_AND_ASSIGN(PluginResourceTracker);
[email protected]c2932f5e2010-11-03 03:22:3348};
49
50} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:0251} // namespace ppapi
[email protected]c2932f5e2010-11-03 03:22:3352
53#endif // PPAPI_PROXY_PLUGIN_RESOURCE_TRACKER_H_