OLD | NEW |
---|---|
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 #include <numeric> | 7 #include <numeric> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/containers/scoped_ptr_hash_map.h" | 14 #include "base/containers/scoped_ptr_hash_map.h" |
15 #include "base/cpu.h" | 15 #include "base/cpu.h" |
16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
19 #include "components/nacl/common/nacl_host_messages.h" | 19 #include "components/nacl/common/nacl_host_messages.h" |
20 #include "components/nacl/common/nacl_messages.h" | 20 #include "components/nacl/common/nacl_messages.h" |
21 #include "components/nacl/common/nacl_nonsfi_util.h" | |
21 #include "components/nacl/common/nacl_switches.h" | 22 #include "components/nacl/common/nacl_switches.h" |
22 #include "components/nacl/common/nacl_types.h" | 23 #include "components/nacl/common/nacl_types.h" |
23 #include "components/nacl/renderer/histogram.h" | 24 #include "components/nacl/renderer/histogram.h" |
24 #include "components/nacl/renderer/json_manifest.h" | 25 #include "components/nacl/renderer/json_manifest.h" |
25 #include "components/nacl/renderer/manifest_downloader.h" | 26 #include "components/nacl/renderer/manifest_downloader.h" |
26 #include "components/nacl/renderer/manifest_service_channel.h" | 27 #include "components/nacl/renderer/manifest_service_channel.h" |
27 #include "components/nacl/renderer/nexe_load_manager.h" | 28 #include "components/nacl/renderer/nexe_load_manager.h" |
28 #include "components/nacl/renderer/pnacl_translation_resource_host.h" | 29 #include "components/nacl/renderer/pnacl_translation_resource_host.h" |
29 #include "components/nacl/renderer/progress_event.h" | 30 #include "components/nacl/renderer/progress_event.h" |
30 #include "components/nacl/renderer/sandbox_arch.h" | 31 #include "components/nacl/renderer/sandbox_arch.h" |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 int32_t GetNumberOfProcessors() { | 517 int32_t GetNumberOfProcessors() { |
517 int32_t num_processors; | 518 int32_t num_processors; |
518 IPC::Sender* sender = content::RenderThread::Get(); | 519 IPC::Sender* sender = content::RenderThread::Get(); |
519 DCHECK(sender); | 520 DCHECK(sender); |
520 if(!sender->Send(new NaClHostMsg_NaClGetNumProcessors(&num_processors))) { | 521 if(!sender->Send(new NaClHostMsg_NaClGetNumProcessors(&num_processors))) { |
521 return 1; | 522 return 1; |
522 } | 523 } |
523 return num_processors; | 524 return num_processors; |
524 } | 525 } |
525 | 526 |
526 PP_Bool IsNonSFIModeEnabled() { | 527 PP_Bool PPIsNonSFIModeEnabled() { |
527 // Note that this only indicates whether non-sfi mode *can* run for a given | 528 return IsNonSFIModeEnabled() ? PP_TRUE : PP_FALSE; |
Mark Seaborn
2014/05/12 22:49:26
Maybe use PP_FromBool as the original code did?
mdempsky
2014/05/12 22:54:24
Done.
| |
528 // platform and if nonsfi manifest entries are preferred. There can be other | |
529 // restrictions which prevent a particular module from launching. See | |
530 // NaClProcessHost::Launch which makes the final determination. | |
531 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | |
532 return PP_TRUE; | |
533 #elif defined(OS_LINUX) | |
534 return PP_FromBool(CommandLine::ForCurrentProcess()->HasSwitch( | |
535 switches::kEnableNaClNonSfiMode)); | |
536 #else | |
537 return PP_FALSE; | |
538 #endif | |
539 } | 529 } |
540 | 530 |
541 int32_t GetNexeFd(PP_Instance instance, | 531 int32_t GetNexeFd(PP_Instance instance, |
542 const char* pexe_url, | 532 const char* pexe_url, |
543 uint32_t abi_version, | 533 uint32_t abi_version, |
544 uint32_t opt_level, | 534 uint32_t opt_level, |
545 const char* http_headers_param, | 535 const char* http_headers_param, |
546 const char* extra_flags, | 536 const char* extra_flags, |
547 PP_Bool* is_hit, | 537 PP_Bool* is_hit, |
548 PP_FileHandle* handle, | 538 PP_FileHandle* handle, |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
998 const char* manifest_url, | 988 const char* manifest_url, |
999 const char* isa_type, | 989 const char* isa_type, |
1000 const char* manifest_data) { | 990 const char* manifest_data) { |
1001 int32_t manifest_id = g_next_manifest_id.Get(); | 991 int32_t manifest_id = g_next_manifest_id.Get(); |
1002 g_next_manifest_id.Get()++; | 992 g_next_manifest_id.Get()++; |
1003 | 993 |
1004 scoped_ptr<nacl::JsonManifest> j( | 994 scoped_ptr<nacl::JsonManifest> j( |
1005 new nacl::JsonManifest( | 995 new nacl::JsonManifest( |
1006 manifest_url, | 996 manifest_url, |
1007 isa_type, | 997 isa_type, |
1008 PP_ToBool(IsNonSFIModeEnabled()), | 998 IsNonSFIModeEnabled(), |
1009 PP_ToBool(NaClDebugEnabledForURL(manifest_url)))); | 999 PP_ToBool(NaClDebugEnabledForURL(manifest_url)))); |
1010 JsonManifest::ErrorInfo error_info; | 1000 JsonManifest::ErrorInfo error_info; |
1011 if (j->Init(manifest_data, &error_info)) { | 1001 if (j->Init(manifest_data, &error_info)) { |
1012 g_manifest_map.Get().add(manifest_id, j.Pass()); | 1002 g_manifest_map.Get().add(manifest_id, j.Pass()); |
1013 return manifest_id; | 1003 return manifest_id; |
1014 } | 1004 } |
1015 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 1005 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1016 if (load_manager) | 1006 if (load_manager) |
1017 load_manager->ReportLoadError(error_info.error, error_info.string); | 1007 load_manager->ReportLoadError(error_info.error, error_info.string); |
1018 return -1; | 1008 return -1; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1231 | 1221 |
1232 const PPB_NaCl_Private nacl_interface = { | 1222 const PPB_NaCl_Private nacl_interface = { |
1233 &LaunchSelLdr, | 1223 &LaunchSelLdr, |
1234 &StartPpapiProxy, | 1224 &StartPpapiProxy, |
1235 &UrandomFD, | 1225 &UrandomFD, |
1236 &Are3DInterfacesDisabled, | 1226 &Are3DInterfacesDisabled, |
1237 &BrokerDuplicateHandle, | 1227 &BrokerDuplicateHandle, |
1238 &GetReadonlyPnaclFD, | 1228 &GetReadonlyPnaclFD, |
1239 &CreateTemporaryFile, | 1229 &CreateTemporaryFile, |
1240 &GetNumberOfProcessors, | 1230 &GetNumberOfProcessors, |
1241 &IsNonSFIModeEnabled, | 1231 &PPIsNonSFIModeEnabled, |
1242 &GetNexeFd, | 1232 &GetNexeFd, |
1243 &ReportTranslationFinished, | 1233 &ReportTranslationFinished, |
1244 &OpenNaClExecutable, | 1234 &OpenNaClExecutable, |
1245 &DispatchEvent, | 1235 &DispatchEvent, |
1246 &NexeFileDidOpen, | 1236 &NexeFileDidOpen, |
1247 &ReportLoadSuccess, | 1237 &ReportLoadSuccess, |
1248 &ReportLoadError, | 1238 &ReportLoadError, |
1249 &ReportLoadAbort, | 1239 &ReportLoadAbort, |
1250 &NexeDidCrash, | 1240 &NexeDidCrash, |
1251 &InstanceCreated, | 1241 &InstanceCreated, |
(...skipping 27 matching lines...) Expand all Loading... | |
1279 &PostMessageToJavaScript | 1269 &PostMessageToJavaScript |
1280 }; | 1270 }; |
1281 | 1271 |
1282 } // namespace | 1272 } // namespace |
1283 | 1273 |
1284 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1274 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1285 return &nacl_interface; | 1275 return &nacl_interface; |
1286 } | 1276 } |
1287 | 1277 |
1288 } // namespace nacl | 1278 } // namespace nacl |
OLD | NEW |