Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: native_client_sdk/src/libraries/ppapi_simple_cpp/ps_entrypoints_cpp.cc

Issue 914983003: [NaCl SDK] Switch ppapi_simple to C library (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tty output bug Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
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>
11
12 #include "ppapi_simple/ps_interface.h"
13
14 class PSModule : public pp::Module {
15 public:
16 virtual pp::Instance* CreateInstance(PP_Instance instance) {
17 // Should not get here.
18 // This is only called by libppapi_cpp in Instance_DidCreate. That function
19 // is called by the PPP_Instance handler in libppapi_cpp, but we handle all
20 // plugin interfaces in ppapi_simple.
21 assert(0);
22 return NULL;
23 }
24 };
25
26 static PSModule* s_module;
27
28 namespace pp {
29
30 Module* Module::Get() {
31 return s_module;
32 }
33
34 // This shouldn't be called (it is only referenced by PPP_InitialzeModule in
35 // ppapi_cpp, which we override), but is needed to successfully link.
36 Module* CreateModule() {
37 assert(0);
38 return NULL;
39 }
40
41 } // namespace pp
42
43 extern "C" {
44
45 // Defined in ps_instance.c.
46 const void* PSGetInterfaceImplementation(const char*);
47 extern PPB_GetInterface g_ps_get_interface;
48
49 // This is defined to allow an executable to force inclusion of this object
50 // file. Otherwise PPP_* functions won't be linked in (because they are not
51 // needed until -lppapi on the link-line, which is usually last.
52 FORCE_LINK_THIS(ps_entry)
53
54 } // extern "C"
55
56 int32_t PPP_InitializeModule(PP_Module module_id,
57 PPB_GetInterface get_interface) {
58 g_ps_get_interface = get_interface;
59 PSInterfaceInit();
60
61 PSModule* module = new PSModule();
62 if (!module->InternalInit(module_id, get_interface)) {
63 delete s_module;
64 return PP_ERROR_FAILED;
65 }
66 s_module = module;
67 return PP_OK;
68 }
69
70 const void* PPP_GetInterface(const char* interface_name) {
71 return PSGetInterfaceImplementation(interface_name);
72 }
73
74 void PPP_ShutdownModule(void) {
75 delete s_module;
76 s_module = NULL;
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698