Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / webkit / plugins / ppapi / resource_helper.h
blobcca66f031bb8d5015fa2f58779be591dab11a339
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"
13 namespace ppapi {
14 class Resource;
17 namespace webkit {
18 namespace ppapi {
20 class PluginInstance;
21 class PluginModule;
22 class PluginDelegate;
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 {
30 public:
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);
47 private:
48 DISALLOW_IMPLICIT_CONSTRUCTORS(ResourceHelper);
51 } // namespace ppapi
52 } // namespace webkit
54 #endif // WEBKIT_PLUGINS_PPAPI_RESOURCE_IMPL_HELPER_H_