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 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 // No need to close |file_desc|, that is handled by |nexe_downloader_|. | 1167 // No need to close |file_desc|, that is handled by |nexe_downloader_|. |
1168 json_buffer[total_bytes_read] = '\0'; // Force null termination. | 1168 json_buffer[total_bytes_read] = '\0'; // Force null termination. |
1169 | 1169 |
1170 ProcessNaClManifest(json_buffer.get()); | 1170 ProcessNaClManifest(json_buffer.get()); |
1171 } | 1171 } |
1172 | 1172 |
1173 void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) { | 1173 void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) { |
1174 HistogramSizeKB("NaCl.Perf.Size.Manifest", | 1174 HistogramSizeKB("NaCl.Perf.Size.Manifest", |
1175 static_cast<int32_t>(manifest_json.length() / 1024)); | 1175 static_cast<int32_t>(manifest_json.length() / 1024)); |
1176 nacl::string program_url; | 1176 nacl::string program_url; |
1177 nacl::string cache_identity; | 1177 PnaclOptions pnacl_options; |
1178 bool is_portable; | |
1179 ErrorInfo error_info; | 1178 ErrorInfo error_info; |
1180 if (!SetManifestObject(manifest_json, &error_info)) { | 1179 if (!SetManifestObject(manifest_json, &error_info)) { |
1181 ReportLoadError(error_info); | 1180 ReportLoadError(error_info); |
1182 return; | 1181 return; |
1183 } | 1182 } |
1184 | 1183 |
1185 if (manifest_->GetProgramURL(&program_url, &cache_identity, | 1184 if (manifest_->GetProgramURL(&program_url, &pnacl_options, &error_info)) { |
1186 &error_info, &is_portable)) { | |
1187 is_installed_ = GetUrlScheme(program_url) == SCHEME_CHROME_EXTENSION; | 1185 is_installed_ = GetUrlScheme(program_url) == SCHEME_CHROME_EXTENSION; |
1188 set_nacl_ready_state(LOADING); | 1186 set_nacl_ready_state(LOADING); |
1189 // Inform JavaScript that we found a nexe URL to load. | 1187 // Inform JavaScript that we found a nexe URL to load. |
1190 EnqueueProgressEvent(kProgressEventProgress); | 1188 EnqueueProgressEvent(kProgressEventProgress); |
1191 if (is_portable) { | 1189 if (pnacl_options.translate()) { |
1192 if (this->nacl_interface()->IsPnaclEnabled()) { | 1190 if (this->nacl_interface()->IsPnaclEnabled()) { |
1193 pp::CompletionCallback translate_callback = | 1191 pp::CompletionCallback translate_callback = |
1194 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); | 1192 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); |
1195 // Will always call the callback on success or failure. | 1193 // Will always call the callback on success or failure. |
1196 pnacl_coordinator_.reset( | 1194 pnacl_coordinator_.reset( |
1197 PnaclCoordinator::BitcodeToNative(this, | 1195 PnaclCoordinator::BitcodeToNative(this, |
1198 program_url, | 1196 program_url, |
1199 cache_identity, | 1197 pnacl_options, |
1200 translate_callback)); | 1198 translate_callback)); |
1201 return; | 1199 return; |
1202 } else { | 1200 } else { |
1203 error_info.SetReport(ERROR_PNACL_NOT_ENABLED, | 1201 error_info.SetReport(ERROR_PNACL_NOT_ENABLED, |
1204 "PNaCl has not been enabled (e.g., by setting " | 1202 "PNaCl has not been enabled (e.g., by setting " |
1205 "the --enable-pnacl flag)."); | 1203 "the --enable-pnacl flag)."); |
1206 } | 1204 } |
1207 } else { | 1205 } else { |
1208 pp::CompletionCallback open_callback = | 1206 pp::CompletionCallback open_callback = |
1209 callback_factory_.NewCallback(&Plugin::NexeFileDidOpen); | 1207 callback_factory_.NewCallback(&Plugin::NexeFileDidOpen); |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 static_cast<uint32_t>(text.size())); | 1624 static_cast<uint32_t>(text.size())); |
1627 const PPB_Console* console_interface = | 1625 const PPB_Console* console_interface = |
1628 static_cast<const PPB_Console*>( | 1626 static_cast<const PPB_Console*>( |
1629 module->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); | 1627 module->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); |
1630 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); | 1628 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); |
1631 var_interface->Release(prefix); | 1629 var_interface->Release(prefix); |
1632 var_interface->Release(str); | 1630 var_interface->Release(str); |
1633 } | 1631 } |
1634 | 1632 |
1635 } // namespace plugin | 1633 } // namespace plugin |
OLD | NEW |