| 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 "ppapi/native_client/src/trusted/plugin/plugin.h" | 10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 // If the MIME type is foreign, then this NEXE is being used as a content | 624 // If the MIME type is foreign, then this NEXE is being used as a content |
| 625 // type handler rather than directly by an HTML document. | 625 // type handler rather than directly by an HTML document. |
| 626 return | 626 return |
| 627 !mime_type().empty() && | 627 !mime_type().empty() && |
| 628 mime_type() != kNaClMIMEType && | 628 mime_type() != kNaClMIMEType && |
| 629 mime_type() != kPnaclMIMEType; | 629 mime_type() != kPnaclMIMEType; |
| 630 } | 630 } |
| 631 | 631 |
| 632 | 632 |
| 633 Plugin* Plugin::New(PP_Instance pp_instance) { | 633 Plugin* Plugin::New(PP_Instance pp_instance) { |
| 634 PLUGIN_PRINTF(("Plugin::New (pp_instance=%"NACL_PRId32")\n", pp_instance)); | 634 PLUGIN_PRINTF(("Plugin::New (pp_instance=%" NACL_PRId32 ")\n", pp_instance)); |
| 635 Plugin* plugin = new Plugin(pp_instance); | 635 Plugin* plugin = new Plugin(pp_instance); |
| 636 PLUGIN_PRINTF(("Plugin::New (plugin=%p)\n", static_cast<void*>(plugin))); | 636 PLUGIN_PRINTF(("Plugin::New (plugin=%p)\n", static_cast<void*>(plugin))); |
| 637 if (plugin == NULL) { | 637 if (plugin == NULL) { |
| 638 return NULL; | 638 return NULL; |
| 639 } | 639 } |
| 640 return plugin; | 640 return plugin; |
| 641 } | 641 } |
| 642 | 642 |
| 643 | 643 |
| 644 // All failures of this function will show up as "Missing Plugin-in", so | 644 // All failures of this function will show up as "Missing Plugin-in", so |
| 645 // there is no need to log to JS console that there was an initialization | 645 // there is no need to log to JS console that there was an initialization |
| 646 // failure. Note that module loading functions will log their own errors. | 646 // failure. Note that module loading functions will log their own errors. |
| 647 bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) { | 647 bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) { |
| 648 PLUGIN_PRINTF(("Plugin::Init (argc=%"NACL_PRIu32")\n", argc)); | 648 PLUGIN_PRINTF(("Plugin::Init (argc=%" NACL_PRIu32 ")\n", argc)); |
| 649 HistogramEnumerateOsArch(GetSandboxISA()); | 649 HistogramEnumerateOsArch(GetSandboxISA()); |
| 650 init_time_ = NaClGetTimeOfDayMicroseconds(); | 650 init_time_ = NaClGetTimeOfDayMicroseconds(); |
| 651 | 651 |
| 652 ScriptablePlugin* scriptable_plugin = ScriptablePlugin::NewPlugin(this); | 652 ScriptablePlugin* scriptable_plugin = ScriptablePlugin::NewPlugin(this); |
| 653 if (scriptable_plugin == NULL) | 653 if (scriptable_plugin == NULL) |
| 654 return false; | 654 return false; |
| 655 | 655 |
| 656 set_scriptable_plugin(scriptable_plugin); | 656 set_scriptable_plugin(scriptable_plugin); |
| 657 PLUGIN_PRINTF(("Plugin::Init (scriptable_handle=%p)\n", | 657 PLUGIN_PRINTF(("Plugin::Init (scriptable_handle=%p)\n", |
| 658 static_cast<void*>(scriptable_plugin_))); | 658 static_cast<void*>(scriptable_plugin_))); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 nexe_error_reported_(false), | 733 nexe_error_reported_(false), |
| 734 wrapper_factory_(NULL), | 734 wrapper_factory_(NULL), |
| 735 enable_dev_interfaces_(false), | 735 enable_dev_interfaces_(false), |
| 736 is_installed_(false), | 736 is_installed_(false), |
| 737 init_time_(0), | 737 init_time_(0), |
| 738 ready_time_(0), | 738 ready_time_(0), |
| 739 nexe_size_(0), | 739 nexe_size_(0), |
| 740 time_of_last_progress_event_(0), | 740 time_of_last_progress_event_(0), |
| 741 nacl_interface_(NULL) { | 741 nacl_interface_(NULL) { |
| 742 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" | 742 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" |
| 743 NACL_PRId32")\n", static_cast<void*>(this), pp_instance)); | 743 NACL_PRId32 ")\n", static_cast<void*>(this), pp_instance)); |
| 744 callback_factory_.Initialize(this); | 744 callback_factory_.Initialize(this); |
| 745 nexe_downloader_.Initialize(this); | 745 nexe_downloader_.Initialize(this); |
| 746 nacl_interface_ = GetNaClInterface(); | 746 nacl_interface_ = GetNaClInterface(); |
| 747 CHECK(nacl_interface_ != NULL); | 747 CHECK(nacl_interface_ != NULL); |
| 748 } | 748 } |
| 749 | 749 |
| 750 | 750 |
| 751 Plugin::~Plugin() { | 751 Plugin::~Plugin() { |
| 752 int64_t shutdown_start = NaClGetTimeOfDayMicroseconds(); | 752 int64_t shutdown_start = NaClGetTimeOfDayMicroseconds(); |
| 753 | 753 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 | 837 |
| 838 void Plugin::HistogramStartupTimeMedium(const std::string& name, float dt) { | 838 void Plugin::HistogramStartupTimeMedium(const std::string& name, float dt) { |
| 839 if (nexe_size_ > 0) { | 839 if (nexe_size_ > 0) { |
| 840 float size_in_MB = static_cast<float>(nexe_size_) / (1024.f * 1024.f); | 840 float size_in_MB = static_cast<float>(nexe_size_) / (1024.f * 1024.f); |
| 841 HistogramTimeMedium(name, static_cast<int64_t>(dt)); | 841 HistogramTimeMedium(name, static_cast<int64_t>(dt)); |
| 842 HistogramTimeMedium(name + "PerMB", static_cast<int64_t>(dt / size_in_MB)); | 842 HistogramTimeMedium(name + "PerMB", static_cast<int64_t>(dt / size_in_MB)); |
| 843 } | 843 } |
| 844 } | 844 } |
| 845 | 845 |
| 846 void Plugin::NexeFileDidOpen(int32_t pp_error) { | 846 void Plugin::NexeFileDidOpen(int32_t pp_error) { |
| 847 PLUGIN_PRINTF(("Plugin::NexeFileDidOpen (pp_error=%"NACL_PRId32")\n", | 847 PLUGIN_PRINTF(("Plugin::NexeFileDidOpen (pp_error=%" NACL_PRId32 ")\n", |
| 848 pp_error)); | 848 pp_error)); |
| 849 struct NaClFileInfo info = nexe_downloader_.GetFileInfo(); | 849 struct NaClFileInfo info = nexe_downloader_.GetFileInfo(); |
| 850 PLUGIN_PRINTF(("Plugin::NexeFileDidOpen (file_desc=%"NACL_PRId32")\n", | 850 PLUGIN_PRINTF(("Plugin::NexeFileDidOpen (file_desc=%" NACL_PRId32 ")\n", |
| 851 info.desc)); | 851 info.desc)); |
| 852 HistogramHTTPStatusCode( | 852 HistogramHTTPStatusCode( |
| 853 is_installed_ ? | 853 is_installed_ ? |
| 854 "NaCl.HttpStatusCodeClass.Nexe.InstalledApp" : | 854 "NaCl.HttpStatusCodeClass.Nexe.InstalledApp" : |
| 855 "NaCl.HttpStatusCodeClass.Nexe.NotInstalledApp", | 855 "NaCl.HttpStatusCodeClass.Nexe.NotInstalledApp", |
| 856 nexe_downloader_.status_code()); | 856 nexe_downloader_.status_code()); |
| 857 ErrorInfo error_info; | 857 ErrorInfo error_info; |
| 858 if (pp_error != PP_OK || info.desc == NACL_NO_FILE_DESC) { | 858 if (pp_error != PP_OK || info.desc == NACL_NO_FILE_DESC) { |
| 859 if (pp_error == PP_ERROR_ABORTED) { | 859 if (pp_error == PP_ERROR_ABORTED) { |
| 860 ReportLoadAbort(); | 860 ReportLoadAbort(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 PLUGIN_PRINTF(("LogLineToConsole: %s\n", | 946 PLUGIN_PRINTF(("LogLineToConsole: %s\n", |
| 947 one_line.c_str())); | 947 one_line.c_str())); |
| 948 plugin->AddToConsole(one_line); | 948 plugin->AddToConsole(one_line); |
| 949 } | 949 } |
| 950 | 950 |
| 951 void Plugin::CopyCrashLogToJsConsole() { | 951 void Plugin::CopyCrashLogToJsConsole() { |
| 952 nacl::string fatal_msg(main_service_runtime()->GetCrashLogOutput()); | 952 nacl::string fatal_msg(main_service_runtime()->GetCrashLogOutput()); |
| 953 size_t ix_start = 0; | 953 size_t ix_start = 0; |
| 954 size_t ix_end; | 954 size_t ix_end; |
| 955 | 955 |
| 956 PLUGIN_PRINTF(("Plugin::CopyCrashLogToJsConsole: got %"NACL_PRIuS" bytes\n", | 956 PLUGIN_PRINTF(("Plugin::CopyCrashLogToJsConsole: got %" NACL_PRIuS " bytes\n", |
| 957 fatal_msg.size())); | 957 fatal_msg.size())); |
| 958 while (nacl::string::npos != (ix_end = fatal_msg.find('\n', ix_start))) { | 958 while (nacl::string::npos != (ix_end = fatal_msg.find('\n', ix_start))) { |
| 959 LogLineToConsole(this, fatal_msg.substr(ix_start, ix_end - ix_start)); | 959 LogLineToConsole(this, fatal_msg.substr(ix_start, ix_end - ix_start)); |
| 960 ix_start = ix_end + 1; | 960 ix_start = ix_end + 1; |
| 961 } | 961 } |
| 962 if (ix_start != fatal_msg.size()) { | 962 if (ix_start != fatal_msg.size()) { |
| 963 LogLineToConsole(this, fatal_msg.substr(ix_start)); | 963 LogLineToConsole(this, fatal_msg.substr(ix_start)); |
| 964 } | 964 } |
| 965 } | 965 } |
| 966 | 966 |
| 967 void Plugin::NexeDidCrash(int32_t pp_error) { | 967 void Plugin::NexeDidCrash(int32_t pp_error) { |
| 968 PLUGIN_PRINTF(("Plugin::NexeDidCrash (pp_error=%"NACL_PRId32")\n", | 968 PLUGIN_PRINTF(("Plugin::NexeDidCrash (pp_error=%" NACL_PRId32 ")\n", |
| 969 pp_error)); | 969 pp_error)); |
| 970 if (pp_error != PP_OK) { | 970 if (pp_error != PP_OK) { |
| 971 PLUGIN_PRINTF(("Plugin::NexeDidCrash: CallOnMainThread callback with" | 971 PLUGIN_PRINTF(("Plugin::NexeDidCrash: CallOnMainThread callback with" |
| 972 " non-PP_OK arg -- SHOULD NOT HAPPEN\n")); | 972 " non-PP_OK arg -- SHOULD NOT HAPPEN\n")); |
| 973 } | 973 } |
| 974 PLUGIN_PRINTF(("Plugin::NexeDidCrash: crash event!\n")); | 974 PLUGIN_PRINTF(("Plugin::NexeDidCrash: crash event!\n")); |
| 975 int exit_status = main_subprocess_.service_runtime()->exit_status(); | 975 int exit_status = main_subprocess_.service_runtime()->exit_status(); |
| 976 if (-1 != exit_status) { | 976 if (-1 != exit_status) { |
| 977 // The NaCl module voluntarily exited. However, this is still a | 977 // The NaCl module voluntarily exited. However, this is still a |
| 978 // crash from the point of view of Pepper, since PPAPI plugins are | 978 // crash from the point of view of Pepper, since PPAPI plugins are |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1005 // In all cases, try to grab the crash log. The first error | 1005 // In all cases, try to grab the crash log. The first error |
| 1006 // reported may have come from the start_module RPC reply indicating | 1006 // reported may have come from the start_module RPC reply indicating |
| 1007 // a validation error or something similar, which wouldn't grab the | 1007 // a validation error or something similar, which wouldn't grab the |
| 1008 // crash log. In the event that this is called twice, the second | 1008 // crash log. In the event that this is called twice, the second |
| 1009 // invocation will just be a no-op, since all the crash log will | 1009 // invocation will just be a no-op, since all the crash log will |
| 1010 // have been received and we'll just get an EOF indication. | 1010 // have been received and we'll just get an EOF indication. |
| 1011 CopyCrashLogToJsConsole(); | 1011 CopyCrashLogToJsConsole(); |
| 1012 } | 1012 } |
| 1013 | 1013 |
| 1014 void Plugin::BitcodeDidTranslate(int32_t pp_error) { | 1014 void Plugin::BitcodeDidTranslate(int32_t pp_error) { |
| 1015 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%"NACL_PRId32")\n", | 1015 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%" NACL_PRId32 ")\n", |
| 1016 pp_error)); | 1016 pp_error)); |
| 1017 if (pp_error != PP_OK) { | 1017 if (pp_error != PP_OK) { |
| 1018 // Error should have been reported by pnacl. Just return. | 1018 // Error should have been reported by pnacl. Just return. |
| 1019 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate error in Pnacl\n")); | 1019 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate error in Pnacl\n")); |
| 1020 return; | 1020 return; |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 // Inform JavaScript that we successfully translated the bitcode to a nexe. | 1023 // Inform JavaScript that we successfully translated the bitcode to a nexe. |
| 1024 nacl::scoped_ptr<nacl::DescWrapper> | 1024 nacl::scoped_ptr<nacl::DescWrapper> |
| 1025 wrapper(pnacl_coordinator_.get()->ReleaseTranslatedFD()); | 1025 wrapper(pnacl_coordinator_.get()->ReleaseTranslatedFD()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 // else ReportLoadError() and ReportAbortError() will be used by loading code | 1073 // else ReportLoadError() and ReportAbortError() will be used by loading code |
| 1074 // to provide error handling. | 1074 // to provide error handling. |
| 1075 // | 1075 // |
| 1076 // NOTE: not all crashes during load will make it here. | 1076 // NOTE: not all crashes during load will make it here. |
| 1077 // Those in BrowserPpp::InitializeModule and creation of PPP interfaces | 1077 // Those in BrowserPpp::InitializeModule and creation of PPP interfaces |
| 1078 // will just get reported back as PP_ERROR_FAILED. | 1078 // will just get reported back as PP_ERROR_FAILED. |
| 1079 } | 1079 } |
| 1080 | 1080 |
| 1081 void Plugin::NaClManifestBufferReady(int32_t pp_error) { | 1081 void Plugin::NaClManifestBufferReady(int32_t pp_error) { |
| 1082 PLUGIN_PRINTF(("Plugin::NaClManifestBufferReady (pp_error=%" | 1082 PLUGIN_PRINTF(("Plugin::NaClManifestBufferReady (pp_error=%" |
| 1083 NACL_PRId32")\n", pp_error)); | 1083 NACL_PRId32 ")\n", pp_error)); |
| 1084 ErrorInfo error_info; | 1084 ErrorInfo error_info; |
| 1085 set_manifest_url(nexe_downloader_.url()); | 1085 set_manifest_url(nexe_downloader_.url()); |
| 1086 if (pp_error != PP_OK) { | 1086 if (pp_error != PP_OK) { |
| 1087 if (pp_error == PP_ERROR_ABORTED) { | 1087 if (pp_error == PP_ERROR_ABORTED) { |
| 1088 ReportLoadAbort(); | 1088 ReportLoadAbort(); |
| 1089 } else { | 1089 } else { |
| 1090 error_info.SetReport(ERROR_MANIFEST_LOAD_URL, | 1090 error_info.SetReport(ERROR_MANIFEST_LOAD_URL, |
| 1091 "could not load manifest url."); | 1091 "could not load manifest url."); |
| 1092 ReportLoadError(error_info); | 1092 ReportLoadError(error_info); |
| 1093 } | 1093 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1110 return; | 1110 return; |
| 1111 } | 1111 } |
| 1112 std::copy(buffer.begin(), buffer.begin() + buffer_size, &json_buffer[0]); | 1112 std::copy(buffer.begin(), buffer.begin() + buffer_size, &json_buffer[0]); |
| 1113 json_buffer[buffer_size] = '\0'; | 1113 json_buffer[buffer_size] = '\0'; |
| 1114 | 1114 |
| 1115 ProcessNaClManifest(json_buffer.get()); | 1115 ProcessNaClManifest(json_buffer.get()); |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 void Plugin::NaClManifestFileDidOpen(int32_t pp_error) { | 1118 void Plugin::NaClManifestFileDidOpen(int32_t pp_error) { |
| 1119 PLUGIN_PRINTF(("Plugin::NaClManifestFileDidOpen (pp_error=%" | 1119 PLUGIN_PRINTF(("Plugin::NaClManifestFileDidOpen (pp_error=%" |
| 1120 NACL_PRId32")\n", pp_error)); | 1120 NACL_PRId32 ")\n", pp_error)); |
| 1121 HistogramTimeSmall("NaCl.Perf.StartupTime.ManifestDownload", | 1121 HistogramTimeSmall("NaCl.Perf.StartupTime.ManifestDownload", |
| 1122 nexe_downloader_.TimeSinceOpenMilliseconds()); | 1122 nexe_downloader_.TimeSinceOpenMilliseconds()); |
| 1123 HistogramHTTPStatusCode( | 1123 HistogramHTTPStatusCode( |
| 1124 is_installed_ ? | 1124 is_installed_ ? |
| 1125 "NaCl.HttpStatusCodeClass.Manifest.InstalledApp" : | 1125 "NaCl.HttpStatusCodeClass.Manifest.InstalledApp" : |
| 1126 "NaCl.HttpStatusCodeClass.Manifest.NotInstalledApp", | 1126 "NaCl.HttpStatusCodeClass.Manifest.NotInstalledApp", |
| 1127 nexe_downloader_.status_code()); | 1127 nexe_downloader_.status_code()); |
| 1128 ErrorInfo error_info; | 1128 ErrorInfo error_info; |
| 1129 // The manifest file was successfully opened. Set the src property on the | 1129 // The manifest file was successfully opened. Set the src property on the |
| 1130 // plugin now, so that the full url is available to error handlers. | 1130 // plugin now, so that the full url is available to error handlers. |
| 1131 set_manifest_url(nexe_downloader_.url()); | 1131 set_manifest_url(nexe_downloader_.url()); |
| 1132 struct NaClFileInfo info = nexe_downloader_.GetFileInfo(); | 1132 struct NaClFileInfo info = nexe_downloader_.GetFileInfo(); |
| 1133 PLUGIN_PRINTF(("Plugin::NaClManifestFileDidOpen (file_desc=%" | 1133 PLUGIN_PRINTF(("Plugin::NaClManifestFileDidOpen (file_desc=%" |
| 1134 NACL_PRId32")\n", info.desc)); | 1134 NACL_PRId32 ")\n", info.desc)); |
| 1135 if (pp_error != PP_OK || info.desc == NACL_NO_FILE_DESC) { | 1135 if (pp_error != PP_OK || info.desc == NACL_NO_FILE_DESC) { |
| 1136 if (pp_error == PP_ERROR_ABORTED) { | 1136 if (pp_error == PP_ERROR_ABORTED) { |
| 1137 ReportLoadAbort(); | 1137 ReportLoadAbort(); |
| 1138 } else if (pp_error == PP_ERROR_NOACCESS) { | 1138 } else if (pp_error == PP_ERROR_NOACCESS) { |
| 1139 error_info.SetReport(ERROR_MANIFEST_NOACCESS_URL, | 1139 error_info.SetReport(ERROR_MANIFEST_NOACCESS_URL, |
| 1140 "access to manifest url was denied."); | 1140 "access to manifest url was denied."); |
| 1141 ReportLoadError(error_info); | 1141 ReportLoadError(error_info); |
| 1142 } else { | 1142 } else { |
| 1143 error_info.SetReport(ERROR_MANIFEST_LOAD_URL, | 1143 error_info.SetReport(ERROR_MANIFEST_LOAD_URL, |
| 1144 "could not load manifest url."); | 1144 "could not load manifest url."); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 if (!json_manifest->Init(manifest_json, error_info)) { | 1306 if (!json_manifest->Init(manifest_json, error_info)) { |
| 1307 return false; | 1307 return false; |
| 1308 } | 1308 } |
| 1309 manifest_.reset(json_manifest.release()); | 1309 manifest_.reset(json_manifest.release()); |
| 1310 return true; | 1310 return true; |
| 1311 } | 1311 } |
| 1312 | 1312 |
| 1313 void Plugin::UrlDidOpenForStreamAsFile(int32_t pp_error, | 1313 void Plugin::UrlDidOpenForStreamAsFile(int32_t pp_error, |
| 1314 FileDownloader*& url_downloader, | 1314 FileDownloader*& url_downloader, |
| 1315 PP_CompletionCallback callback) { | 1315 PP_CompletionCallback callback) { |
| 1316 PLUGIN_PRINTF(("Plugin::UrlDidOpen (pp_error=%"NACL_PRId32 | 1316 PLUGIN_PRINTF(("Plugin::UrlDidOpen (pp_error=%" NACL_PRId32 |
| 1317 ", url_downloader=%p)\n", pp_error, | 1317 ", url_downloader=%p)\n", pp_error, |
| 1318 static_cast<void*>(url_downloader))); | 1318 static_cast<void*>(url_downloader))); |
| 1319 url_downloaders_.erase(url_downloader); | 1319 url_downloaders_.erase(url_downloader); |
| 1320 nacl::scoped_ptr<FileDownloader> scoped_url_downloader(url_downloader); | 1320 nacl::scoped_ptr<FileDownloader> scoped_url_downloader(url_downloader); |
| 1321 struct NaClFileInfo info = scoped_url_downloader->GetFileInfo(); | 1321 struct NaClFileInfo info = scoped_url_downloader->GetFileInfo(); |
| 1322 | 1322 |
| 1323 if (pp_error != PP_OK) { | 1323 if (pp_error != PP_OK) { |
| 1324 PP_RunCompletionCallback(&callback, pp_error); | 1324 PP_RunCompletionCallback(&callback, pp_error); |
| 1325 } else if (info.desc > NACL_NO_FILE_DESC) { | 1325 } else if (info.desc > NACL_NO_FILE_DESC) { |
| 1326 url_file_info_map_[url_downloader->url_to_open()] = info; | 1326 url_file_info_map_[url_downloader->url_to_open()] = info; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 Plugin::kUnknownBytes); | 1506 Plugin::kUnknownBytes); |
| 1507 } | 1507 } |
| 1508 | 1508 |
| 1509 void Plugin::EnqueueProgressEvent(const char* event_type, | 1509 void Plugin::EnqueueProgressEvent(const char* event_type, |
| 1510 const nacl::string& url, | 1510 const nacl::string& url, |
| 1511 LengthComputable length_computable, | 1511 LengthComputable length_computable, |
| 1512 uint64_t loaded_bytes, | 1512 uint64_t loaded_bytes, |
| 1513 uint64_t total_bytes) { | 1513 uint64_t total_bytes) { |
| 1514 PLUGIN_PRINTF(("Plugin::EnqueueProgressEvent (" | 1514 PLUGIN_PRINTF(("Plugin::EnqueueProgressEvent (" |
| 1515 "event_type='%s', url='%s', length_computable=%d, " | 1515 "event_type='%s', url='%s', length_computable=%d, " |
| 1516 "loaded=%"NACL_PRIu64", total=%"NACL_PRIu64")\n", | 1516 "loaded=%" NACL_PRIu64 ", total=%" NACL_PRIu64 ")\n", |
| 1517 event_type, | 1517 event_type, |
| 1518 url.c_str(), | 1518 url.c_str(), |
| 1519 static_cast<int>(length_computable), | 1519 static_cast<int>(length_computable), |
| 1520 loaded_bytes, | 1520 loaded_bytes, |
| 1521 total_bytes)); | 1521 total_bytes)); |
| 1522 | 1522 |
| 1523 progress_events_.push(new ProgressEvent(event_type, | 1523 progress_events_.push(new ProgressEvent(event_type, |
| 1524 url, | 1524 url, |
| 1525 length_computable, | 1525 length_computable, |
| 1526 loaded_bytes, | 1526 loaded_bytes, |
| 1527 total_bytes)); | 1527 total_bytes)); |
| 1528 // Note that using callback_factory_ in this way is not thread safe. | 1528 // Note that using callback_factory_ in this way is not thread safe. |
| 1529 // If/when EnqueueProgressEvent is callable from another thread, this | 1529 // If/when EnqueueProgressEvent is callable from another thread, this |
| 1530 // will need to change. | 1530 // will need to change. |
| 1531 pp::CompletionCallback callback = | 1531 pp::CompletionCallback callback = |
| 1532 callback_factory_.NewCallback(&Plugin::DispatchProgressEvent); | 1532 callback_factory_.NewCallback(&Plugin::DispatchProgressEvent); |
| 1533 pp::Core* core = pp::Module::Get()->core(); | 1533 pp::Core* core = pp::Module::Get()->core(); |
| 1534 core->CallOnMainThread(0, callback, 0); | 1534 core->CallOnMainThread(0, callback, 0); |
| 1535 } | 1535 } |
| 1536 | 1536 |
| 1537 void Plugin::ReportSelLdrLoadStatus(int status) { | 1537 void Plugin::ReportSelLdrLoadStatus(int status) { |
| 1538 HistogramEnumerateSelLdrLoadStatus(static_cast<NaClErrorCode>(status), | 1538 HistogramEnumerateSelLdrLoadStatus(static_cast<NaClErrorCode>(status), |
| 1539 is_installed_); | 1539 is_installed_); |
| 1540 } | 1540 } |
| 1541 | 1541 |
| 1542 void Plugin::DispatchProgressEvent(int32_t result) { | 1542 void Plugin::DispatchProgressEvent(int32_t result) { |
| 1543 PLUGIN_PRINTF(("Plugin::DispatchProgressEvent (result=%" | 1543 PLUGIN_PRINTF(("Plugin::DispatchProgressEvent (result=%" |
| 1544 NACL_PRId32")\n", result)); | 1544 NACL_PRId32 ")\n", result)); |
| 1545 if (result < 0) { | 1545 if (result < 0) { |
| 1546 return; | 1546 return; |
| 1547 } | 1547 } |
| 1548 if (progress_events_.empty()) { | 1548 if (progress_events_.empty()) { |
| 1549 PLUGIN_PRINTF(("Plugin::DispatchProgressEvent: no pending events\n")); | 1549 PLUGIN_PRINTF(("Plugin::DispatchProgressEvent: no pending events\n")); |
| 1550 return; | 1550 return; |
| 1551 } | 1551 } |
| 1552 nacl::scoped_ptr<ProgressEvent> event(progress_events_.front()); | 1552 nacl::scoped_ptr<ProgressEvent> event(progress_events_.front()); |
| 1553 progress_events_.pop(); | 1553 progress_events_.pop(); |
| 1554 PLUGIN_PRINTF(("Plugin::DispatchProgressEvent (" | 1554 PLUGIN_PRINTF(("Plugin::DispatchProgressEvent (" |
| 1555 "event_type='%s', url='%s', length_computable=%d, " | 1555 "event_type='%s', url='%s', length_computable=%d, " |
| 1556 "loaded=%"NACL_PRIu64", total=%"NACL_PRIu64")\n", | 1556 "loaded=%" NACL_PRIu64 ", total=%" NACL_PRIu64 ")\n", |
| 1557 event->event_type(), | 1557 event->event_type(), |
| 1558 event->url(), | 1558 event->url(), |
| 1559 static_cast<int>(event->length_computable()), | 1559 static_cast<int>(event->length_computable()), |
| 1560 event->loaded_bytes(), | 1560 event->loaded_bytes(), |
| 1561 event->total_bytes())); | 1561 event->total_bytes())); |
| 1562 | 1562 |
| 1563 static const char* kEventClosureJS = | 1563 static const char* kEventClosureJS = |
| 1564 "(function(target, type, url," | 1564 "(function(target, type, url," |
| 1565 " lengthComputable, loadedBytes, totalBytes) {" | 1565 " lengthComputable, loadedBytes, totalBytes) {" |
| 1566 " var progress_event = new ProgressEvent(type, {" | 1566 " var progress_event = new ProgressEvent(type, {" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 static_cast<uint32_t>(text.size())); | 1682 static_cast<uint32_t>(text.size())); |
| 1683 const PPB_Console* console_interface = | 1683 const PPB_Console* console_interface = |
| 1684 static_cast<const PPB_Console*>( | 1684 static_cast<const PPB_Console*>( |
| 1685 module->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); | 1685 module->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); |
| 1686 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); | 1686 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); |
| 1687 var_interface->Release(prefix); | 1687 var_interface->Release(prefix); |
| 1688 var_interface->Release(str); | 1688 var_interface->Release(str); |
| 1689 } | 1689 } |
| 1690 | 1690 |
| 1691 } // namespace plugin | 1691 } // namespace plugin |
| OLD | NEW |