OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifdef _MSC_VER | 5 #ifdef _MSC_VER |
6 // Do not warn about use of std::copy with raw pointers. | 6 // Do not warn about use of std::copy with raw pointers. |
7 #pragma warning(disable : 4996) | 7 #pragma warning(disable : 4996) |
8 #endif | 8 #endif |
9 | 9 |
10 #include "native_client/src/trusted/plugin/plugin.h" | 10 #include "native_client/src/trusted/plugin/plugin.h" |
(...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 if (!SetManifestObject(manifest_json, &error_info)) { | 1600 if (!SetManifestObject(manifest_json, &error_info)) { |
1601 ReportLoadError(error_info); | 1601 ReportLoadError(error_info); |
1602 return; | 1602 return; |
1603 } | 1603 } |
1604 | 1604 |
1605 if (SelectProgramURLFromManifest(&program_url, &error_info, &is_portable)) { | 1605 if (SelectProgramURLFromManifest(&program_url, &error_info, &is_portable)) { |
1606 set_nacl_ready_state(LOADING); | 1606 set_nacl_ready_state(LOADING); |
1607 // Inform JavaScript that we found a nexe URL to load. | 1607 // Inform JavaScript that we found a nexe URL to load. |
1608 EnqueueProgressEvent(kProgressEventProgress); | 1608 EnqueueProgressEvent(kProgressEventProgress); |
1609 if (is_portable) { | 1609 if (is_portable) { |
1610 // TODO(jvoung): Do we want to check an ENV var if pnacl is enabled first? | 1610 pp::CompletionCallback translate_callback = |
1611 nacl::string llc_url; | 1611 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); |
1612 nacl::string ld_url; | 1612 // Will always call the callback on success or failure. |
1613 if (SelectLLCURLFromManifest(&llc_url, &error_info) && | 1613 pnacl_.BitcodeToNative(program_url, translate_callback); |
1614 SelectLDURLFromManifest(&ld_url, &error_info)) { | 1614 return; |
1615 pp::CompletionCallback translate_callback = | |
1616 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); | |
1617 // Will always call the callback on success or failure. | |
1618 pnacl_.BitcodeToNative(program_url, | |
1619 llc_url, | |
1620 ld_url, | |
1621 translate_callback); | |
1622 return; | |
1623 } | |
1624 } else { | 1615 } else { |
1625 pp::CompletionCallback open_callback = | 1616 pp::CompletionCallback open_callback = |
1626 callback_factory_.NewRequiredCallback(&Plugin::NexeFileDidOpen); | 1617 callback_factory_.NewRequiredCallback(&Plugin::NexeFileDidOpen); |
1627 // Will always call the callback on success or failure. | 1618 // Will always call the callback on success or failure. |
1628 CHECK( | 1619 CHECK( |
1629 nexe_downloader_.Open(program_url, | 1620 nexe_downloader_.Open(program_url, |
1630 DOWNLOAD_TO_FILE, | 1621 DOWNLOAD_TO_FILE, |
1631 open_callback, | 1622 open_callback, |
1632 &UpdateDownloadProgress)); | 1623 &UpdateDownloadProgress)); |
1633 return; | 1624 return; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 ErrorInfo* error_info, | 1692 ErrorInfo* error_info, |
1702 bool* is_portable) { | 1693 bool* is_portable) { |
1703 const nacl::string sandbox_isa(GetSandboxISA()); | 1694 const nacl::string sandbox_isa(GetSandboxISA()); |
1704 PLUGIN_PRINTF(("Plugin::SelectProgramURLFromManifest(): sandbox='%s'.\n", | 1695 PLUGIN_PRINTF(("Plugin::SelectProgramURLFromManifest(): sandbox='%s'.\n", |
1705 sandbox_isa.c_str())); | 1696 sandbox_isa.c_str())); |
1706 if (result == NULL || error_info == NULL || manifest_ == NULL) | 1697 if (result == NULL || error_info == NULL || manifest_ == NULL) |
1707 return false; | 1698 return false; |
1708 return manifest_->GetProgramURL(result, error_info, is_portable); | 1699 return manifest_->GetProgramURL(result, error_info, is_portable); |
1709 } | 1700 } |
1710 | 1701 |
1711 // TODO(jvoung): get rid of these when we have a better hosting solution | |
1712 // for PNaCl's nexes. | |
1713 bool Plugin::SelectLLCURLFromManifest(nacl::string* result, | |
1714 ErrorInfo* error_info) { | |
1715 PLUGIN_PRINTF(("Plugin::SelectLLCURLFromManifest()\n")); | |
1716 if (result == NULL || error_info == NULL || manifest_ == NULL) | |
1717 return false; | |
1718 return manifest_->GetLLCURL(result, error_info); | |
1719 } | |
1720 | |
1721 bool Plugin::SelectLDURLFromManifest(nacl::string* result, | |
1722 ErrorInfo* error_info) { | |
1723 PLUGIN_PRINTF(("Plugin::SelectLDURLFromManifest()\n")); | |
1724 if (result == NULL || error_info == NULL || manifest_ == NULL) | |
1725 return false; | |
1726 return manifest_->GetLDURL(result, error_info); | |
1727 } | |
1728 // end TODO(jvoung) | |
1729 | |
1730 | |
1731 void Plugin::UrlDidOpenForStreamAsFile(int32_t pp_error, | 1702 void Plugin::UrlDidOpenForStreamAsFile(int32_t pp_error, |
1732 FileDownloader*& url_downloader, | 1703 FileDownloader*& url_downloader, |
1733 PP_CompletionCallback callback) { | 1704 PP_CompletionCallback callback) { |
1734 PLUGIN_PRINTF(("Plugin::UrlDidOpen (pp_error=%"NACL_PRId32 | 1705 PLUGIN_PRINTF(("Plugin::UrlDidOpen (pp_error=%"NACL_PRId32 |
1735 ", url_downloader=%p)\n", pp_error, | 1706 ", url_downloader=%p)\n", pp_error, |
1736 static_cast<void*>(url_downloader))); | 1707 static_cast<void*>(url_downloader))); |
1737 url_downloaders_.erase(url_downloader); | 1708 url_downloaders_.erase(url_downloader); |
1738 nacl::scoped_ptr<FileDownloader> scoped_url_downloader(url_downloader); | 1709 nacl::scoped_ptr<FileDownloader> scoped_url_downloader(url_downloader); |
1739 int32_t file_desc = scoped_url_downloader->GetPOSIXFileDescriptor(); | 1710 int32_t file_desc = scoped_url_downloader->GetPOSIXFileDescriptor(); |
1740 | 1711 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2041 std::string scheme = canonicalized.AsString().substr(comps.scheme.begin, | 2012 std::string scheme = canonicalized.AsString().substr(comps.scheme.begin, |
2042 comps.scheme.len); | 2013 comps.scheme.len); |
2043 if (scheme == kChromeExtensionUriScheme) | 2014 if (scheme == kChromeExtensionUriScheme) |
2044 return SCHEME_CHROME_EXTENSION; | 2015 return SCHEME_CHROME_EXTENSION; |
2045 if (scheme == kDataUriScheme) | 2016 if (scheme == kDataUriScheme) |
2046 return SCHEME_DATA; | 2017 return SCHEME_DATA; |
2047 return SCHEME_OTHER; | 2018 return SCHEME_OTHER; |
2048 } | 2019 } |
2049 | 2020 |
2050 } // namespace plugin | 2021 } // namespace plugin |
OLD | NEW |