| 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 } | 530 } |
| 531 } | 531 } |
| 532 // request automatically deleted | 532 // request automatically deleted |
| 533 } | 533 } |
| 534 | 534 |
| 535 void PluginReverseInterface::QuotaRequest_MainThreadResponse( | 535 void PluginReverseInterface::QuotaRequest_MainThreadResponse( |
| 536 QuotaRequest* request, | 536 QuotaRequest* request, |
| 537 int32_t err) { | 537 int32_t err) { |
| 538 NaClLog(4, | 538 NaClLog(4, |
| 539 "PluginReverseInterface::QuotaRequest_MainThreadResponse:" | 539 "PluginReverseInterface::QuotaRequest_MainThreadResponse:" |
| 540 " (resource=%"NACL_PRIx32", offset=%"NACL_PRId64", requested=%" | 540 " (resource=%" NACL_PRIx32 ", offset=%" NACL_PRId64 ", requested=%" |
| 541 NACL_PRId64", err=%"NACL_PRId32")\n", | 541 NACL_PRId64 ", err=%" NACL_PRId32 ")\n", |
| 542 request->data.resource, | 542 request->data.resource, |
| 543 request->offset, request->bytes_requested, err); | 543 request->offset, request->bytes_requested, err); |
| 544 nacl::MutexLocker take(&mu_); | 544 nacl::MutexLocker take(&mu_); |
| 545 if (err >= PP_OK) { | 545 if (err >= PP_OK) { |
| 546 *request->bytes_granted = err; | 546 *request->bytes_granted = err; |
| 547 } else { | 547 } else { |
| 548 *request->bytes_granted = 0; | 548 *request->bytes_granted = 0; |
| 549 } | 549 } |
| 550 *request->op_complete_ptr = true; | 550 *request->op_complete_ptr = true; |
| 551 NaClXCondVarBroadcast(&cv_); | 551 NaClXCondVarBroadcast(&cv_); |
| 552 // request automatically deleted | 552 // request automatically deleted |
| 553 } | 553 } |
| 554 | 554 |
| 555 int64_t PluginReverseInterface::RequestQuotaForWrite( | 555 int64_t PluginReverseInterface::RequestQuotaForWrite( |
| 556 nacl::string file_id, int64_t offset, int64_t bytes_to_write) { | 556 nacl::string file_id, int64_t offset, int64_t bytes_to_write) { |
| 557 NaClLog(4, | 557 NaClLog(4, |
| 558 "PluginReverseInterface::RequestQuotaForWrite:" | 558 "PluginReverseInterface::RequestQuotaForWrite:" |
| 559 " (file_id='%s', offset=%"NACL_PRId64", bytes_to_write=%" | 559 " (file_id='%s', offset=%" NACL_PRId64 ", bytes_to_write=%" |
| 560 NACL_PRId64")\n", file_id.c_str(), offset, bytes_to_write); | 560 NACL_PRId64 ")\n", file_id.c_str(), offset, bytes_to_write); |
| 561 QuotaData quota_data; | 561 QuotaData quota_data; |
| 562 { | 562 { |
| 563 nacl::MutexLocker take(&mu_); | 563 nacl::MutexLocker take(&mu_); |
| 564 uint64_t file_key = STRTOULL(file_id.c_str(), NULL, 10); | 564 uint64_t file_key = STRTOULL(file_id.c_str(), NULL, 10); |
| 565 if (quota_map_.find(file_key) == quota_map_.end()) { | 565 if (quota_map_.find(file_key) == quota_map_.end()) { |
| 566 // Look up failed to find the requested quota managed resource. | 566 // Look up failed to find the requested quota managed resource. |
| 567 NaClLog(4, "PluginReverseInterface::RequestQuotaForWrite: failed...\n"); | 567 NaClLog(4, "PluginReverseInterface::RequestQuotaForWrite: failed...\n"); |
| 568 return 0; | 568 return 0; |
| 569 } | 569 } |
| 570 quota_data = quota_map_[file_key]; | 570 quota_data = quota_map_[file_key]; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 598 } while (0); | 598 } while (0); |
| 599 if (shutting_down) return 0; | 599 if (shutting_down) return 0; |
| 600 return quota_granted; | 600 return quota_granted; |
| 601 } | 601 } |
| 602 | 602 |
| 603 void PluginReverseInterface::AddQuotaManagedFile(const nacl::string& file_id, | 603 void PluginReverseInterface::AddQuotaManagedFile(const nacl::string& file_id, |
| 604 const pp::FileIO& file_io) { | 604 const pp::FileIO& file_io) { |
| 605 PP_Resource resource = file_io.pp_resource(); | 605 PP_Resource resource = file_io.pp_resource(); |
| 606 NaClLog(4, | 606 NaClLog(4, |
| 607 "PluginReverseInterface::AddQuotaManagedFile: " | 607 "PluginReverseInterface::AddQuotaManagedFile: " |
| 608 "(file_id='%s', file_io_ref=%"NACL_PRIx32")\n", | 608 "(file_id='%s', file_io_ref=%" NACL_PRIx32 ")\n", |
| 609 file_id.c_str(), resource); | 609 file_id.c_str(), resource); |
| 610 nacl::MutexLocker take(&mu_); | 610 nacl::MutexLocker take(&mu_); |
| 611 uint64_t file_key = STRTOULL(file_id.c_str(), NULL, 10); | 611 uint64_t file_key = STRTOULL(file_id.c_str(), NULL, 10); |
| 612 QuotaData data(plugin::PepperQuotaType, resource); | 612 QuotaData data(plugin::PepperQuotaType, resource); |
| 613 quota_map_[file_key] = data; | 613 quota_map_[file_key] = data; |
| 614 } | 614 } |
| 615 | 615 |
| 616 void PluginReverseInterface::AddTempQuotaManagedFile( | 616 void PluginReverseInterface::AddTempQuotaManagedFile( |
| 617 const nacl::string& file_id) { | 617 const nacl::string& file_id) { |
| 618 NaClLog(4, "PluginReverseInterface::AddTempQuotaManagedFile: " | 618 NaClLog(4, "PluginReverseInterface::AddTempQuotaManagedFile: " |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 "reverse_setup::h", | 663 "reverse_setup::h", |
| 664 &out_conn_cap); | 664 &out_conn_cap); |
| 665 | 665 |
| 666 if (NACL_SRPC_RESULT_OK != rpc_result) { | 666 if (NACL_SRPC_RESULT_OK != rpc_result) { |
| 667 error_info->SetReport(ERROR_SEL_LDR_COMMUNICATION_REV_SETUP, | 667 error_info->SetReport(ERROR_SEL_LDR_COMMUNICATION_REV_SETUP, |
| 668 "ServiceRuntime: reverse setup rpc failed"); | 668 "ServiceRuntime: reverse setup rpc failed"); |
| 669 return false; | 669 return false; |
| 670 } | 670 } |
| 671 // Get connection capability to service runtime where the IMC | 671 // Get connection capability to service runtime where the IMC |
| 672 // server/SRPC client is waiting for a rendezvous. | 672 // server/SRPC client is waiting for a rendezvous. |
| 673 NaClLog(4, "ServiceRuntime: got 0x%"NACL_PRIxPTR"\n", | 673 NaClLog(4, "ServiceRuntime: got 0x%" NACL_PRIxPTR "\n", |
| 674 (uintptr_t) out_conn_cap); | 674 (uintptr_t) out_conn_cap); |
| 675 nacl::DescWrapper* conn_cap = plugin_->wrapper_factory()->MakeGenericCleanup( | 675 nacl::DescWrapper* conn_cap = plugin_->wrapper_factory()->MakeGenericCleanup( |
| 676 out_conn_cap); | 676 out_conn_cap); |
| 677 if (conn_cap == NULL) { | 677 if (conn_cap == NULL) { |
| 678 error_info->SetReport(ERROR_SEL_LDR_COMMUNICATION_WRAPPER, | 678 error_info->SetReport(ERROR_SEL_LDR_COMMUNICATION_WRAPPER, |
| 679 "ServiceRuntime: wrapper allocation failure"); | 679 "ServiceRuntime: wrapper allocation failure"); |
| 680 return false; | 680 return false; |
| 681 } | 681 } |
| 682 out_conn_cap = NULL; // ownership passed | 682 out_conn_cap = NULL; // ownership passed |
| 683 NaClLog(4, "ServiceRuntime::InitCommunication: starting reverse service\n"); | 683 NaClLog(4, "ServiceRuntime::InitCommunication: starting reverse service\n"); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 | 875 |
| 876 nacl::string ServiceRuntime::GetCrashLogOutput() { | 876 nacl::string ServiceRuntime::GetCrashLogOutput() { |
| 877 if (NULL != subprocess_.get()) { | 877 if (NULL != subprocess_.get()) { |
| 878 return subprocess_->GetCrashLogOutput(); | 878 return subprocess_->GetCrashLogOutput(); |
| 879 } else { | 879 } else { |
| 880 return std::string(); | 880 return std::string(); |
| 881 } | 881 } |
| 882 } | 882 } |
| 883 | 883 |
| 884 } // namespace plugin | 884 } // namespace plugin |
| OLD | NEW |