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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/module_ppapi.cc

Issue 876483002: NaCl: Move src/trusted/plugin/ to components/nacl/renderer/plugin/ (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update #include guards 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 /*
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7 #include "native_client/src/shared/imc/nacl_imc_c.h"
8 #include "native_client/src/shared/platform/nacl_secure_random.h"
9 #include "native_client/src/shared/platform/nacl_time.h"
10 #include "native_client/src/trusted/desc/nrd_all_modules.h"
11
12 #include "ppapi/native_client/src/trusted/plugin/module_ppapi.h"
13 #include "ppapi/native_client/src/trusted/plugin/plugin.h"
14 #include "ppapi/native_client/src/trusted/plugin/utility.h"
15
16 namespace plugin {
17
18 ModulePpapi::ModulePpapi() : pp::Module(),
19 init_was_successful_(false),
20 private_interface_(NULL) {
21 MODULE_PRINTF(("ModulePpapi::ModulePpapi (this=%p)\n",
22 static_cast<void*>(this)));
23 }
24
25 ModulePpapi::~ModulePpapi() {
26 if (init_was_successful_) {
27 NaClSrpcModuleFini();
28 NaClNrdAllModulesFini();
29 }
30 MODULE_PRINTF(("ModulePpapi::~ModulePpapi (this=%p)\n",
31 static_cast<void*>(this)));
32 }
33
34 bool ModulePpapi::Init() {
35 // Ask the browser for an interface which provides missing functions
36 private_interface_ = reinterpret_cast<const PPB_NaCl_Private*>(
37 GetBrowserInterface(PPB_NACL_PRIVATE_INTERFACE));
38
39 if (NULL == private_interface_) {
40 MODULE_PRINTF(("ModulePpapi::Init failed: "
41 "GetBrowserInterface returned NULL\n"));
42 return false;
43 }
44 SetNaClInterface(private_interface_);
45
46 #if NACL_LINUX || NACL_OSX
47 // Note that currently we do not need random numbers inside the
48 // NaCl trusted plugin on Unix, but NaClSecureRngModuleInit() is
49 // strict and will raise a fatal error unless we provide it with a
50 // /dev/urandom FD beforehand.
51 NaClSecureRngModuleSetUrandomFd(dup(private_interface_->UrandomFD()));
52 #endif
53
54 // In the plugin, we don't need high resolution time of day.
55 NaClAllowLowResolutionTimeOfDay();
56 NaClNrdAllModulesInit();
57 NaClSrpcModuleInit();
58
59 #if NACL_WINDOWS
60 NaClSetBrokerDuplicateHandleFunc(private_interface_->BrokerDuplicateHandle);
61 #endif
62
63 init_was_successful_ = true;
64 return true;
65 }
66
67 pp::Instance* ModulePpapi::CreateInstance(PP_Instance pp_instance) {
68 MODULE_PRINTF(("ModulePpapi::CreateInstance (pp_instance=%" NACL_PRId32
69 ")\n",
70 pp_instance));
71 Plugin* plugin = new Plugin(pp_instance);
72 MODULE_PRINTF(("ModulePpapi::CreateInstance (return %p)\n",
73 static_cast<void* >(plugin)));
74 return plugin;
75 }
76
77 } // namespace plugin
78
79
80 namespace pp {
81
82 Module* CreateModule() {
83 MODULE_PRINTF(("CreateModule ()\n"));
84 return new plugin::ModulePpapi();
85 }
86
87 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698