| 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 "ppapi/native_client/src/trusted/plugin/plugin.h" | 10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 37 #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" | 37 #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" | 
| 38 #include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" | 38 #include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" | 
| 39 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" | 39 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" | 
| 40 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" | 40 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" | 
| 41 #include "ppapi/native_client/src/trusted/plugin/utility.h" | 41 #include "ppapi/native_client/src/trusted/plugin/utility.h" | 
| 42 | 42 | 
| 43 namespace plugin { | 43 namespace plugin { | 
| 44 | 44 | 
| 45 namespace { | 45 namespace { | 
| 46 | 46 | 
| 47 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file. |  | 
| 48 // Note that the resulting string object has to have at least one byte extra |  | 
| 49 // for the null termination character. |  | 
| 50 const size_t kNaClManifestMaxFileBytes = 1024 * 1024; |  | 
| 51 |  | 
| 52 // Up to 20 seconds | 47 // Up to 20 seconds | 
| 53 const int64_t kTimeSmallMin = 1;         // in ms | 48 const int64_t kTimeSmallMin = 1;         // in ms | 
| 54 const int64_t kTimeSmallMax = 20000;     // in ms | 49 const int64_t kTimeSmallMax = 20000;     // in ms | 
| 55 const uint32_t kTimeSmallBuckets = 100; | 50 const uint32_t kTimeSmallBuckets = 100; | 
| 56 | 51 | 
| 57 const int64_t kSizeKBMin = 1; | 52 const int64_t kSizeKBMin = 1; | 
| 58 const int64_t kSizeKBMax = 512*1024;     // very large .nexe | 53 const int64_t kSizeKBMax = 512*1024;     // very large .nexe | 
| 59 const uint32_t kSizeKBBuckets = 100; | 54 const uint32_t kSizeKBBuckets = 100; | 
| 60 | 55 | 
| 61 }  // namespace | 56 }  // namespace | 
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 591                                   true, | 586                                   true, | 
| 592                                   &UpdateDownloadProgress)); | 587                                   &UpdateDownloadProgress)); | 
| 593       } | 588       } | 
| 594       return; | 589       return; | 
| 595     } | 590     } | 
| 596   } | 591   } | 
| 597 } | 592 } | 
| 598 | 593 | 
| 599 void Plugin::RequestNaClManifest(const nacl::string& url) { | 594 void Plugin::RequestNaClManifest(const nacl::string& url) { | 
| 600   PLUGIN_PRINTF(("Plugin::RequestNaClManifest (url='%s')\n", url.c_str())); | 595   PLUGIN_PRINTF(("Plugin::RequestNaClManifest (url='%s')\n", url.c_str())); | 
| 601   PP_Bool is_data_uri; | 596   pp::CompletionCallback open_callback = | 
| 602   ErrorInfo error_info; | 597       callback_factory_.NewCallback(&Plugin::NaClManifestFileDidOpen); | 
| 603   if (!nacl_interface_->RequestNaClManifest(pp_instance(), url.c_str(), | 598   nacl_interface_->RequestNaClManifest(pp_instance(), | 
| 604                                             &is_data_uri)) | 599                                        url.c_str(), | 
| 605     return; | 600                                        &manifest_data_var_, | 
| 606   pp::Var nmf_resolved_url = | 601                                        open_callback.pp_completion_callback()); | 
| 607       pp::Var(pp::PASS_REF, nacl_interface_->GetManifestBaseURL(pp_instance())); |  | 
| 608   if (is_data_uri) { |  | 
| 609     std::string string_nmf_resolved_url = nmf_resolved_url.AsString(); |  | 
| 610     pp::Var nmf_data = pp::Var( |  | 
| 611         pp::PASS_REF, |  | 
| 612         nacl_interface_->ParseDataURL(string_nmf_resolved_url.c_str())); |  | 
| 613     if (!nmf_data.is_string()) { |  | 
| 614       error_info.SetReport(PP_NACL_ERROR_MANIFEST_LOAD_URL, |  | 
| 615                            "could not load manifest url."); |  | 
| 616       ReportLoadError(error_info); |  | 
| 617     } else if (nmf_data.AsString().size() > kNaClManifestMaxFileBytes) { |  | 
| 618       error_info.SetReport(PP_NACL_ERROR_MANIFEST_TOO_LARGE, |  | 
| 619                            "manifest file too large."); |  | 
| 620       ReportLoadError(error_info); |  | 
| 621     } else { |  | 
| 622       ProcessNaClManifest(nmf_data.AsString()); |  | 
| 623     } |  | 
| 624   } else { |  | 
| 625     pp::CompletionCallback open_callback = |  | 
| 626         callback_factory_.NewCallback(&Plugin::NaClManifestFileDidOpen); |  | 
| 627     std::string nmf_resolved_url_str = nmf_resolved_url.AsString(); |  | 
| 628     nacl_interface_->DownloadManifestToBuffer( |  | 
| 629         pp_instance(), |  | 
| 630         &manifest_data_var_, |  | 
| 631         open_callback.pp_completion_callback()); |  | 
| 632   } |  | 
| 633 } | 602 } | 
| 634 | 603 | 
| 635 | 604 | 
| 636 bool Plugin::SetManifestObject(const nacl::string& manifest_json) { | 605 bool Plugin::SetManifestObject(const nacl::string& manifest_json) { | 
| 637   PLUGIN_PRINTF(("Plugin::SetManifestObject(): manifest_json='%s'.\n", | 606   PLUGIN_PRINTF(("Plugin::SetManifestObject(): manifest_json='%s'.\n", | 
| 638        manifest_json.c_str())); | 607        manifest_json.c_str())); | 
| 639   // Determine whether lookups should use portable (i.e., pnacl versions) | 608   // Determine whether lookups should use portable (i.e., pnacl versions) | 
| 640   // rather than platform-specific files. | 609   // rather than platform-specific files. | 
| 641   pp::Var manifest_base_url = | 610   pp::Var manifest_base_url = | 
| 642       pp::Var(pp::PASS_REF, nacl_interface_->GetManifestBaseURL(pp_instance())); | 611       pp::Var(pp::PASS_REF, nacl_interface_->GetManifestBaseURL(pp_instance())); | 
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 860 | 829 | 
| 861 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, | 830 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, | 
| 862                                        int exit_status) { | 831                                        int exit_status) { | 
| 863   DCHECK(pp::Module::Get()->core()->IsMainThread()); | 832   DCHECK(pp::Module::Get()->core()->IsMainThread()); | 
| 864   DCHECK(nacl_interface_); | 833   DCHECK(nacl_interface_); | 
| 865   nacl_interface_->SetExitStatus(pp_instance(), exit_status); | 834   nacl_interface_->SetExitStatus(pp_instance(), exit_status); | 
| 866 } | 835 } | 
| 867 | 836 | 
| 868 | 837 | 
| 869 }  // namespace plugin | 838 }  // namespace plugin | 
| OLD | NEW | 
|---|