| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "remoting/client/plugin/pepper_entrypoints.h" | 5 #include "remoting/client/plugin/pepper_entrypoints.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/c/pp_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
| 10 #include "ppapi/c/pp_module.h" | 10 #include "ppapi/c/pp_module.h" |
| 11 #include "ppapi/c/ppb_instance.h" | 11 #include "ppapi/c/ppb_instance.h" |
| 12 #include "ppapi/cpp/instance.h" | 12 #include "ppapi/cpp/instance.h" |
| 13 #include "ppapi/cpp/internal_module.h" |
| 13 #include "ppapi/cpp/module.h" | 14 #include "ppapi/cpp/module.h" |
| 14 #include "remoting/client/plugin/chromoting_instance.h" | 15 #include "remoting/client/plugin/chromoting_instance.h" |
| 15 | 16 |
| 16 static pp::Module* g_module_singleton = NULL; | |
| 17 | |
| 18 namespace pp { | |
| 19 | |
| 20 Module* Module::Get() { | |
| 21 return g_module_singleton; | |
| 22 } | |
| 23 | |
| 24 } // namespace pp | |
| 25 | |
| 26 namespace remoting { | 17 namespace remoting { |
| 27 | 18 |
| 28 class ChromotingModule : public pp::Module { | 19 class ChromotingModule : public pp::Module { |
| 29 protected: | 20 protected: |
| 30 virtual ChromotingInstance* CreateInstance(PP_Instance instance) OVERRIDE { | 21 virtual ChromotingInstance* CreateInstance(PP_Instance instance) OVERRIDE { |
| 31 return new ChromotingInstance(instance); | 22 return new ChromotingInstance(instance); |
| 32 } | 23 } |
| 33 }; | 24 }; |
| 34 | 25 |
| 35 // Implementation of Global PPP functions --------------------------------- | 26 // Implementation of Global PPP functions --------------------------------- |
| 36 int32_t PPP_InitializeModule(PP_Module module_id, | 27 int32_t PPP_InitializeModule(PP_Module module_id, |
| 37 PPB_GetInterface get_browser_interface) { | 28 PPB_GetInterface get_browser_interface) { |
| 38 ChromotingModule* module = new ChromotingModule(); | 29 ChromotingModule* module = new ChromotingModule(); |
| 39 if (!module->InternalInit(module_id, get_browser_interface)) { | 30 if (!module->InternalInit(module_id, get_browser_interface)) { |
| 40 delete module; | 31 delete module; |
| 41 return PP_ERROR_FAILED; | 32 return PP_ERROR_FAILED; |
| 42 } | 33 } |
| 43 | 34 |
| 44 #if !defined(NDEBUG) | 35 #if !defined(NDEBUG) |
| 45 // Register a global log handler, but only in Debug builds. | 36 // Register a global log handler, but only in Debug builds. |
| 46 ChromotingInstance::RegisterLogMessageHandler(); | 37 ChromotingInstance::RegisterLogMessageHandler(); |
| 47 #endif | 38 #endif |
| 48 | 39 |
| 49 g_module_singleton = module; | 40 pp::InternalSetModuleSingleton(module); |
| 50 return PP_OK; | 41 return PP_OK; |
| 51 } | 42 } |
| 52 | 43 |
| 53 void PPP_ShutdownModule() { | 44 void PPP_ShutdownModule() { |
| 54 delete pp::Module::Get(); | 45 delete pp::Module::Get(); |
| 55 g_module_singleton = NULL; | 46 pp::InternalSetModuleSingleton(NULL); |
| 56 } | 47 } |
| 57 | 48 |
| 58 const void* PPP_GetInterface(const char* interface_name) { | 49 const void* PPP_GetInterface(const char* interface_name) { |
| 59 if (!pp::Module::Get()) | 50 if (!pp::Module::Get()) |
| 60 return NULL; | 51 return NULL; |
| 61 return pp::Module::Get()->GetPluginInterface(interface_name); | 52 return pp::Module::Get()->GetPluginInterface(interface_name); |
| 62 } | 53 } |
| 63 | 54 |
| 64 const void* PPP_GetBrowserInterface(const char* interface_name) { | 55 const void* PPP_GetBrowserInterface(const char* interface_name) { |
| 65 if (!pp::Module::Get()) | 56 if (!pp::Module::Get()) |
| 66 return NULL; | 57 return NULL; |
| 67 return pp::Module::Get()->GetBrowserInterface(interface_name); | 58 return pp::Module::Get()->GetBrowserInterface(interface_name); |
| 68 } | 59 } |
| 69 | 60 |
| 70 } // namespace remoting | 61 } // namespace remoting |
| OLD | NEW |