OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); | 1489 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); |
1490 // Will always call the callback on success or failure. | 1490 // Will always call the callback on success or failure. |
1491 pnacl_coordinator_.reset( | 1491 pnacl_coordinator_.reset( |
1492 PnaclCoordinator::BitcodeToNative(this, | 1492 PnaclCoordinator::BitcodeToNative(this, |
1493 program_url, | 1493 program_url, |
1494 cache_identity, | 1494 cache_identity, |
1495 translate_callback)); | 1495 translate_callback)); |
1496 return; | 1496 return; |
1497 } else { | 1497 } else { |
1498 pp::CompletionCallback open_callback = | 1498 pp::CompletionCallback open_callback = |
1499 callback_factory_.NewRequiredCallback(&Plugin::NexeFileDidOpen); | 1499 callback_factory_.NewCallback(&Plugin::NexeFileDidOpen); |
1500 // Will always call the callback on success or failure. | 1500 // Will always call the callback on success or failure. |
1501 CHECK( | 1501 CHECK( |
1502 nexe_downloader_.Open(program_url, | 1502 nexe_downloader_.Open(program_url, |
1503 DOWNLOAD_TO_FILE, | 1503 DOWNLOAD_TO_FILE, |
1504 open_callback, | 1504 open_callback, |
1505 &UpdateDownloadProgress)); | 1505 &UpdateDownloadProgress)); |
1506 return; | 1506 return; |
1507 } | 1507 } |
1508 } | 1508 } |
1509 // Failed to select the program and/or the translator. | 1509 // Failed to select the program and/or the translator. |
(...skipping 21 matching lines...) Expand all Loading... |
1531 nmf_resolved_url.AsString().c_str())); | 1531 nmf_resolved_url.AsString().c_str())); |
1532 set_manifest_base_url(nmf_resolved_url.AsString()); | 1532 set_manifest_base_url(nmf_resolved_url.AsString()); |
1533 set_manifest_url(url); | 1533 set_manifest_url(url); |
1534 // Inform JavaScript that a load is starting. | 1534 // Inform JavaScript that a load is starting. |
1535 set_nacl_ready_state(OPENED); | 1535 set_nacl_ready_state(OPENED); |
1536 EnqueueProgressEvent(kProgressEventLoadStart); | 1536 EnqueueProgressEvent(kProgressEventLoadStart); |
1537 bool is_data_uri = GetUrlScheme(nmf_resolved_url.AsString()) == SCHEME_DATA; | 1537 bool is_data_uri = GetUrlScheme(nmf_resolved_url.AsString()) == SCHEME_DATA; |
1538 HistogramEnumerateManifestIsDataURI(static_cast<int>(is_data_uri)); | 1538 HistogramEnumerateManifestIsDataURI(static_cast<int>(is_data_uri)); |
1539 if (is_data_uri) { | 1539 if (is_data_uri) { |
1540 pp::CompletionCallback open_callback = | 1540 pp::CompletionCallback open_callback = |
1541 callback_factory_.NewRequiredCallback(&Plugin::NaClManifestBufferReady); | 1541 callback_factory_.NewCallback(&Plugin::NaClManifestBufferReady); |
1542 // Will always call the callback on success or failure. | 1542 // Will always call the callback on success or failure. |
1543 CHECK(nexe_downloader_.Open(nmf_resolved_url.AsString(), | 1543 CHECK(nexe_downloader_.Open(nmf_resolved_url.AsString(), |
1544 DOWNLOAD_TO_BUFFER, | 1544 DOWNLOAD_TO_BUFFER, |
1545 open_callback, | 1545 open_callback, |
1546 NULL)); | 1546 NULL)); |
1547 } else { | 1547 } else { |
1548 pp::CompletionCallback open_callback = | 1548 pp::CompletionCallback open_callback = |
1549 callback_factory_.NewRequiredCallback(&Plugin::NaClManifestFileDidOpen); | 1549 callback_factory_.NewCallback(&Plugin::NaClManifestFileDidOpen); |
1550 // Will always call the callback on success or failure. | 1550 // Will always call the callback on success or failure. |
1551 CHECK(nexe_downloader_.Open(nmf_resolved_url.AsString(), | 1551 CHECK(nexe_downloader_.Open(nmf_resolved_url.AsString(), |
1552 DOWNLOAD_TO_FILE, | 1552 DOWNLOAD_TO_FILE, |
1553 open_callback, | 1553 open_callback, |
1554 NULL)); | 1554 NULL)); |
1555 } | 1555 } |
1556 } | 1556 } |
1557 | 1557 |
1558 | 1558 |
1559 bool Plugin::SetManifestObject(const nacl::string& manifest_json, | 1559 bool Plugin::SetManifestObject(const nacl::string& manifest_json, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1607 return file_desc_ok_to_close; | 1607 return file_desc_ok_to_close; |
1608 } | 1608 } |
1609 | 1609 |
1610 | 1610 |
1611 bool Plugin::StreamAsFile(const nacl::string& url, | 1611 bool Plugin::StreamAsFile(const nacl::string& url, |
1612 PP_CompletionCallback callback) { | 1612 PP_CompletionCallback callback) { |
1613 PLUGIN_PRINTF(("Plugin::StreamAsFile (url='%s')\n", url.c_str())); | 1613 PLUGIN_PRINTF(("Plugin::StreamAsFile (url='%s')\n", url.c_str())); |
1614 FileDownloader* downloader = new FileDownloader(); | 1614 FileDownloader* downloader = new FileDownloader(); |
1615 downloader->Initialize(this); | 1615 downloader->Initialize(this); |
1616 url_downloaders_.insert(downloader); | 1616 url_downloaders_.insert(downloader); |
1617 pp::CompletionCallback open_callback = | 1617 pp::CompletionCallback open_callback = callback_factory_.NewCallback( |
1618 callback_factory_.NewRequiredCallback( | 1618 &Plugin::UrlDidOpenForStreamAsFile, downloader, callback); |
1619 &Plugin::UrlDidOpenForStreamAsFile, downloader, callback); | |
1620 // Untrusted loads are always relative to the page's origin. | 1619 // Untrusted loads are always relative to the page's origin. |
1621 CHECK(url_util_ != NULL); | 1620 CHECK(url_util_ != NULL); |
1622 pp::Var resolved_url = | 1621 pp::Var resolved_url = |
1623 url_util_->ResolveRelativeToURL(pp::Var(plugin_base_url()), url); | 1622 url_util_->ResolveRelativeToURL(pp::Var(plugin_base_url()), url); |
1624 if (!resolved_url.is_string()) { | 1623 if (!resolved_url.is_string()) { |
1625 PLUGIN_PRINTF(("Plugin::StreamAsFile: " | 1624 PLUGIN_PRINTF(("Plugin::StreamAsFile: " |
1626 "could not resolve url \"%s\" relative to plugin \"%s\".", | 1625 "could not resolve url \"%s\" relative to plugin \"%s\".", |
1627 url.c_str(), | 1626 url.c_str(), |
1628 plugin_base_url().c_str())); | 1627 plugin_base_url().c_str())); |
1629 return false; | 1628 return false; |
1630 } | 1629 } |
1631 // If true, will always call the callback on success or failure. | 1630 // If true, will always call the callback on success or failure. |
1632 return downloader->Open(url, | 1631 return downloader->Open(url, |
1633 DOWNLOAD_TO_FILE, | 1632 DOWNLOAD_TO_FILE, |
1634 open_callback, | 1633 open_callback, |
1635 &UpdateDownloadProgress); | 1634 &UpdateDownloadProgress); |
1636 } | 1635 } |
1637 | 1636 |
1638 #ifndef HACK_FOR_MACOS_HANG_REMOVED | 1637 #ifndef HACK_FOR_MACOS_HANG_REMOVED |
1639 // The following is needed to avoid a plugin startup hang in the | 1638 // The following is needed to avoid a plugin startup hang in the |
1640 // MacOS "chrome_browser_tests under gyp" stage. | 1639 // MacOS "chrome_browser_tests under gyp" stage. |
1641 // TODO(sehr,mseaborn): remove this hack. | 1640 // TODO(sehr,mseaborn): remove this hack. |
1642 void (plugin::Plugin::*pmem)(int32_t, | 1641 void (plugin::Plugin::*pmem)(int32_t, |
1643 plugin::FileDownloader*&, | 1642 plugin::FileDownloader*&, |
1644 pp::VarPrivate&); | 1643 pp::VarPrivate&); |
1645 void Plugin::XYZZY(const nacl::string& url, | 1644 void Plugin::XYZZY(const nacl::string& url, |
1646 pp::VarPrivate js_callback) { | 1645 pp::VarPrivate js_callback) { |
1647 UNREFERENCED_PARAMETER(url); | 1646 UNREFERENCED_PARAMETER(url); |
1648 UNREFERENCED_PARAMETER(js_callback); | 1647 UNREFERENCED_PARAMETER(js_callback); |
1649 pp::CompletionCallback open_callback = | 1648 pp::CompletionCallback open_callback = callback_factory_.NewCallback(pmem, |
1650 callback_factory_.NewRequiredCallback(pmem, | 1649 reinterpret_cast<plugin::FileDownloader*>(NULL), |
1651 reinterpret_cast<plugin::FileDownloader*>(NULL), | 1650 js_callback); |
1652 js_callback); | |
1653 static_cast<void>(open_callback); | 1651 static_cast<void>(open_callback); |
1654 } | 1652 } |
1655 #endif // HACK_FOR_MACOS_HANG_REMOVED | 1653 #endif // HACK_FOR_MACOS_HANG_REMOVED |
1656 | 1654 |
1657 | 1655 |
1658 void Plugin::ReportLoadSuccess(LengthComputable length_computable, | 1656 void Plugin::ReportLoadSuccess(LengthComputable length_computable, |
1659 uint64_t loaded_bytes, | 1657 uint64_t loaded_bytes, |
1660 uint64_t total_bytes) { | 1658 uint64_t total_bytes) { |
1661 // Set the readyState attribute to indicate loaded. | 1659 // Set the readyState attribute to indicate loaded. |
1662 set_nacl_ready_state(DONE); | 1660 set_nacl_ready_state(DONE); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 static_cast<uint32_t>(text.size())); | 1915 static_cast<uint32_t>(text.size())); |
1918 const PPB_Console_Dev* console_interface = | 1916 const PPB_Console_Dev* console_interface = |
1919 static_cast<const PPB_Console_Dev*>( | 1917 static_cast<const PPB_Console_Dev*>( |
1920 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)); | 1918 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)); |
1921 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); | 1919 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); |
1922 var_interface->Release(prefix); | 1920 var_interface->Release(prefix); |
1923 var_interface->Release(str); | 1921 var_interface->Release(str); |
1924 } | 1922 } |
1925 | 1923 |
1926 } // namespace plugin | 1924 } // namespace plugin |
OLD | NEW |