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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <numeric> | 9 #include <numeric> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/containers/scoped_ptr_hash_map.h" | 17 #include "base/containers/scoped_ptr_hash_map.h" |
18 #include "base/cpu.h" | 18 #include "base/cpu.h" |
19 #include "base/files/file.h" | 19 #include "base/files/file.h" |
20 #include "base/json/json_reader.h" | 20 #include "base/json/json_reader.h" |
21 #include "base/lazy_instance.h" | 21 #include "base/lazy_instance.h" |
22 #include "base/location.h" | 22 #include "base/location.h" |
23 #include "base/logging.h" | 23 #include "base/logging.h" |
24 #include "base/macros.h" | 24 #include "base/macros.h" |
25 #include "base/rand_util.h" | |
26 #include "base/single_thread_task_runner.h" | 25 #include "base/single_thread_task_runner.h" |
27 #include "base/strings/string_split.h" | 26 #include "base/strings/string_split.h" |
28 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" |
29 #include "base/thread_task_runner_handle.h" | 28 #include "base/thread_task_runner_handle.h" |
30 #include "build/build_config.h" | 29 #include "build/build_config.h" |
31 #include "components/nacl/common/nacl_host_messages.h" | 30 #include "components/nacl/common/nacl_host_messages.h" |
32 #include "components/nacl/common/nacl_messages.h" | 31 #include "components/nacl/common/nacl_messages.h" |
33 #include "components/nacl/common/nacl_nonsfi_util.h" | 32 #include "components/nacl/common/nacl_nonsfi_util.h" |
34 #include "components/nacl/common/nacl_switches.h" | 33 #include "components/nacl/common/nacl_switches.h" |
35 #include "components/nacl/common/nacl_types.h" | 34 #include "components/nacl/common/nacl_types.h" |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 } else if (result == PP_EXTERNAL_PLUGIN_ERROR_MODULE) { | 612 } else if (result == PP_EXTERNAL_PLUGIN_ERROR_MODULE) { |
614 load_manager->ReportLoadError(PP_NACL_ERROR_START_PROXY_MODULE, | 613 load_manager->ReportLoadError(PP_NACL_ERROR_START_PROXY_MODULE, |
615 "could not initialize module."); | 614 "could not initialize module."); |
616 } else if (result == PP_EXTERNAL_PLUGIN_ERROR_INSTANCE) { | 615 } else if (result == PP_EXTERNAL_PLUGIN_ERROR_INSTANCE) { |
617 load_manager->ReportLoadError(PP_NACL_ERROR_START_PROXY_MODULE, | 616 load_manager->ReportLoadError(PP_NACL_ERROR_START_PROXY_MODULE, |
618 "could not create instance."); | 617 "could not create instance."); |
619 } | 618 } |
620 return PP_FALSE; | 619 return PP_FALSE; |
621 } | 620 } |
622 | 621 |
623 int UrandomFD(void) { | |
624 #if defined(OS_POSIX) | |
625 return base::GetUrandomFD(); | |
626 #else | |
627 return -1; | |
628 #endif | |
629 } | |
630 | |
631 // Convert a URL to a filename for GetReadonlyPnaclFd. | 622 // Convert a URL to a filename for GetReadonlyPnaclFd. |
632 // Must be kept in sync with PnaclCanOpenFile() in | 623 // Must be kept in sync with PnaclCanOpenFile() in |
633 // components/nacl/browser/nacl_file_host.cc. | 624 // components/nacl/browser/nacl_file_host.cc. |
634 std::string PnaclComponentURLToFilename(const std::string& url) { | 625 std::string PnaclComponentURLToFilename(const std::string& url) { |
635 // PNaCl component URLs aren't arbitrary URLs; they are always either | 626 // PNaCl component URLs aren't arbitrary URLs; they are always either |
636 // generated from ManifestResolveKey or PnaclResources::ReadResourceInfo. | 627 // generated from ManifestResolveKey or PnaclResources::ReadResourceInfo. |
637 // So, it's safe to just use string parsing operations here instead of | 628 // So, it's safe to just use string parsing operations here instead of |
638 // URL-parsing ones. | 629 // URL-parsing ones. |
639 DCHECK(base::StartsWith(url, kPNaClTranslatorBaseUrl, | 630 DCHECK(base::StartsWith(url, kPNaClTranslatorBaseUrl, |
640 base::CompareCase::SENSITIVE)); | 631 base::CompareCase::SENSITIVE)); |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 // so that component updater can detect this user action. | 1684 // so that component updater can detect this user action. |
1694 url_request.addHTTPHeaderField( | 1685 url_request.addHTTPHeaderField( |
1695 blink::WebString::fromUTF8("Accept"), | 1686 blink::WebString::fromUTF8("Accept"), |
1696 blink::WebString::fromUTF8("application/x-pnacl, */*")); | 1687 blink::WebString::fromUTF8("application/x-pnacl, */*")); |
1697 url_request.setRequestContext(blink::WebURLRequest::RequestContextObject); | 1688 url_request.setRequestContext(blink::WebURLRequest::RequestContextObject); |
1698 downloader->Load(url_request); | 1689 downloader->Load(url_request); |
1699 } | 1690 } |
1700 | 1691 |
1701 const PPB_NaCl_Private nacl_interface = { | 1692 const PPB_NaCl_Private nacl_interface = { |
1702 &LaunchSelLdr, | 1693 &LaunchSelLdr, |
1703 &UrandomFD, | |
1704 &GetReadExecPnaclFd, | 1694 &GetReadExecPnaclFd, |
1705 &CreateTemporaryFile, | 1695 &CreateTemporaryFile, |
1706 &GetNumberOfProcessors, | 1696 &GetNumberOfProcessors, |
1707 &ReportTranslationFinished, | 1697 &ReportTranslationFinished, |
1708 &DispatchEvent, | 1698 &DispatchEvent, |
1709 &ReportLoadError, | 1699 &ReportLoadError, |
1710 &InstanceCreated, | 1700 &InstanceCreated, |
1711 &InstanceDestroyed, | 1701 &InstanceDestroyed, |
1712 &GetSandboxArch, | 1702 &GetSandboxArch, |
1713 &InitializePlugin, | 1703 &InitializePlugin, |
(...skipping 10 matching lines...) Expand all Loading... |
1724 &StreamPexe | 1714 &StreamPexe |
1725 }; | 1715 }; |
1726 | 1716 |
1727 } // namespace | 1717 } // namespace |
1728 | 1718 |
1729 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1719 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1730 return &nacl_interface; | 1720 return &nacl_interface; |
1731 } | 1721 } |
1732 | 1722 |
1733 } // namespace nacl | 1723 } // namespace nacl |
OLD | NEW |