Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 | 5 |
| 6 #include "ppapi/c/pp_instance.h" | 6 #include "ppapi/c/pp_instance.h" |
| 7 #include "ppapi/c/pp_module.h" | 7 #include "ppapi/c/pp_module.h" |
| 8 | 8 |
| 9 #include "ppapi/cpp/instance.h" | 9 #include "ppapi/cpp/instance.h" |
| 10 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
| 11 | 11 |
| 12 #include "ppapi_main/ppapi_instance.h" | 12 #include "ppapi_simple/ps.h" |
| 13 #include "ppapi_main/ppapi_instance3d.h" | |
| 14 #include "ppapi_main/ppapi_main.h" | |
| 15 | |
| 16 | 13 |
| 17 static pp::Instance* s_Instance = NULL; | 14 static pp::Instance* s_Instance = NULL; |
| 18 | 15 |
| 19 | 16 PP_Instance PSGetInstanceId() { |
| 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(); | 17 return s_Instance->pp_instance(); |
| 27 } | 18 } |
| 28 | 19 |
| 29 const void* PPAPI_GetInterface(const char *name) { | 20 const void* PSGetInterface(const char *name) { |
| 30 return pp::Module::Get()->GetBrowserInterface(name); | 21 return pp::Module::Get()->GetBrowserInterface(name); |
| 31 } | 22 } |
| 32 | 23 |
| 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 | 24 |
| 46 /// The Module class. The browser calls the CreateInstance() method to create | 25 /// The Module class. The browser calls the CreateInstance() method to create |
|
nfullagar1
2013/05/30 18:04:52
/// ?
noelallen1
2013/05/30 21:01:44
Done.
| |
| 47 /// an instance of your NaCl module on the web page. The browser creates a new | 26 /// 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". | 27 /// instance for each <embed> tag with type="application/x-nacl". |
| 49 class PPAPIMainModule : public pp::Module { | 28 class PSModule : public pp::Module { |
| 50 public: | 29 public: |
| 51 PPAPIMainModule() : pp::Module() {} | 30 PSModule() : pp::Module() {} |
| 52 virtual ~PPAPIMainModule() {} | 31 virtual ~PSModule() {} |
| 53 | 32 |
| 54 virtual pp::Instance* CreateInstance(PP_Instance instance) { | 33 virtual pp::Instance* CreateInstance(PP_Instance instance) { |
| 55 s_Instance = static_cast<pp::Instance*>(UserCreateInstance(instance)); | 34 s_Instance = static_cast<pp::Instance*>(PSUserCreateInstance(instance)); |
| 56 return s_Instance; | 35 return s_Instance; |
| 57 } | 36 } |
| 58 }; | 37 }; |
| 59 | 38 |
| 60 namespace pp { | 39 namespace pp { |
| 61 /// Factory function called by the browser when the module is first loaded. | 40 /// Factory function called by the browser when the module is first loaded. |
| 62 /// The browser keeps a singleton of this module. It calls the | 41 /// The browser keeps a singleton of this module. It calls the |
| 63 /// CreateInstance() method on the object you return to make instances. There | 42 /// 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 | 43 /// is one instance per <embed> tag on the page. This is the main binding |
| 65 /// point for your NaCl module with the browser. | 44 /// point for your NaCl module with the browser. |
| 66 Module* CreateModule() { | 45 Module* CreateModule() { |
| 67 return new PPAPIMainModule(); | 46 return new PSModule(); |
| 68 } | 47 } |
| 69 | 48 |
| 70 } // namespace pp | 49 } // namespace pp |
| 71 | 50 |
| OLD | NEW |