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
3 // found in the LICENSE file.
5 #ifndef WEBKIT_PLUGINS_PPAPI_RESOURCE_HELPER_H_
6 #define WEBKIT_PLUGINS_PPAPI_RESOURCE_HELPER_H_
8 #include "base/basictypes.h"
9 #include "ppapi/c/pp_instance.h"
10 #include "ppapi/c/pp_resource.h"
11 #include "webkit/plugins/webkit_plugins_export.h"
24 // Helper functions for Resoruce implementations.
26 // This is specifically not designed to be a base class that derives from
27 // ppapi::Resource to avoid diamond inheritance if most of a resource class
28 // is implemented in the shared_impl (to share code with the proxy).
29 class ResourceHelper
{
31 // Returns the instance implementation object for the given resource, or NULL
32 // if the resource has outlived its instance.
33 static PluginInstance
* GetPluginInstance(const ::ppapi::Resource
* resource
);
35 // Returns the module for the given resource, or NULL if the resource has
36 // outlived its instance.
37 WEBKIT_PLUGINS_EXPORT
static PluginModule
* GetPluginModule(
38 const ::ppapi::Resource
* resource
);
40 // Returns the plugin delegate for the given resource, or NULL if the
41 // resource has outlived its instance.
42 static PluginDelegate
* GetPluginDelegate(const ::ppapi::Resource
* resource
);
44 // Returns the instance implementation object for the pp_instance.
45 static PluginInstance
* PPInstanceToPluginInstance(PP_Instance instance
);
48 DISALLOW_IMPLICIT_CONSTRUCTORS(ResourceHelper
);
54 #endif // WEBKIT_PLUGINS_PPAPI_RESOURCE_IMPL_HELPER_H_