1 // Copyright 2015 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 #include <ppapi/c/pp_errors.h>
6 #include <ppapi/c/pp_module.h>
7 #include <ppapi/c/ppb.h>
8 #include <ppapi/c/ppp.h>
9 #include <ppapi/cpp/instance.h>
10 #include <ppapi/cpp/module.h>
12 #include "ppapi_simple/ps_interface.h"
13 #include "ppapi_simple/ps_internal.h"
15 class PSModule
: public pp::Module
{
17 virtual pp::Instance
* CreateInstance(PP_Instance instance
) {
18 // Should not get here.
19 // This is only called by libppapi_cpp in Instance_DidCreate. That function
20 // is called by the PPP_Instance handler in libppapi_cpp, but we handle all
21 // plugin interfaces in ppapi_simple.
27 static PSModule
* s_module
;
31 Module
* Module::Get() {
35 // This shouldn't be called (it is only referenced by PPP_InitialzeModule in
36 // ppapi_cpp, which we override), but is needed to successfully link.
37 Module
* CreateModule() {
46 // This is defined to allow an executable to force inclusion of this object
47 // file. Otherwise PPP_* functions won't be linked in (because they are not
48 // needed until -lppapi on the link-line, which is usually last.
49 FORCE_LINK_THIS(ps_entry
)
53 int32_t PPP_InitializeModule(PP_Module module_id
,
54 PPB_GetInterface get_interface
) {
55 g_ps_get_interface
= get_interface
;
58 PSModule
* module
= new PSModule();
59 if (!module
->InternalInit(module_id
, get_interface
)) {
61 return PP_ERROR_FAILED
;
67 const void* PPP_GetInterface(const char* interface_name
) {
68 return PSGetInterfaceImplementation(interface_name
);
71 void PPP_ShutdownModule(void) {