OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 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. | |
4 | |
5 #include <ppapi/c/pp_errors.h> | |
6 #include <ppapi/c/pp_module.h> | |
7 #include <ppapi/c/ppb.h> | |
8 #include <ppapi/cpp/instance.h> | |
9 #include <ppapi/cpp/module.h> | |
10 | |
11 #include "ppapi_simple/ps_interface.h" | |
12 | |
13 class PSModule : public pp::Module { | |
14 public: | |
15 virtual pp::Instance* CreateInstance(PP_Instance instance) { | |
16 // Should not get here. | |
17 // This is only called by libppapi_cpp in Instance_DidCreate. That function | |
18 // is called by the PPP_Instance handler in libppapi_cpp, but we handle all | |
19 // plugin interfaces in ppapi_simple. | |
20 assert(0); | |
21 return NULL; | |
22 } | |
23 }; | |
24 | |
25 static PSModule* s_module; | |
26 | |
27 namespace pp { | |
28 | |
29 Module* Module::Get() { | |
30 return s_module; | |
31 } | |
32 | |
33 // This shouldn't be called (it is only referenced by PPP_InitialzeModule in | |
34 // ppapi_cpp, which we override), but is needed to successfully link. | |
35 Module* CreateModule() { | |
36 assert(0); | |
37 return NULL; | |
38 } | |
39 | |
40 } // namespace pp | |
41 | |
42 extern "C" { | |
Sam Clegg
2015/02/19 21:24:20
These should be declared as extern "C" in the head
binji
2015/02/20 17:33:48
True for PPP_*, but the other definitions are not
| |
43 | |
44 // Defined in ps_instance.c. | |
45 const void* PSGetInterfaceImplementation(const char*); | |
46 extern PPB_GetInterface g_ps_get_interface; | |
47 | |
48 int32_t PPP_InitializeModule(PP_Module module_id, | |
49 PPB_GetInterface get_interface) { | |
50 g_ps_get_interface = get_interface; | |
51 PSInterfaceInit(); | |
52 | |
53 PSModule* module = new PSModule(); | |
54 if (!module->InternalInit(module_id, get_interface)) { | |
55 delete s_module; | |
56 return PP_ERROR_FAILED; | |
57 } | |
58 s_module = module; | |
59 return PP_OK; | |
60 } | |
61 | |
62 const void* PPP_GetInterface(const char* interface_name) { | |
63 return PSGetInterfaceImplementation(interface_name); | |
64 } | |
65 | |
66 void PPP_ShutdownModule(void) { | |
67 delete s_module; | |
68 s_module = NULL; | |
69 } | |
70 | |
71 } // extern "C" | |
OLD | NEW |