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 #include "ppapi/native_client/src/trusted/plugin/plugin.h" | 5 #include "ppapi/native_client/src/trusted/plugin/plugin.h" |
6 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 return true; | 302 return true; |
303 } | 303 } |
304 | 304 |
305 void Plugin::NexeFileDidOpen(int32_t pp_error) { | 305 void Plugin::NexeFileDidOpen(int32_t pp_error) { |
306 if (pp_error != PP_OK) | 306 if (pp_error != PP_OK) |
307 return; | 307 return; |
308 LoadNaClModule( | 308 LoadNaClModule( |
309 nexe_file_info_, | 309 nexe_file_info_, |
310 uses_nonsfi_mode_, | 310 uses_nonsfi_mode_, |
311 PP_NATIVE_NACL_PROCESS_TYPE, | 311 PP_NATIVE_NACL_PROCESS_TYPE, |
312 callback_factory_.NewCallback(&Plugin::NexeFileDidOpenContinuation)); | 312 // No-op callback. |
313 } | 313 pp::CompletionCallback()); |
314 | |
315 void Plugin::NexeFileDidOpenContinuation(int32_t pp_error) { | |
316 UNREFERENCED_PARAMETER(pp_error); | |
317 NaClLog(4, "Entered NexeFileDidOpenContinuation\n"); | |
318 if (LoadNaClModuleContinuationIntern()) { | |
319 NaClLog(4, "NexeFileDidOpenContinuation: success;" | |
320 " setting histograms\n"); | |
321 int64_t nexe_size = nacl_interface_->GetNexeSize(pp_instance()); | |
322 nacl_interface_->ReportLoadSuccess( | |
323 pp_instance(), nexe_size, nexe_size); | |
324 } else { | |
325 NaClLog(4, "NexeFileDidOpenContinuation: failed."); | |
326 } | |
327 NaClLog(4, "Leaving NexeFileDidOpenContinuation\n"); | |
328 } | 314 } |
329 | 315 |
330 void Plugin::BitcodeDidTranslate(int32_t pp_error) { | 316 void Plugin::BitcodeDidTranslate(int32_t pp_error) { |
331 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%" NACL_PRId32 ")\n", | 317 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%" NACL_PRId32 ")\n", |
332 pp_error)); | 318 pp_error)); |
333 if (pp_error != PP_OK) { | 319 if (pp_error != PP_OK) { |
334 // Error should have been reported by pnacl. Just return. | 320 // Error should have been reported by pnacl. Just return. |
335 return; | 321 return; |
336 } | 322 } |
337 | 323 |
338 // Inform JavaScript that we successfully translated the bitcode to a nexe. | 324 // Inform JavaScript that we successfully translated the bitcode to a nexe. |
339 PP_FileHandle handle = pnacl_coordinator_->TakeTranslatedFileHandle(); | 325 PP_FileHandle handle = pnacl_coordinator_->TakeTranslatedFileHandle(); |
340 | 326 |
341 PP_NaClFileInfo info; | 327 PP_NaClFileInfo info; |
342 info.handle = handle; | 328 info.handle = handle; |
343 info.token_lo = 0; | 329 info.token_lo = 0; |
344 info.token_hi = 0; | 330 info.token_hi = 0; |
345 LoadNaClModule( | 331 LoadNaClModule( |
346 info, | 332 info, |
347 false, /* uses_nonsfi_mode */ | 333 false, /* uses_nonsfi_mode */ |
348 PP_PNACL_PROCESS_TYPE, | 334 PP_PNACL_PROCESS_TYPE, |
349 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslateContinuation)); | 335 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslateContinuation)); |
350 } | 336 } |
351 | 337 |
| 338 // This is the only code path that responds to the |
| 339 // "init_done"/StartupInitializationComplete() SRPC call, which now has an |
| 340 // effect for PNaCl only. |
| 341 // TODO(mseaborn): Switch to doing this ReportLoadSuccess() call via the |
| 342 // Chrome-IPC-based StartupInitializationComplete() handler in |
| 343 // ppb_nacl_private_impl.cc, to match the non-PNaCl cases. |
352 void Plugin::BitcodeDidTranslateContinuation(int32_t pp_error) { | 344 void Plugin::BitcodeDidTranslateContinuation(int32_t pp_error) { |
353 NaClLog(4, "Entered BitcodeDidTranslateContinuation\n"); | 345 NaClLog(4, "Entered BitcodeDidTranslateContinuation\n"); |
354 UNREFERENCED_PARAMETER(pp_error); | 346 UNREFERENCED_PARAMETER(pp_error); |
355 if (LoadNaClModuleContinuationIntern()) { | 347 if (LoadNaClModuleContinuationIntern()) { |
356 int64_t loaded; | 348 int64_t loaded; |
357 int64_t total; | 349 int64_t total; |
358 // TODO(teravest): Tighten this up so we can get rid of | 350 // TODO(teravest): Tighten this up so we can get rid of |
359 // GetCurrentProgress(). loaded should always equal total. | 351 // GetCurrentProgress(). loaded should always equal total. |
360 pnacl_coordinator_->GetCurrentProgress(&loaded, &total); | 352 pnacl_coordinator_->GetCurrentProgress(&loaded, &total); |
361 nacl_interface_->ReportLoadSuccess(pp_instance(), loaded, total); | 353 nacl_interface_->ReportLoadSuccess(pp_instance(), loaded, total); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 392 } |
401 } | 393 } |
402 | 394 |
403 void Plugin::ReportLoadError(const ErrorInfo& error_info) { | 395 void Plugin::ReportLoadError(const ErrorInfo& error_info) { |
404 nacl_interface_->ReportLoadError(pp_instance(), | 396 nacl_interface_->ReportLoadError(pp_instance(), |
405 error_info.error_code(), | 397 error_info.error_code(), |
406 error_info.message().c_str()); | 398 error_info.message().c_str()); |
407 } | 399 } |
408 | 400 |
409 } // namespace plugin | 401 } // namespace plugin |
OLD | NEW |