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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 | 398 |
399 // Hereafter, normal files. | 399 // Hereafter, normal files. |
400 | 400 |
401 // Because p is owned by the callback of this invocation, so it is necessary | 401 // Because p is owned by the callback of this invocation, so it is necessary |
402 // to create another instance. | 402 // to create another instance. |
403 OpenManifestEntryResource* open_cont = new OpenManifestEntryResource(*p); | 403 OpenManifestEntryResource* open_cont = new OpenManifestEntryResource(*p); |
404 open_cont->url = mapped_url; | 404 open_cont->url = mapped_url; |
405 // Callback is now delegated from p to open_cont. So, here we manually clear | 405 // Callback is now delegated from p to open_cont. So, here we manually clear |
406 // complete callback. | 406 // complete callback. |
407 p->callback = NULL; | 407 p->callback = NULL; |
| 408 |
408 pp::CompletionCallback stream_cc = WeakRefNewCallback( | 409 pp::CompletionCallback stream_cc = WeakRefNewCallback( |
409 anchor_, | 410 anchor_, |
410 this, | 411 this, |
411 &PluginReverseInterface::StreamAsFile_MainThreadContinuation, | 412 &PluginReverseInterface::StreamAsFile_MainThreadContinuation, |
412 open_cont); | 413 open_cont); |
413 | 414 |
414 if (!plugin_->StreamAsFile(mapped_url, p->file_info, stream_cc)) { | 415 plugin_->StreamAsFile(mapped_url, &open_cont->pp_file_info, stream_cc); |
415 NaClLog(4, | 416 // p is deleted automatically. |
416 "OpenManifestEntry_MainThreadContinuation: " | |
417 "StreamAsFile failed\n"); | |
418 // Here, StreamAsFile is failed and stream_cc is not called. | |
419 // However, open_cont will be released only by the invocation. | |
420 // So, we manually call it here with error. | |
421 stream_cc.Run(PP_ERROR_FAILED); | |
422 return; | |
423 } | |
424 | |
425 NaClLog(4, "OpenManifestEntry_MainThreadContinuation: StreamAsFile okay\n"); | |
426 // p is deleted automatically | |
427 } | 417 } |
428 | 418 |
429 void PluginReverseInterface::StreamAsFile_MainThreadContinuation( | 419 void PluginReverseInterface::StreamAsFile_MainThreadContinuation( |
430 OpenManifestEntryResource* p, | 420 OpenManifestEntryResource* p, |
431 int32_t result) { | 421 int32_t result) { |
432 NaClLog(4, | 422 NaClLog(4, "Entered StreamAsFile_MainThreadContinuation\n"); |
433 "Entered StreamAsFile_MainThreadContinuation\n"); | |
434 | |
435 { | 423 { |
436 nacl::MutexLocker take(&mu_); | 424 nacl::MutexLocker take(&mu_); |
437 if (result == PP_OK) { | 425 if (result == PP_OK) { |
| 426 // We downloaded this file to temporary storage for this plugin; it's |
| 427 // reasonable to provide a file descriptor with write access. |
| 428 p->file_info->desc = ConvertFileDescriptor(p->pp_file_info.handle, false); |
| 429 p->file_info->file_token.lo = p->pp_file_info.token_lo; |
| 430 p->file_info->file_token.hi = p->pp_file_info.token_hi; |
438 NaClLog(4, | 431 NaClLog(4, |
439 "StreamAsFile_MainThreadContinuation: PP_OK, desc %d\n", | 432 "StreamAsFile_MainThreadContinuation: PP_OK, desc %d\n", |
440 p->file_info->desc); | 433 p->file_info->desc); |
441 } else { | 434 } else { |
442 NaClLog( | 435 NaClLog( |
443 4, | 436 4, |
444 "StreamAsFile_MainThreadContinuation: !PP_OK, setting desc -1\n"); | 437 "StreamAsFile_MainThreadContinuation: !PP_OK, setting desc -1\n"); |
445 p->file_info->desc = -1; | 438 p->file_info->desc = -1; |
446 } | 439 } |
447 *p->op_complete_ptr = true; | 440 *p->op_complete_ptr = true; |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 | 827 |
835 nacl::string ServiceRuntime::GetCrashLogOutput() { | 828 nacl::string ServiceRuntime::GetCrashLogOutput() { |
836 if (NULL != subprocess_.get()) { | 829 if (NULL != subprocess_.get()) { |
837 return subprocess_->GetCrashLogOutput(); | 830 return subprocess_->GetCrashLogOutput(); |
838 } else { | 831 } else { |
839 return std::string(); | 832 return std::string(); |
840 } | 833 } |
841 } | 834 } |
842 | 835 |
843 } // namespace plugin | 836 } // namespace plugin |
OLD | NEW |