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

Side by Side Diff: components/nacl/renderer/ppb_nacl_private_impl.cc

Issue 177113009: Support non-SFI mode in NaCl manifest file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/nacl/renderer/ppb_nacl_private_impl.h" 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h"
6 6
7 #ifndef DISABLE_NACL 7 #ifndef DISABLE_NACL
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "components/nacl/common/nacl_host_messages.h" 14 #include "components/nacl/common/nacl_host_messages.h"
15 #include "components/nacl/common/nacl_messages.h" 15 #include "components/nacl/common/nacl_messages.h"
16 #include "components/nacl/common/nacl_switches.h"
16 #include "components/nacl/common/nacl_types.h" 17 #include "components/nacl/common/nacl_types.h"
17 #include "components/nacl/renderer/pnacl_translation_resource_host.h" 18 #include "components/nacl/renderer/pnacl_translation_resource_host.h"
18 #include "components/nacl/renderer/trusted_plugin_channel.h" 19 #include "components/nacl/renderer/trusted_plugin_channel.h"
19 #include "content/public/common/content_client.h" 20 #include "content/public/common/content_client.h"
20 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
21 #include "content/public/common/sandbox_init.h" 22 #include "content/public/common/sandbox_init.h"
22 #include "content/public/renderer/pepper_plugin_instance.h" 23 #include "content/public/renderer/pepper_plugin_instance.h"
23 #include "content/public/renderer/render_thread.h" 24 #include "content/public/renderer/render_thread.h"
24 #include "content/public/renderer/render_view.h" 25 #include "content/public/renderer/render_view.h"
25 #include "content/public/renderer/renderer_ppapi_host.h" 26 #include "content/public/renderer/renderer_ppapi_host.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 if (!host) 101 if (!host)
101 return 0; 102 return 0;
102 return host->GetRoutingIDForWidget(instance); 103 return host->GetRoutingIDForWidget(instance);
103 } 104 }
104 105
105 // Launch NaCl's sel_ldr process. 106 // Launch NaCl's sel_ldr process.
106 void LaunchSelLdr(PP_Instance instance, 107 void LaunchSelLdr(PP_Instance instance,
107 const char* alleged_url, 108 const char* alleged_url,
108 PP_Bool uses_irt, 109 PP_Bool uses_irt,
109 PP_Bool uses_ppapi, 110 PP_Bool uses_ppapi,
111 PP_Bool uses_nonsfi_mode,
110 PP_Bool enable_ppapi_dev, 112 PP_Bool enable_ppapi_dev,
111 PP_Bool enable_dyncode_syscalls, 113 PP_Bool enable_dyncode_syscalls,
112 PP_Bool enable_exception_handling, 114 PP_Bool enable_exception_handling,
113 PP_Bool enable_crash_throttling, 115 PP_Bool enable_crash_throttling,
114 void* imc_handle, 116 void* imc_handle,
115 struct PP_Var* error_message, 117 struct PP_Var* error_message,
116 PP_CompletionCallback callback) { 118 PP_CompletionCallback callback) {
117 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> 119 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->
118 BelongsToCurrentThread()); 120 BelongsToCurrentThread());
119 121
(...skipping 29 matching lines...) Expand all
149 instance_info.permissions = 151 instance_info.permissions =
150 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); 152 ppapi::PpapiPermissions::GetForCommandLine(perm_bits);
151 std::string error_message_string; 153 std::string error_message_string;
152 nacl::NaClLaunchResult launch_result; 154 nacl::NaClLaunchResult launch_result;
153 155
154 if (!sender->Send(new NaClHostMsg_LaunchNaCl( 156 if (!sender->Send(new NaClHostMsg_LaunchNaCl(
155 nacl::NaClLaunchParams(instance_info.url.spec(), 157 nacl::NaClLaunchParams(instance_info.url.spec(),
156 routing_id, 158 routing_id,
157 perm_bits, 159 perm_bits,
158 PP_ToBool(uses_irt), 160 PP_ToBool(uses_irt),
161 PP_ToBool(uses_nonsfi_mode),
159 PP_ToBool(enable_dyncode_syscalls), 162 PP_ToBool(enable_dyncode_syscalls),
160 PP_ToBool(enable_exception_handling), 163 PP_ToBool(enable_exception_handling),
161 PP_ToBool(enable_crash_throttling)), 164 PP_ToBool(enable_crash_throttling)),
162 &launch_result, 165 &launch_result,
163 &error_message_string))) { 166 &error_message_string))) {
164 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( 167 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
165 FROM_HERE, 168 FROM_HERE,
166 base::Bind(callback.func, callback.user_data, 169 base::Bind(callback.func, callback.user_data,
167 static_cast<int32_t>(PP_ERROR_FAILED))); 170 static_cast<int32_t>(PP_ERROR_FAILED)));
168 return; 171 return;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 int32_t GetNumberOfProcessors() { 298 int32_t GetNumberOfProcessors() {
296 int32_t num_processors; 299 int32_t num_processors;
297 IPC::Sender* sender = content::RenderThread::Get(); 300 IPC::Sender* sender = content::RenderThread::Get();
298 DCHECK(sender); 301 DCHECK(sender);
299 if(!sender->Send(new NaClHostMsg_NaClGetNumProcessors(&num_processors))) { 302 if(!sender->Send(new NaClHostMsg_NaClGetNumProcessors(&num_processors))) {
300 return 1; 303 return 1;
301 } 304 }
302 return num_processors; 305 return num_processors;
303 } 306 }
304 307
308 PP_Bool IsNonSFIEnabled() {
309 #if defined(OS_LINUX)
310 return PP_FromBool(CommandLine::ForCurrentProcess()->HasSwitch(
311 switches::kEnableNaClNonSfiMode));
312 #else
313 return PP_FALSE;
314 #endif
315 }
316
305 int32_t GetNexeFd(PP_Instance instance, 317 int32_t GetNexeFd(PP_Instance instance,
306 const char* pexe_url, 318 const char* pexe_url,
307 uint32_t abi_version, 319 uint32_t abi_version,
308 uint32_t opt_level, 320 uint32_t opt_level,
309 const char* last_modified, 321 const char* last_modified,
310 const char* etag, 322 const char* etag,
311 PP_Bool has_no_store_header, 323 PP_Bool has_no_store_header,
312 const char* sandbox_isa, 324 const char* sandbox_isa,
313 const char* extra_flags, 325 const char* extra_flags,
314 PP_Bool* is_hit, 326 PP_Bool* is_hit,
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 554
543 const PPB_NaCl_Private nacl_interface = { 555 const PPB_NaCl_Private nacl_interface = {
544 &LaunchSelLdr, 556 &LaunchSelLdr,
545 &StartPpapiProxy, 557 &StartPpapiProxy,
546 &UrandomFD, 558 &UrandomFD,
547 &Are3DInterfacesDisabled, 559 &Are3DInterfacesDisabled,
548 &BrokerDuplicateHandle, 560 &BrokerDuplicateHandle,
549 &GetReadonlyPnaclFD, 561 &GetReadonlyPnaclFD,
550 &CreateTemporaryFile, 562 &CreateTemporaryFile,
551 &GetNumberOfProcessors, 563 &GetNumberOfProcessors,
564 &IsNonSFIEnabled,
552 &GetNexeFd, 565 &GetNexeFd,
553 &ReportTranslationFinished, 566 &ReportTranslationFinished,
554 &OpenNaClExecutable, 567 &OpenNaClExecutable,
555 &DispatchEvent, 568 &DispatchEvent,
556 &SetReadOnlyProperty, 569 &SetReadOnlyProperty,
557 &ReportLoadError, 570 &ReportLoadError,
558 &InstanceDestroyed 571 &InstanceDestroyed
559 }; 572 };
560 573
561 } // namespace 574 } // namespace
562 575
563 namespace nacl { 576 namespace nacl {
564 577
565 const PPB_NaCl_Private* GetNaClPrivateInterface() { 578 const PPB_NaCl_Private* GetNaClPrivateInterface() {
566 return &nacl_interface; 579 return &nacl_interface;
567 } 580 }
568 581
569 } // namespace nacl 582 } // namespace nacl
570 583
571 #endif // DISABLE_NACL 584 #endif // DISABLE_NACL
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698