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 26 matching lines...) Expand all Loading... |
37 #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" | 37 #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" |
38 #include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" | 38 #include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" |
39 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" | 39 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" |
40 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" | 40 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" |
41 #include "ppapi/native_client/src/trusted/plugin/utility.h" | 41 #include "ppapi/native_client/src/trusted/plugin/utility.h" |
42 | 42 |
43 namespace plugin { | 43 namespace plugin { |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 // The pseudo-architecture used to indicate portable native client. | |
48 const char* const kPortableArch = "portable"; | |
49 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file. | 47 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file. |
50 // Note that the resulting string object has to have at least one byte extra | 48 // Note that the resulting string object has to have at least one byte extra |
51 // for the null termination character. | 49 // for the null termination character. |
52 const size_t kNaClManifestMaxFileBytes = 1024 * 1024; | 50 const size_t kNaClManifestMaxFileBytes = 1024 * 1024; |
53 | 51 |
54 // Up to 20 seconds | 52 // Up to 20 seconds |
55 const int64_t kTimeSmallMin = 1; // in ms | 53 const int64_t kTimeSmallMin = 1; // in ms |
56 const int64_t kTimeSmallMax = 20000; // in ms | 54 const int64_t kTimeSmallMax = 20000; // in ms |
57 const uint32_t kTimeSmallBuckets = 100; | 55 const uint32_t kTimeSmallBuckets = 100; |
58 | 56 |
(...skipping 28 matching lines...) Expand all Loading... |
87 | 85 |
88 void Plugin::HistogramSizeKB(const std::string& name, | 86 void Plugin::HistogramSizeKB(const std::string& name, |
89 int32_t sample) { | 87 int32_t sample) { |
90 if (sample < 0) return; | 88 if (sample < 0) return; |
91 uma_interface_.HistogramCustomCounts(name, | 89 uma_interface_.HistogramCustomCounts(name, |
92 sample, | 90 sample, |
93 kSizeKBMin, kSizeKBMax, | 91 kSizeKBMin, kSizeKBMax, |
94 kSizeKBBuckets); | 92 kSizeKBBuckets); |
95 } | 93 } |
96 | 94 |
97 void Plugin::HistogramEnumerate(const std::string& name, | 95 void Plugin::HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code) { |
98 int sample, | 96 if (error_code < 0 || error_code > NACL_ERROR_CODE_MAX) |
99 int maximum, | 97 error_code = LOAD_STATUS_UNKNOWN; |
100 int out_of_range_replacement) { | |
101 if (sample < 0 || sample >= maximum) { | |
102 if (out_of_range_replacement < 0) | |
103 // No replacement for bad input, abort. | |
104 return; | |
105 else | |
106 // Use a specific value to signal a bad input. | |
107 sample = out_of_range_replacement; | |
108 } | |
109 uma_interface_.HistogramEnumeration(name, sample, maximum); | |
110 } | |
111 | 98 |
112 void Plugin::HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code) { | 99 uma_interface_.HistogramEnumeration("NaCl.LoadStatus.SelLdr", |
113 HistogramEnumerate("NaCl.LoadStatus.SelLdr", error_code, | 100 error_code, |
114 NACL_ERROR_CODE_MAX, LOAD_STATUS_UNKNOWN); | 101 NACL_ERROR_CODE_MAX); |
115 | 102 |
116 // Gather data to see if being installed changes load outcomes. | 103 // Gather data to see if being installed changes load outcomes. |
117 const char* name = nacl_interface_->GetIsInstalled(pp_instance()) ? | 104 const char* name = nacl_interface_->GetIsInstalled(pp_instance()) ? |
118 "NaCl.LoadStatus.SelLdr.InstalledApp" : | 105 "NaCl.LoadStatus.SelLdr.InstalledApp" : |
119 "NaCl.LoadStatus.SelLdr.NotInstalledApp"; | 106 "NaCl.LoadStatus.SelLdr.NotInstalledApp"; |
120 HistogramEnumerate(name, error_code, NACL_ERROR_CODE_MAX, | 107 uma_interface_.HistogramEnumeration(name, error_code, NACL_ERROR_CODE_MAX); |
121 LOAD_STATUS_UNKNOWN); | |
122 } | |
123 | |
124 void Plugin::HistogramHTTPStatusCode(const std::string& name, int status) { | |
125 // Log the status codes in rough buckets - 1XX, 2XX, etc. | |
126 int sample = status / 100; | |
127 // HTTP status codes only go up to 5XX, using "6" to indicate an internal | |
128 // error. | |
129 // Note: installed files may have "0" for a status code. | |
130 if (status < 0 || status >= 600) | |
131 sample = 6; | |
132 HistogramEnumerate(name, sample, 7, 6); | |
133 } | 108 } |
134 | 109 |
135 bool Plugin::LoadNaClModuleFromBackgroundThread( | 110 bool Plugin::LoadNaClModuleFromBackgroundThread( |
136 nacl::DescWrapper* wrapper, | 111 nacl::DescWrapper* wrapper, |
137 NaClSubprocess* subprocess, | 112 NaClSubprocess* subprocess, |
138 int32_t manifest_id, | 113 int32_t manifest_id, |
139 const SelLdrStartParams& params) { | 114 const SelLdrStartParams& params) { |
140 CHECK(!pp::Module::Get()->core()->IsMainThread()); | 115 CHECK(!pp::Module::Get()->core()->IsMainThread()); |
141 ServiceRuntime* service_runtime = | 116 ServiceRuntime* service_runtime = |
142 new ServiceRuntime(this, manifest_id, false, uses_nonsfi_mode_, | 117 new ServiceRuntime(this, manifest_id, false, uses_nonsfi_mode_, |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 } | 490 } |
516 | 491 |
517 void Plugin::NexeDidCrash(int32_t pp_error) { | 492 void Plugin::NexeDidCrash(int32_t pp_error) { |
518 PLUGIN_PRINTF(("Plugin::NexeDidCrash (pp_error=%" NACL_PRId32 ")\n", | 493 PLUGIN_PRINTF(("Plugin::NexeDidCrash (pp_error=%" NACL_PRId32 ")\n", |
519 pp_error)); | 494 pp_error)); |
520 if (pp_error != PP_OK) { | 495 if (pp_error != PP_OK) { |
521 PLUGIN_PRINTF(("Plugin::NexeDidCrash: CallOnMainThread callback with" | 496 PLUGIN_PRINTF(("Plugin::NexeDidCrash: CallOnMainThread callback with" |
522 " non-PP_OK arg -- SHOULD NOT HAPPEN\n")); | 497 " non-PP_OK arg -- SHOULD NOT HAPPEN\n")); |
523 } | 498 } |
524 | 499 |
525 std::string crash_log = main_service_runtime()->GetCrashLogOutput(); | 500 std::string crash_log = |
| 501 main_subprocess_.service_runtime()->GetCrashLogOutput(); |
526 nacl_interface_->NexeDidCrash(pp_instance(), crash_log.c_str()); | 502 nacl_interface_->NexeDidCrash(pp_instance(), crash_log.c_str()); |
527 } | 503 } |
528 | 504 |
529 void Plugin::BitcodeDidTranslate(int32_t pp_error) { | 505 void Plugin::BitcodeDidTranslate(int32_t pp_error) { |
530 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%" NACL_PRId32 ")\n", | 506 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%" NACL_PRId32 ")\n", |
531 pp_error)); | 507 pp_error)); |
532 if (pp_error != PP_OK) { | 508 if (pp_error != PP_OK) { |
533 // Error should have been reported by pnacl. Just return. | 509 // Error should have been reported by pnacl. Just return. |
534 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate error in Pnacl\n")); | 510 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate error in Pnacl\n")); |
535 return; | 511 return; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 open_callback.pp_completion_callback()); | 631 open_callback.pp_completion_callback()); |
656 } | 632 } |
657 } | 633 } |
658 | 634 |
659 | 635 |
660 bool Plugin::SetManifestObject(const nacl::string& manifest_json) { | 636 bool Plugin::SetManifestObject(const nacl::string& manifest_json) { |
661 PLUGIN_PRINTF(("Plugin::SetManifestObject(): manifest_json='%s'.\n", | 637 PLUGIN_PRINTF(("Plugin::SetManifestObject(): manifest_json='%s'.\n", |
662 manifest_json.c_str())); | 638 manifest_json.c_str())); |
663 // Determine whether lookups should use portable (i.e., pnacl versions) | 639 // Determine whether lookups should use portable (i.e., pnacl versions) |
664 // rather than platform-specific files. | 640 // rather than platform-specific files. |
665 bool is_pnacl = nacl_interface_->IsPNaCl(pp_instance()); | |
666 pp::Var manifest_base_url = | 641 pp::Var manifest_base_url = |
667 pp::Var(pp::PASS_REF, nacl_interface_->GetManifestBaseURL(pp_instance())); | 642 pp::Var(pp::PASS_REF, nacl_interface_->GetManifestBaseURL(pp_instance())); |
668 std::string manifest_base_url_str = manifest_base_url.AsString(); | 643 std::string manifest_base_url_str = manifest_base_url.AsString(); |
669 const char* sandbox_isa = nacl_interface_->GetSandboxArch(); | |
670 | 644 |
671 int32_t manifest_id = nacl_interface_->CreateJsonManifest( | 645 int32_t manifest_id = nacl_interface_->CreateJsonManifest( |
672 pp_instance(), | 646 pp_instance(), |
673 manifest_base_url_str.c_str(), | 647 manifest_base_url_str.c_str(), |
674 is_pnacl ? kPortableArch : sandbox_isa, | |
675 manifest_json.c_str()); | 648 manifest_json.c_str()); |
676 if (manifest_id == -1) | 649 if (manifest_id == -1) |
677 return false; | 650 return false; |
678 manifest_id_ = manifest_id; | 651 manifest_id_ = manifest_id; |
679 return true; | 652 return true; |
680 } | 653 } |
681 | 654 |
682 void Plugin::UrlDidOpenForStreamAsFile( | 655 void Plugin::UrlDidOpenForStreamAsFile( |
683 int32_t pp_error, | 656 int32_t pp_error, |
684 FileDownloader* url_downloader, | 657 FileDownloader* url_downloader, |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 | 860 |
888 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, | 861 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, |
889 int exit_status) { | 862 int exit_status) { |
890 DCHECK(pp::Module::Get()->core()->IsMainThread()); | 863 DCHECK(pp::Module::Get()->core()->IsMainThread()); |
891 DCHECK(nacl_interface_); | 864 DCHECK(nacl_interface_); |
892 nacl_interface_->SetExitStatus(pp_instance(), exit_status); | 865 nacl_interface_->SetExitStatus(pp_instance(), exit_status); |
893 } | 866 } |
894 | 867 |
895 | 868 |
896 } // namespace plugin | 869 } // namespace plugin |
OLD | NEW |