| 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 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 NexeFileDidOpen(PP_OK); | 1178 NexeFileDidOpen(PP_OK); |
| 1179 } else { | 1179 } else { |
| 1180 pp::CompletionCallback open_callback = | 1180 pp::CompletionCallback open_callback = |
| 1181 callback_factory_.NewCallback(&Plugin::NexeFileDidOpen); | 1181 callback_factory_.NewCallback(&Plugin::NexeFileDidOpen); |
| 1182 // Will always call the callback on success or failure. | 1182 // Will always call the callback on success or failure. |
| 1183 CHECK( | 1183 CHECK( |
| 1184 nexe_downloader_.Open(program_url, | 1184 nexe_downloader_.Open(program_url, |
| 1185 DOWNLOAD_TO_FILE, | 1185 DOWNLOAD_TO_FILE, |
| 1186 open_callback, | 1186 open_callback, |
| 1187 true, | 1187 true, |
| 1188 &UpdateDownloadProgress)); | 1188 &UpdateDownloadProgress, |
| 1189 true)); |
| 1189 } | 1190 } |
| 1190 return; | 1191 return; |
| 1191 } | 1192 } |
| 1192 } | 1193 } |
| 1193 // Failed to select the program and/or the translator. | 1194 // Failed to select the program and/or the translator. |
| 1194 ReportLoadError(error_info); | 1195 ReportLoadError(error_info); |
| 1195 } | 1196 } |
| 1196 | 1197 |
| 1197 void Plugin::RequestNaClManifest(const nacl::string& url) { | 1198 void Plugin::RequestNaClManifest(const nacl::string& url) { |
| 1198 PLUGIN_PRINTF(("Plugin::RequestNaClManifest (url='%s')\n", url.c_str())); | 1199 PLUGIN_PRINTF(("Plugin::RequestNaClManifest (url='%s')\n", url.c_str())); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1223 bool is_data_uri = GetUrlScheme(nmf_resolved_url.AsString()) == SCHEME_DATA; | 1224 bool is_data_uri = GetUrlScheme(nmf_resolved_url.AsString()) == SCHEME_DATA; |
| 1224 HistogramEnumerateManifestIsDataURI(static_cast<int>(is_data_uri)); | 1225 HistogramEnumerateManifestIsDataURI(static_cast<int>(is_data_uri)); |
| 1225 if (is_data_uri) { | 1226 if (is_data_uri) { |
| 1226 pp::CompletionCallback open_callback = | 1227 pp::CompletionCallback open_callback = |
| 1227 callback_factory_.NewCallback(&Plugin::NaClManifestBufferReady); | 1228 callback_factory_.NewCallback(&Plugin::NaClManifestBufferReady); |
| 1228 // Will always call the callback on success or failure. | 1229 // Will always call the callback on success or failure. |
| 1229 CHECK(nexe_downloader_.Open(nmf_resolved_url.AsString(), | 1230 CHECK(nexe_downloader_.Open(nmf_resolved_url.AsString(), |
| 1230 DOWNLOAD_TO_BUFFER, | 1231 DOWNLOAD_TO_BUFFER, |
| 1231 open_callback, | 1232 open_callback, |
| 1232 false, | 1233 false, |
| 1233 NULL)); | 1234 NULL, |
| 1235 true)); |
| 1234 } else { | 1236 } else { |
| 1235 pp::CompletionCallback open_callback = | 1237 pp::CompletionCallback open_callback = |
| 1236 callback_factory_.NewCallback(&Plugin::NaClManifestFileDidOpen); | 1238 callback_factory_.NewCallback(&Plugin::NaClManifestFileDidOpen); |
| 1237 // Will always call the callback on success or failure. | 1239 // Will always call the callback on success or failure. |
| 1238 CHECK(nexe_downloader_.Open(nmf_resolved_url.AsString(), | 1240 CHECK(nexe_downloader_.Open(nmf_resolved_url.AsString(), |
| 1239 DOWNLOAD_TO_FILE, | 1241 DOWNLOAD_TO_FILE, |
| 1240 open_callback, | 1242 open_callback, |
| 1241 false, | 1243 false, |
| 1242 NULL)); | 1244 NULL, |
| 1245 true)); |
| 1243 } | 1246 } |
| 1244 } | 1247 } |
| 1245 | 1248 |
| 1246 | 1249 |
| 1247 bool Plugin::SetManifestObject(const nacl::string& manifest_json, | 1250 bool Plugin::SetManifestObject(const nacl::string& manifest_json, |
| 1248 ErrorInfo* error_info) { | 1251 ErrorInfo* error_info) { |
| 1249 PLUGIN_PRINTF(("Plugin::SetManifestObject(): manifest_json='%s'.\n", | 1252 PLUGIN_PRINTF(("Plugin::SetManifestObject(): manifest_json='%s'.\n", |
| 1250 manifest_json.c_str())); | 1253 manifest_json.c_str())); |
| 1251 if (error_info == NULL) | 1254 if (error_info == NULL) |
| 1252 return false; | 1255 return false; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 return true; | 1327 return true; |
| 1325 } | 1328 } |
| 1326 | 1329 |
| 1327 pp::CompletionCallback open_callback = callback_factory_.NewCallback( | 1330 pp::CompletionCallback open_callback = callback_factory_.NewCallback( |
| 1328 &Plugin::UrlDidOpenForStreamAsFile, downloader, callback); | 1331 &Plugin::UrlDidOpenForStreamAsFile, downloader, callback); |
| 1329 // If true, will always call the callback on success or failure. | 1332 // If true, will always call the callback on success or failure. |
| 1330 return downloader->Open(url, | 1333 return downloader->Open(url, |
| 1331 DOWNLOAD_TO_FILE, | 1334 DOWNLOAD_TO_FILE, |
| 1332 open_callback, | 1335 open_callback, |
| 1333 true, | 1336 true, |
| 1334 &UpdateDownloadProgress); | 1337 &UpdateDownloadProgress, |
| 1338 true); |
| 1335 } | 1339 } |
| 1336 | 1340 |
| 1337 | 1341 |
| 1338 void Plugin::ReportLoadSuccess(LengthComputable length_computable, | 1342 void Plugin::ReportLoadSuccess(LengthComputable length_computable, |
| 1339 uint64_t loaded_bytes, | 1343 uint64_t loaded_bytes, |
| 1340 uint64_t total_bytes) { | 1344 uint64_t total_bytes) { |
| 1341 // Set the readyState attribute to indicate loaded. | 1345 // Set the readyState attribute to indicate loaded. |
| 1342 set_nacl_ready_state(DONE); | 1346 set_nacl_ready_state(DONE); |
| 1343 // Inform JavaScript that loading was successful and is complete. | 1347 // Inform JavaScript that loading was successful and is complete. |
| 1344 const nacl::string& url = nexe_downloader_.url_to_open(); | 1348 const nacl::string& url = nexe_downloader_.url_to_open(); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 static_cast<uint32_t>(text.size())); | 1641 static_cast<uint32_t>(text.size())); |
| 1638 const PPB_Console* console_interface = | 1642 const PPB_Console* console_interface = |
| 1639 static_cast<const PPB_Console*>( | 1643 static_cast<const PPB_Console*>( |
| 1640 module->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); | 1644 module->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); |
| 1641 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); | 1645 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); |
| 1642 var_interface->Release(prefix); | 1646 var_interface->Release(prefix); |
| 1643 var_interface->Release(str); | 1647 var_interface->Release(str); |
| 1644 } | 1648 } |
| 1645 | 1649 |
| 1646 } // namespace plugin | 1650 } // namespace plugin |
| OLD | NEW |