OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #define NACL_LOG_MODULE_NAME "Plugin_ServiceRuntime" | 7 #define NACL_LOG_MODULE_NAME "Plugin_ServiceRuntime" |
8 | 8 |
9 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" | 9 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" |
10 | 10 |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 392 |
393 // Hereafter, normal files. | 393 // Hereafter, normal files. |
394 | 394 |
395 // Because p is owned by the callback of this invocation, so it is necessary | 395 // Because p is owned by the callback of this invocation, so it is necessary |
396 // to create another instance. | 396 // to create another instance. |
397 OpenManifestEntryResource* open_cont = new OpenManifestEntryResource(*p); | 397 OpenManifestEntryResource* open_cont = new OpenManifestEntryResource(*p); |
398 open_cont->url = mapped_url; | 398 open_cont->url = mapped_url; |
399 // Callback is now delegated from p to open_cont. So, here we manually clear | 399 // Callback is now delegated from p to open_cont. So, here we manually clear |
400 // complete callback. | 400 // complete callback. |
401 p->callback = NULL; | 401 p->callback = NULL; |
| 402 |
402 pp::CompletionCallback stream_cc = WeakRefNewCallback( | 403 pp::CompletionCallback stream_cc = WeakRefNewCallback( |
403 anchor_, | 404 anchor_, |
404 this, | 405 this, |
405 &PluginReverseInterface::StreamAsFile_MainThreadContinuation, | 406 &PluginReverseInterface::StreamAsFile_MainThreadContinuation, |
406 open_cont); | 407 open_cont); |
407 | 408 |
408 if (!plugin_->StreamAsFile(mapped_url, p->file_info, stream_cc)) { | 409 plugin_->StreamAsFile(mapped_url, &open_cont->pp_file_info, stream_cc); |
409 NaClLog(4, | 410 // p is deleted automatically. |
410 "OpenManifestEntry_MainThreadContinuation: " | |
411 "StreamAsFile failed\n"); | |
412 // Here, StreamAsFile is failed and stream_cc is not called. | |
413 // However, open_cont will be released only by the invocation. | |
414 // So, we manually call it here with error. | |
415 stream_cc.Run(PP_ERROR_FAILED); | |
416 return; | |
417 } | |
418 | |
419 NaClLog(4, "OpenManifestEntry_MainThreadContinuation: StreamAsFile okay\n"); | |
420 // p is deleted automatically | |
421 } | 411 } |
422 | 412 |
423 void PluginReverseInterface::StreamAsFile_MainThreadContinuation( | 413 void PluginReverseInterface::StreamAsFile_MainThreadContinuation( |
424 OpenManifestEntryResource* p, | 414 OpenManifestEntryResource* p, |
425 int32_t result) { | 415 int32_t result) { |
426 NaClLog(4, | 416 NaClLog(4, "Entered StreamAsFile_MainThreadContinuation\n"); |
427 "Entered StreamAsFile_MainThreadContinuation\n"); | |
428 | |
429 { | 417 { |
430 nacl::MutexLocker take(&mu_); | 418 nacl::MutexLocker take(&mu_); |
431 if (result == PP_OK) { | 419 if (result == PP_OK) { |
| 420 // We downloaded this file to temporary storage for this plugin; it's |
| 421 // reasonable to provide a file descriptor with write access. |
| 422 p->file_info->desc = ConvertFileDescriptor(p->pp_file_info.handle, false); |
| 423 p->file_info->file_token.lo = p->pp_file_info.token_lo; |
| 424 p->file_info->file_token.hi = p->pp_file_info.token_hi; |
432 NaClLog(4, | 425 NaClLog(4, |
433 "StreamAsFile_MainThreadContinuation: PP_OK, desc %d\n", | 426 "StreamAsFile_MainThreadContinuation: PP_OK, desc %d\n", |
434 p->file_info->desc); | 427 p->file_info->desc); |
435 } else { | 428 } else { |
436 NaClLog( | 429 NaClLog( |
437 4, | 430 4, |
438 "StreamAsFile_MainThreadContinuation: !PP_OK, setting desc -1\n"); | 431 "StreamAsFile_MainThreadContinuation: !PP_OK, setting desc -1\n"); |
439 p->file_info->desc = -1; | 432 p->file_info->desc = -1; |
440 } | 433 } |
441 *p->op_complete_ptr = true; | 434 *p->op_complete_ptr = true; |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 | 794 |
802 nacl::string ServiceRuntime::GetCrashLogOutput() { | 795 nacl::string ServiceRuntime::GetCrashLogOutput() { |
803 if (NULL != subprocess_.get()) { | 796 if (NULL != subprocess_.get()) { |
804 return subprocess_->GetCrashLogOutput(); | 797 return subprocess_->GetCrashLogOutput(); |
805 } else { | 798 } else { |
806 return std::string(); | 799 return std::string(); |
807 } | 800 } |
808 } | 801 } |
809 | 802 |
810 } // namespace plugin | 803 } // namespace plugin |
OLD | NEW |