This source file includes following definitions.
- private_interface_
- Init
- CreateInstance
- CreateModule
#include "native_client/src/shared/imc/nacl_imc_c.h"
#include "native_client/src/shared/platform/nacl_secure_random.h"
#include "native_client/src/shared/platform/nacl_time.h"
#include "native_client/src/trusted/desc/nrd_all_modules.h"
#include "ppapi/native_client/src/trusted/plugin/module_ppapi.h"
#include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h"
#include "ppapi/native_client/src/trusted/plugin/plugin.h"
namespace plugin {
ModulePpapi::ModulePpapi() : pp::Module(),
init_was_successful_(false),
private_interface_(NULL) {
MODULE_PRINTF(("ModulePpapi::ModulePpapi (this=%p)\n",
static_cast<void*>(this)));
}
ModulePpapi::~ModulePpapi() {
if (init_was_successful_) {
NaClSrpcModuleFini();
NaClNrdAllModulesFini();
}
MODULE_PRINTF(("ModulePpapi::~ModulePpapi (this=%p)\n",
static_cast<void*>(this)));
}
bool ModulePpapi::Init() {
private_interface_ = reinterpret_cast<const PPB_NaCl_Private*>(
GetBrowserInterface(PPB_NACL_PRIVATE_INTERFACE));
if (NULL == private_interface_) {
MODULE_PRINTF(("ModulePpapi::Init failed: "
"GetBrowserInterface returned NULL\n"));
return false;
}
launch_nacl_process = reinterpret_cast<LaunchNaClProcessFunc>(
private_interface_->LaunchSelLdr);
#if NACL_LINUX || NACL_OSX
NaClSecureRngModuleSetUrandomFd(dup(private_interface_->UrandomFD()));
#endif
NaClAllowLowResolutionTimeOfDay();
NaClNrdAllModulesInit();
NaClSrpcModuleInit();
#if NACL_WINDOWS
NaClSetBrokerDuplicateHandleFunc(private_interface_->BrokerDuplicateHandle);
#endif
init_was_successful_ = true;
return true;
}
pp::Instance* ModulePpapi::CreateInstance(PP_Instance pp_instance) {
MODULE_PRINTF(("ModulePpapi::CreateInstance (pp_instance=%" NACL_PRId32
")\n",
pp_instance));
Plugin* plugin = Plugin::New(pp_instance);
MODULE_PRINTF(("ModulePpapi::CreateInstance (return %p)\n",
static_cast<void* >(plugin)));
return plugin;
}
}
namespace pp {
Module* CreateModule() {
MODULE_PRINTF(("CreateModule ()\n"));
return new plugin::ModulePpapi();
}
}