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

Side by Side Diff: native_client_sdk/src/libraries/ppapi_main/ppapi_main.cc

Issue 15011003: ppapi_simple (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copyright Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /* Copyright (c) 2012 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
6 #include "ppapi/c/pp_instance.h"
7 #include "ppapi/c/pp_module.h"
8
9 #include "ppapi/cpp/instance.h"
10 #include "ppapi/cpp/module.h"
11
12 #include "ppapi_main/ppapi_instance.h"
13 #include "ppapi_main/ppapi_instance3d.h"
14 #include "ppapi_main/ppapi_main.h"
15
16
17 static pp::Instance* s_Instance = NULL;
18
19
20 // Helpers to access PPAPI interfaces
21 void* PPAPI_GetInstanceObject() {
22 return s_Instance;
23 }
24
25 PP_Instance PPAPI_GetInstanceId() {
26 return s_Instance->pp_instance();
27 }
28
29 const void* PPAPI_GetInterface(const char *name) {
30 return pp::Module::Get()->GetBrowserInterface(name);
31 }
32
33 void* PPAPI_CreateInstance(PP_Instance inst, const char *args[]) {
34 return static_cast<void*>(new PPAPIInstance(inst, args));
35 }
36
37 PPAPIEvent* PPAPI_AcquireEvent() {
38 return static_cast<PPAPIInstance*>(s_Instance)->AcquireInputEvent();
39 }
40
41 void PPAPI_ReleaseEvent(PPAPIEvent* event) {
42 static_cast<PPAPIInstance*>(s_Instance)->ReleaseInputEvent(event);
43 }
44
45
46 /// The Module class. The browser calls the CreateInstance() method to create
47 /// an instance of your NaCl module on the web page. The browser creates a new
48 /// instance for each <embed> tag with type="application/x-nacl".
49 class PPAPIMainModule : public pp::Module {
50 public:
51 PPAPIMainModule() : pp::Module() {}
52 virtual ~PPAPIMainModule() {}
53
54 virtual pp::Instance* CreateInstance(PP_Instance instance) {
55 s_Instance = static_cast<pp::Instance*>(UserCreateInstance(instance));
56 return s_Instance;
57 }
58 };
59
60 namespace pp {
61 /// Factory function called by the browser when the module is first loaded.
62 /// The browser keeps a singleton of this module. It calls the
63 /// CreateInstance() method on the object you return to make instances. There
64 /// is one instance per <embed> tag on the page. This is the main binding
65 /// point for your NaCl module with the browser.
66 Module* CreateModule() {
67 return new PPAPIMainModule();
68 }
69
70 } // namespace pp
71
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/ppapi_main/ppapi_main.h ('k') | native_client_sdk/src/libraries/ppapi_main/ppapi_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698