Chromium Code Reviews| 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 "native_client/src/trusted/plugin/plugin.h" | 10 #include "native_client/src/trusted/plugin/plugin.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 #include "native_client/src/include/portability_io.h" | 33 #include "native_client/src/include/portability_io.h" |
| 34 #include "native_client/src/include/portability_string.h" | 34 #include "native_client/src/include/portability_string.h" |
| 35 #include "native_client/src/shared/platform/nacl_check.h" | 35 #include "native_client/src/shared/platform/nacl_check.h" |
| 36 #include "native_client/src/shared/platform/nacl_time.h" | 36 #include "native_client/src/shared/platform/nacl_time.h" |
| 37 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" | 37 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" |
| 38 #include "native_client/src/trusted/desc/nacl_desc_base.h" | 38 #include "native_client/src/trusted/desc/nacl_desc_base.h" |
| 39 #include "native_client/src/trusted/desc/nacl_desc_conn_cap.h" | 39 #include "native_client/src/trusted/desc/nacl_desc_conn_cap.h" |
| 40 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 40 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
| 41 #include "native_client/src/trusted/handle_pass/browser_handle.h" | 41 #include "native_client/src/trusted/handle_pass/browser_handle.h" |
| 42 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" | 42 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" |
| 43 #include "native_client/src/trusted/plugin/browser_interface.h" | |
| 44 #include "native_client/src/trusted/plugin/desc_based_handle.h" | |
| 45 #include "native_client/src/trusted/plugin/json_manifest.h" | 43 #include "native_client/src/trusted/plugin/json_manifest.h" |
| 46 #include "native_client/src/trusted/plugin/nacl_subprocess.h" | 44 #include "native_client/src/trusted/plugin/nacl_subprocess.h" |
| 47 #include "native_client/src/trusted/plugin/nexe_arch.h" | 45 #include "native_client/src/trusted/plugin/nexe_arch.h" |
| 48 #include "native_client/src/trusted/plugin/plugin_error.h" | 46 #include "native_client/src/trusted/plugin/plugin_error.h" |
| 49 #include "native_client/src/trusted/plugin/scriptable_handle.h" | 47 #include "native_client/src/trusted/plugin/scriptable_handle.h" |
| 50 #include "native_client/src/trusted/plugin/service_runtime.h" | 48 #include "native_client/src/trusted/plugin/service_runtime.h" |
| 51 #include "native_client/src/trusted/plugin/string_encoding.h" | 49 #include "native_client/src/trusted/plugin/string_encoding.h" |
| 52 #include "native_client/src/trusted/plugin/utility.h" | 50 #include "native_client/src/trusted/plugin/utility.h" |
| 53 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" | 51 #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h" |
| 54 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" | 52 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" |
| 55 | 53 |
| 54 #include "ppapi/c/dev/ppb_console_dev.h" | |
| 56 #include "ppapi/c/dev/ppp_find_dev.h" | 55 #include "ppapi/c/dev/ppp_find_dev.h" |
| 57 #include "ppapi/c/dev/ppp_printing_dev.h" | 56 #include "ppapi/c/dev/ppp_printing_dev.h" |
| 58 #include "ppapi/c/dev/ppp_scrollbar_dev.h" | 57 #include "ppapi/c/dev/ppp_scrollbar_dev.h" |
| 59 #include "ppapi/c/dev/ppp_selection_dev.h" | 58 #include "ppapi/c/dev/ppp_selection_dev.h" |
| 60 #include "ppapi/c/dev/ppp_widget_dev.h" | 59 #include "ppapi/c/dev/ppp_widget_dev.h" |
| 61 #include "ppapi/c/dev/ppp_zoom_dev.h" | 60 #include "ppapi/c/dev/ppp_zoom_dev.h" |
| 62 #include "ppapi/c/pp_errors.h" | 61 #include "ppapi/c/pp_errors.h" |
| 62 #include "ppapi/c/ppb_var.h" | |
| 63 #include "ppapi/c/ppp_input_event.h" | 63 #include "ppapi/c/ppp_input_event.h" |
| 64 #include "ppapi/c/ppp_instance.h" | 64 #include "ppapi/c/ppp_instance.h" |
| 65 #include "ppapi/c/ppp_mouse_lock.h" | 65 #include "ppapi/c/ppp_mouse_lock.h" |
| 66 #include "ppapi/c/private/ppb_uma_private.h" | 66 #include "ppapi/c/private/ppb_uma_private.h" |
| 67 #include "ppapi/cpp/dev/find_dev.h" | 67 #include "ppapi/cpp/dev/find_dev.h" |
| 68 #include "ppapi/cpp/dev/printing_dev.h" | 68 #include "ppapi/cpp/dev/printing_dev.h" |
| 69 #include "ppapi/cpp/dev/scrollbar_dev.h" | 69 #include "ppapi/cpp/dev/scrollbar_dev.h" |
| 70 #include "ppapi/cpp/dev/selection_dev.h" | 70 #include "ppapi/cpp/dev/selection_dev.h" |
| 71 #include "ppapi/cpp/dev/text_input_dev.h" | 71 #include "ppapi/cpp/dev/text_input_dev.h" |
| 72 #include "ppapi/cpp/dev/url_util_dev.h" | 72 #include "ppapi/cpp/dev/url_util_dev.h" |
| 73 #include "ppapi/cpp/dev/widget_client_dev.h" | 73 #include "ppapi/cpp/dev/widget_client_dev.h" |
| 74 #include "ppapi/cpp/dev/zoom_dev.h" | 74 #include "ppapi/cpp/dev/zoom_dev.h" |
| 75 #include "ppapi/cpp/image_data.h" | 75 #include "ppapi/cpp/image_data.h" |
| 76 #include "ppapi/cpp/input_event.h" | 76 #include "ppapi/cpp/input_event.h" |
| 77 #include "ppapi/cpp/module.h" | 77 #include "ppapi/cpp/module.h" |
| 78 #include "ppapi/cpp/mouse_lock.h" | 78 #include "ppapi/cpp/mouse_lock.h" |
| 79 #include "ppapi/cpp/rect.h" | 79 #include "ppapi/cpp/rect.h" |
| 80 | 80 |
| 81 using ppapi_proxy::BrowserPpp; | 81 using ppapi_proxy::BrowserPpp; |
| 82 | 82 |
| 83 namespace plugin { | 83 namespace plugin { |
| 84 | 84 |
| 85 namespace { | 85 namespace { |
| 86 | 86 |
| 87 bool GetReadyStateProperty(void* obj, SrpcParams* params) { | |
| 88 Plugin* plugin = static_cast<Plugin*>(obj); | |
| 89 params->outs()[0]->u.ival = plugin->nacl_ready_state(); | |
| 90 return true; | |
| 91 } | |
| 92 | |
| 93 const char* const kTypeAttribute = "type"; | 87 const char* const kTypeAttribute = "type"; |
| 94 // The "src" attribute of the <embed> tag. The value is expected to be either | 88 // The "src" attribute of the <embed> tag. The value is expected to be either |
| 95 // a URL or URI pointing to the manifest file (which is expected to contain | 89 // a URL or URI pointing to the manifest file (which is expected to contain |
| 96 // JSON matching ISAs with .nexe URLs). | 90 // JSON matching ISAs with .nexe URLs). |
| 97 const char* const kSrcManifestAttribute = "src"; | 91 const char* const kSrcManifestAttribute = "src"; |
| 98 // The "nacl" attribute of the <embed> tag. We use the value of this attribute | 92 // The "nacl" attribute of the <embed> tag. We use the value of this attribute |
| 99 // to find the manifest file when NaCl is registered as a plug-in for another | 93 // to find the manifest file when NaCl is registered as a plug-in for another |
| 100 // MIME type because the "src" attribute is used to supply us with the resource | 94 // MIME type because the "src" attribute is used to supply us with the resource |
| 101 // of that MIME type that we're supposed to display. | 95 // of that MIME type that we're supposed to display. |
| 102 const char* const kNaClManifestAttribute = "nacl"; | 96 const char* const kNaClManifestAttribute = "nacl"; |
| 103 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file. | 97 // This is a pretty arbitrary limit on the byte size of the NaCl manfest file. |
| 104 // Note that the resulting string object has to have at least one byte extra | 98 // Note that the resulting string object has to have at least one byte extra |
| 105 // for the null termination character. | 99 // for the null termination character. |
| 106 const size_t kNaClManifestMaxFileBytes = 1024 * 1024; | 100 const size_t kNaClManifestMaxFileBytes = 1024 * 1024; |
| 107 | 101 |
| 108 // Define an argument name to enable 'dev' interfaces. To make sure it doesn't | 102 // Define an argument name to enable 'dev' interfaces. To make sure it doesn't |
| 109 // collide with any user-defined HTML attribute, make the first character '@'. | 103 // collide with any user-defined HTML attribute, make the first character '@'. |
| 110 const char* const kDevAttribute = "@dev"; | 104 const char* const kDevAttribute = "@dev"; |
| 111 | 105 |
| 112 // URL schemes that we treat in special ways. | 106 // URL schemes that we treat in special ways. |
| 113 const char* const kChromeExtensionUriScheme = "chrome-extension"; | 107 const char* const kChromeExtensionUriScheme = "chrome-extension"; |
| 114 const char* const kDataUriScheme = "data"; | 108 const char* const kDataUriScheme = "data"; |
| 115 | 109 |
| 116 // The key used to find the dictionary nexe URLs in the manifest file. | 110 // The key used to find the dictionary nexe URLs in the manifest file. |
| 117 const char* const kNexesKey = "nexes"; | 111 const char* const kNexesKey = "nexes"; |
| 118 | 112 |
| 119 bool GetLastError(void* obj, SrpcParams* params) { | |
| 120 NaClSrpcArg** outs = params->outs(); | |
| 121 PLUGIN_PRINTF(("GetLastError (obj=%p)\n", obj)); | |
| 122 | |
| 123 Plugin* plugin = static_cast<Plugin*>(obj); | |
| 124 outs[0]->arrays.str = strdup(plugin->last_error_string().c_str()); | |
| 125 return true; | |
| 126 } | |
| 127 | |
| 128 bool GetExitStatus(void* obj, SrpcParams* params) { | |
| 129 NaClSrpcArg** outs = params->outs(); | |
| 130 PLUGIN_PRINTF(("GetExitStatus (obj=%p)\n", obj)); | |
| 131 | |
| 132 Plugin* plugin = static_cast<Plugin*>(obj); | |
| 133 outs[0]->u.ival = plugin->exit_status(); | |
| 134 return true; | |
| 135 } | |
| 136 | |
| 137 // Up to 20 seconds | 113 // Up to 20 seconds |
| 138 const int64_t kTimeSmallMin = 1; // in ms | 114 const int64_t kTimeSmallMin = 1; // in ms |
| 139 const int64_t kTimeSmallMax = 20000; // in ms | 115 const int64_t kTimeSmallMax = 20000; // in ms |
| 140 const uint32_t kTimeSmallBuckets = 100; | 116 const uint32_t kTimeSmallBuckets = 100; |
| 141 | 117 |
| 142 // Up to 3 minutes, 20 seconds | 118 // Up to 3 minutes, 20 seconds |
| 143 const int64_t kTimeMediumMin = 10; // in ms | 119 const int64_t kTimeMediumMin = 10; // in ms |
| 144 const int64_t kTimeMediumMax = 200000; // in ms | 120 const int64_t kTimeMediumMax = 200000; // in ms |
| 145 const uint32_t kTimeMediumBuckets = 100; | 121 const uint32_t kTimeMediumBuckets = 100; |
| 146 | 122 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 | 474 |
| 499 private: | 475 private: |
| 500 Plugin* plugin_; | 476 Plugin* plugin_; |
| 501 const PPP_Zoom_Dev* ppp_zoom_; | 477 const PPP_Zoom_Dev* ppp_zoom_; |
| 502 | 478 |
| 503 NACL_DISALLOW_COPY_AND_ASSIGN(ZoomAdapter); | 479 NACL_DISALLOW_COPY_AND_ASSIGN(ZoomAdapter); |
| 504 }; | 480 }; |
| 505 | 481 |
| 506 } // namespace | 482 } // namespace |
| 507 | 483 |
| 508 bool Plugin::ExperimentalJavaScriptApisAreEnabled() { | 484 static int const kAbiHeaderBuffer = 256; // must be at least EI_ABIVERSION + 1 |
| 509 return getenv("NACL_ENABLE_EXPERIMENTAL_JAVASCRIPT_APIS") != NULL; | 485 |
| 486 void Plugin::AddPropertyGet(const nacl::string& prop_name, | |
| 487 Plugin::PropertyGetter getter) { | |
| 488 PLUGIN_PRINTF(("Plugin::AddPropertyGet (prop_name='%s')\n", | |
| 489 prop_name.c_str())); | |
| 490 property_getters_[nacl::string(prop_name)] = getter; | |
| 510 } | 491 } |
| 511 | 492 |
| 512 static int const kAbiHeaderBuffer = 256; // must be at least EI_ABIVERSION + 1 | 493 bool Plugin::HasProperty(const nacl::string& prop_name) { |
| 513 | 494 PLUGIN_PRINTF(("Plugin::HasProperty (prop_name=%s)\n", |
| 514 void Plugin::LoadMethods() { | 495 prop_name.c_str())); |
| 515 PLUGIN_PRINTF(("Plugin::LoadMethods ()\n")); | 496 return property_getters_[prop_name] != NULL; |
| 516 // Properties implemented by Plugin. | |
| 517 AddPropertyGet(GetReadyStateProperty, "readyState", "i"); | |
| 518 } | 497 } |
| 519 | 498 |
| 520 bool Plugin::HasMethod(uintptr_t method_id, CallType call_type) { | 499 bool Plugin::GetProperty(const nacl::string& prop_name, |
| 521 PLUGIN_PRINTF(("Plugin::HasMethod (method_id=%x)\n", | 500 NaClSrpcArg* prop_value) { |
| 522 static_cast<int>(method_id))); | 501 PLUGIN_PRINTF(("Plugin::GetProperty (prop_name=%s)\n", prop_name.c_str())); |
| 523 if (GetMethodInfo(method_id, call_type)) { | 502 |
| 524 PLUGIN_PRINTF(("true\n")); | 503 PropertyGetter getter = property_getters_[prop_name]; |
| 525 return true; | 504 if (NULL == getter) { |
| 526 } | |
| 527 if (!ExperimentalJavaScriptApisAreEnabled()) { | |
| 528 PLUGIN_PRINTF(("false\n")); | |
| 529 return false; | 505 return false; |
| 530 } | 506 } |
| 531 if (call_type != METHOD_CALL) { | 507 (this->*getter)(prop_value); |
| 532 // SRPC nexes can only export methods. | 508 return true; |
| 533 PLUGIN_PRINTF(("false\n")); | |
| 534 return false; | |
| 535 } | |
| 536 bool has_method = main_subprocess_.HasMethod(method_id); | |
| 537 PLUGIN_PRINTF(("%s\n", (has_method ? "true" : "false"))); | |
| 538 return has_method; | |
| 539 } | 509 } |
| 540 | 510 |
| 541 bool Plugin::InitParams(uintptr_t method_id, | 511 void Plugin::GetExitStatus(NaClSrpcArg* prop_value) { |
| 542 CallType call_type, | 512 PLUGIN_PRINTF(("GetExitStatus (this=%p)\n", reinterpret_cast<void*>(this))); |
| 543 SrpcParams* params) { | 513 prop_value->tag = NACL_SRPC_ARG_TYPE_INT; |
| 544 MethodInfo* method_info = GetMethodInfo(method_id, call_type); | 514 prop_value->u.ival = exit_status(); |
| 545 PLUGIN_PRINTF(("Plugin::InitParams (id=%"NACL_PRIxPTR", method_info=%p)\n", | |
| 546 method_id, method_info)); | |
| 547 if (NULL != method_info) { | |
| 548 return params->Init(method_info->ins(), method_info->outs()); | |
| 549 } | |
| 550 if (!ExperimentalJavaScriptApisAreEnabled()) { | |
| 551 return false; | |
| 552 } | |
| 553 if (call_type != METHOD_CALL) { | |
| 554 // SRPC nexes can only export methods. | |
| 555 return false; | |
| 556 } | |
| 557 return main_subprocess_.InitParams(method_id, params); | |
| 558 } | 515 } |
| 559 | 516 |
| 560 bool Plugin::Invoke(uintptr_t method_id, | 517 void Plugin::GetLastError(NaClSrpcArg* prop_value) { |
| 561 CallType call_type, | 518 PLUGIN_PRINTF(("GetLastError (this=%p)\n", reinterpret_cast<void*>(this))); |
| 562 SrpcParams* params) { | 519 prop_value->tag = NACL_SRPC_ARG_TYPE_STRING; |
| 563 MethodInfo* method_info = GetMethodInfo(method_id, call_type); | 520 prop_value->arrays.str = strdup(last_error_string().c_str()); |
| 564 | |
| 565 if (NULL != method_info && NULL != method_info->function_ptr()) { | |
| 566 return method_info->function_ptr()(static_cast<void*>(this), params); | |
| 567 } | |
| 568 if (!ExperimentalJavaScriptApisAreEnabled()) { | |
| 569 return false; | |
| 570 } | |
| 571 if (call_type != METHOD_CALL) { | |
| 572 // SRPC nexes can only export methods. | |
| 573 return false; | |
| 574 } | |
| 575 return main_subprocess_.Invoke(method_id, params); | |
| 576 } | 521 } |
| 577 | 522 |
| 578 bool Plugin::Init(BrowserInterface* browser_interface, | 523 void Plugin::GetReadyStateProperty(NaClSrpcArg* prop_value) { |
| 579 int argc, | 524 PLUGIN_PRINTF(("GetReadyState (this=%p)\n", reinterpret_cast<void*>(this))); |
| 580 char* argn[], | 525 prop_value->tag = NACL_SRPC_ARG_TYPE_INT; |
| 581 char* argv[]) { | 526 prop_value->u.ival = nacl_ready_state(); |
| 527 } | |
| 528 | |
| 529 bool Plugin::Init(int argc, char* argn[], char* argv[]) { | |
| 582 PLUGIN_PRINTF(("Plugin::Init (instance=%p)\n", static_cast<void*>(this))); | 530 PLUGIN_PRINTF(("Plugin::Init (instance=%p)\n", static_cast<void*>(this))); |
| 583 | 531 |
| 584 #ifdef NACL_OSX | 532 #ifdef NACL_OSX |
| 585 // TODO(kochi): For crbug.com/102808, this is a stopgap solution for Lion | 533 // TODO(kochi): For crbug.com/102808, this is a stopgap solution for Lion |
| 586 // until we expose IME API to .nexe. This disables any IME interference | 534 // until we expose IME API to .nexe. This disables any IME interference |
| 587 // against key inputs, so you cannot use off-the-spot IME input for NaCl apps. | 535 // against key inputs, so you cannot use off-the-spot IME input for NaCl apps. |
| 588 // This makes discrepancy among platforms and therefore we should remove | 536 // This makes discrepancy among platforms and therefore we should remove |
| 589 // this hack when IME API is made available. | 537 // this hack when IME API is made available. |
| 590 // The default for non-Mac platforms is still off-the-spot IME mode. | 538 // The default for non-Mac platforms is still off-the-spot IME mode. |
| 591 pp::TextInput_Dev(this).SetTextInputType(PP_TEXTINPUT_TYPE_NONE); | 539 pp::TextInput_Dev(this).SetTextInputType(PP_TEXTINPUT_TYPE_NONE); |
| 592 #endif | 540 #endif |
| 593 | 541 |
| 594 browser_interface_ = browser_interface; | |
| 595 // Remember the embed/object argn/argv pairs. | 542 // Remember the embed/object argn/argv pairs. |
| 596 argn_ = new(std::nothrow) char*[argc]; | 543 argn_ = new(std::nothrow) char*[argc]; |
| 597 argv_ = new(std::nothrow) char*[argc]; | 544 argv_ = new(std::nothrow) char*[argc]; |
| 598 argc_ = 0; | 545 argc_ = 0; |
| 599 for (int i = 0; i < argc; ++i) { | 546 for (int i = 0; i < argc; ++i) { |
| 600 if (NULL != argn_ && NULL != argv_) { | 547 if (NULL != argn_ && NULL != argv_) { |
| 601 argn_[argc_] = strdup(argn[i]); | 548 argn_[argc_] = strdup(argn[i]); |
| 602 argv_[argc_] = strdup(argv[i]); | 549 argv_[argc_] = strdup(argv[i]); |
| 603 if (NULL == argn_[argc_] || NULL == argv_[argc_]) { | 550 if (NULL == argn_[argc_] || NULL == argv_[argc_]) { |
| 604 // Give up on passing arguments. | 551 // Give up on passing arguments. |
| 605 free(argn_[argc_]); | 552 free(argn_[argc_]); |
| 606 free(argv_[argc_]); | 553 free(argv_[argc_]); |
| 607 continue; | 554 continue; |
| 608 } | 555 } |
| 609 ++argc_; | 556 ++argc_; |
| 610 } | 557 } |
| 611 } | 558 } |
| 612 // TODO(sehr): this leaks strings if there is a subsequent failure. | 559 // TODO(sehr): this leaks strings if there is a subsequent failure. |
| 613 | 560 |
| 614 // Set up the factory used to produce DescWrappers. | 561 // Set up the factory used to produce DescWrappers. |
| 615 wrapper_factory_ = new nacl::DescWrapperFactory(); | 562 wrapper_factory_ = new nacl::DescWrapperFactory(); |
| 616 if (NULL == wrapper_factory_) { | 563 if (NULL == wrapper_factory_) { |
| 617 return false; | 564 return false; |
| 618 } | 565 } |
| 619 PLUGIN_PRINTF(("Plugin::Init (wrapper_factory=%p)\n", | 566 PLUGIN_PRINTF(("Plugin::Init (wrapper_factory=%p)\n", |
| 620 static_cast<void*>(wrapper_factory_))); | 567 static_cast<void*>(wrapper_factory_))); |
| 621 | 568 |
| 622 // Set up the scriptable methods for the plugin. | 569 // Export a property to allow us to get the exit status of a nexe. |
| 623 LoadMethods(); | 570 AddPropertyGet("exitStatus", &Plugin::GetExitStatus); |
| 571 // Export a property to allow us to get the last error description. | |
| 572 AddPropertyGet("lastError", &Plugin::GetLastError); | |
| 573 // Export a property to allow us to get the ready state of a nexe during load. | |
| 574 AddPropertyGet("readyState", &Plugin::GetReadyStateProperty); | |
| 624 | 575 |
| 625 PLUGIN_PRINTF(("Plugin::Init (return 1)\n")); | 576 PLUGIN_PRINTF(("Plugin::Init (return 1)\n")); |
| 626 // Return success. | 577 // Return success. |
| 627 return true; | 578 return true; |
| 628 } | 579 } |
| 629 | 580 |
| 630 void Plugin::ShutDownSubprocesses() { | 581 void Plugin::ShutDownSubprocesses() { |
| 631 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (this=%p)\n", | 582 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (this=%p)\n", |
| 632 static_cast<void*>(this))); | 583 static_cast<void*>(this))); |
| 633 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (%s)\n", | 584 PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (%s)\n", |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 "%p)\n", | 633 "%p)\n", |
| 683 static_cast<void*>(subprocess->srpc_client()))); | 634 static_cast<void*>(subprocess->srpc_client()))); |
| 684 return true; | 635 return true; |
| 685 } | 636 } |
| 686 | 637 |
| 687 bool Plugin::StartSrpcServices(NaClSubprocess* subprocess, | 638 bool Plugin::StartSrpcServices(NaClSubprocess* subprocess, |
| 688 ErrorInfo* error_info) { | 639 ErrorInfo* error_info) { |
| 689 if (!StartSrpcServicesCommon(subprocess, error_info)) { | 640 if (!StartSrpcServicesCommon(subprocess, error_info)) { |
| 690 return false; | 641 return false; |
| 691 } | 642 } |
| 692 // TODO(jvoung): This next bit is likely not needed... | 643 // TODO(jvoung): This next bit is likely not needed... |
|
jvoung - send to chromium...
2012/02/15 00:58:09
Can this "StartSrpcServices()" be removed now too?
sehr (please use chromium)
2012/02/15 01:16:38
Done.
| |
| 693 // If StartSrpcServices is only in the JS API that is just for SRPC nexes | 644 // If StartSrpcServices is only in the JS API that is just for SRPC nexes |
| 694 // (namely __startSrpcServices), then attempts to start the JS proxy | 645 // (namely __startSrpcServices), then attempts to start the JS proxy |
| 695 // will fail anyway? | 646 // will fail anyway? |
| 696 // If that is the case, by removing the following line, | 647 // If that is the case, by removing the following line, |
| 697 // the StartSrpcServices == StartSrpcServicesCommon. | 648 // the StartSrpcServices == StartSrpcServicesCommon. |
| 698 // We still need this function though, to launch helper SRPC nexes within | 649 // We still need this function though, to launch helper SRPC nexes within |
| 699 // the plugin. | 650 // the plugin. |
| 700 return StartJSObjectProxy(subprocess, error_info); | 651 return StartJSObjectProxy(subprocess, error_info); |
| 701 } | 652 } |
| 702 | 653 |
| 703 bool Plugin::StartJSObjectProxy(NaClSubprocess* subprocess, | 654 bool Plugin::StartJSObjectProxy(NaClSubprocess* subprocess, |
| 704 ErrorInfo* error_info) { | 655 ErrorInfo* error_info) { |
| 705 if (!subprocess->StartJSObjectProxy(this, error_info)) { | 656 return subprocess->StartJSObjectProxy(this, error_info); |
| 706 // TODO(sehr,polina): rename the function and env var | |
| 707 // to ExperimentalJavaScriptApisAreEnabled. | |
| 708 if (error_info->error_code() == ERROR_START_PROXY_CHECK_PPP && | |
| 709 ExperimentalJavaScriptApisAreEnabled()) { | |
| 710 // It is not an error for the proxy to fail to find PPP methods if | |
| 711 // experimental APIs are enabled. This means we have an SRPC nexe. | |
| 712 error_info->Reset(); | |
| 713 } else { | |
| 714 return false; | |
| 715 } | |
| 716 } | |
| 717 return true; | |
| 718 } | 657 } |
| 719 | 658 |
| 720 bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper, | 659 bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper, |
| 721 ErrorInfo* error_info, | 660 ErrorInfo* error_info, |
| 722 pp::CompletionCallback init_done_cb, | 661 pp::CompletionCallback init_done_cb, |
| 723 pp::CompletionCallback crash_cb) { | 662 pp::CompletionCallback crash_cb) { |
| 724 // Before forking a new sel_ldr process, ensure that we do not leak | 663 // Before forking a new sel_ldr process, ensure that we do not leak |
| 725 // the ServiceRuntime object for an existing subprocess, and that any | 664 // the ServiceRuntime object for an existing subprocess, and that any |
| 726 // associated listener threads do not go unjoined because if they | 665 // associated listener threads do not go unjoined because if they |
| 727 // outlive the Plugin object, they will not be memory safe. | 666 // outlive the Plugin object, they will not be memory safe. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 742 } | 681 } |
| 743 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", | 682 PLUGIN_PRINTF(("Plugin::LoadNaClModule (%s)\n", |
| 744 main_subprocess_.detailed_description().c_str())); | 683 main_subprocess_.detailed_description().c_str())); |
| 745 return true; | 684 return true; |
| 746 } | 685 } |
| 747 | 686 |
| 748 NaClSubprocess* Plugin::LoadHelperNaClModule(nacl::DescWrapper* wrapper, | 687 NaClSubprocess* Plugin::LoadHelperNaClModule(nacl::DescWrapper* wrapper, |
| 749 const Manifest* manifest, | 688 const Manifest* manifest, |
| 750 ErrorInfo* error_info) { | 689 ErrorInfo* error_info) { |
| 751 nacl::scoped_ptr<NaClSubprocess> nacl_subprocess( | 690 nacl::scoped_ptr<NaClSubprocess> nacl_subprocess( |
| 752 new NaClSubprocess("helper module", browser_interface_, NULL, NULL)); | 691 new NaClSubprocess("helper module", NULL, NULL)); |
| 753 if (NULL == nacl_subprocess.get()) { | 692 if (NULL == nacl_subprocess.get()) { |
| 754 error_info->SetReport(ERROR_SEL_LDR_INIT, | 693 error_info->SetReport(ERROR_SEL_LDR_INIT, |
| 755 "unable to allocate helper subprocess."); | 694 "unable to allocate helper subprocess."); |
| 756 return NULL; | 695 return NULL; |
| 757 } | 696 } |
| 758 | 697 |
| 759 // Do not report UMA stats for translator-related nexes. | 698 // Do not report UMA stats for translator-related nexes. |
| 760 // TODO(sehr): define new UMA stats for translator related nexe events. | 699 // TODO(sehr): define new UMA stats for translator related nexe events. |
| 761 if (!(LoadNaClModuleCommon(wrapper, nacl_subprocess.get(), manifest, | 700 if (!(LoadNaClModuleCommon(wrapper, nacl_subprocess.get(), manifest, |
| 762 false, error_info, | 701 false, error_info, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 787 char* Plugin::LookupArgument(const char* key) { | 726 char* Plugin::LookupArgument(const char* key) { |
| 788 char** keys = argn(); | 727 char** keys = argn(); |
| 789 for (int ii = 0, len = argc(); ii < len; ++ii) { | 728 for (int ii = 0, len = argc(); ii < len; ++ii) { |
| 790 if (!strcmp(keys[ii], key)) { | 729 if (!strcmp(keys[ii], key)) { |
| 791 return argv()[ii]; | 730 return argv()[ii]; |
| 792 } | 731 } |
| 793 } | 732 } |
| 794 return NULL; | 733 return NULL; |
| 795 } | 734 } |
| 796 | 735 |
| 797 void Plugin::AddPropertyGet(RpcFunction function_ptr, | |
| 798 const char* name, | |
| 799 const char* outs) { | |
| 800 uintptr_t method_id = browser_interface()->StringToIdentifier(name); | |
| 801 PLUGIN_PRINTF(("Plugin::AddPropertyGet (name='%s', id=%" | |
| 802 NACL_PRIxPTR")\n", name, method_id)); | |
| 803 MethodInfo* new_method = new MethodInfo(function_ptr, name, "", outs); | |
| 804 property_get_methods_.AddMethod(method_id, new_method); | |
| 805 } | |
| 806 | |
| 807 MethodInfo* Plugin::GetMethodInfo(uintptr_t method_id, CallType call_type) { | |
| 808 MethodInfo* method_info = NULL; | |
| 809 switch (call_type) { | |
| 810 case PROPERTY_GET: | |
| 811 method_info = property_get_methods_.GetMethod(method_id); | |
| 812 break; | |
| 813 case PROPERTY_SET: | |
| 814 case METHOD_CALL: | |
| 815 break; | |
| 816 } | |
| 817 PLUGIN_PRINTF(("Plugin::GetMethodInfo (id=%"NACL_PRIxPTR", " | |
| 818 "return %p)\n", method_id, static_cast<void*>(method_info))); | |
| 819 return method_info; | |
| 820 } | |
| 821 | |
| 822 // Suggested names for progress event types, per | 736 // Suggested names for progress event types, per |
| 823 // http://www.w3.org/TR/progress-events/ | 737 // http://www.w3.org/TR/progress-events/ |
| 824 const char* const Plugin::kProgressEventLoadStart = "loadstart"; | 738 const char* const Plugin::kProgressEventLoadStart = "loadstart"; |
| 825 const char* const Plugin::kProgressEventProgress = "progress"; | 739 const char* const Plugin::kProgressEventProgress = "progress"; |
| 826 const char* const Plugin::kProgressEventError = "error"; | 740 const char* const Plugin::kProgressEventError = "error"; |
| 827 const char* const Plugin::kProgressEventAbort = "abort"; | 741 const char* const Plugin::kProgressEventAbort = "abort"; |
| 828 const char* const Plugin::kProgressEventLoad = "load"; | 742 const char* const Plugin::kProgressEventLoad = "load"; |
| 829 const char* const Plugin::kProgressEventLoadEnd = "loadend"; | 743 const char* const Plugin::kProgressEventLoadEnd = "loadend"; |
| 830 // Define a NaCl specific event type for .nexe crashes. | 744 // Define a NaCl specific event type for .nexe crashes. |
| 831 const char* const Plugin::kProgressEventCrash = "crash"; | 745 const char* const Plugin::kProgressEventCrash = "crash"; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 | 804 |
| 891 | 805 |
| 892 // All failures of this function will show up as "Missing Plugin-in", so | 806 // All failures of this function will show up as "Missing Plugin-in", so |
| 893 // there is no need to log to JS console that there was an initialization | 807 // there is no need to log to JS console that there was an initialization |
| 894 // failure. Note that module loading functions will log their own errors. | 808 // failure. Note that module loading functions will log their own errors. |
| 895 bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) { | 809 bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) { |
| 896 PLUGIN_PRINTF(("Plugin::Init (argc=%"NACL_PRIu32")\n", argc)); | 810 PLUGIN_PRINTF(("Plugin::Init (argc=%"NACL_PRIu32")\n", argc)); |
| 897 HistogramEnumerateOsArch(GetSandboxISA()); | 811 HistogramEnumerateOsArch(GetSandboxISA()); |
| 898 init_time_ = NaClGetTimeOfDayMicroseconds(); | 812 init_time_ = NaClGetTimeOfDayMicroseconds(); |
| 899 | 813 |
| 900 scoped_ptr<BrowserInterface> browser_interface( | |
| 901 new(std::nothrow) BrowserInterface); | |
| 902 if (browser_interface == NULL) { | |
| 903 return false; | |
| 904 } | |
| 905 ScriptableHandle* handle = ScriptableHandle::NewPlugin(this); | 814 ScriptableHandle* handle = ScriptableHandle::NewPlugin(this); |
| 906 if (handle == NULL) | 815 if (handle == NULL) |
| 907 return false; | 816 return false; |
| 908 | 817 |
| 909 set_scriptable_handle(handle); | 818 set_scriptable_handle(handle); |
| 910 PLUGIN_PRINTF(("Plugin::Init (scriptable_handle=%p)\n", | 819 PLUGIN_PRINTF(("Plugin::Init (scriptable_handle=%p)\n", |
| 911 static_cast<void*>(scriptable_handle()))); | 820 static_cast<void*>(scriptable_handle()))); |
| 912 url_util_ = pp::URLUtil_Dev::Get(); | 821 url_util_ = pp::URLUtil_Dev::Get(); |
| 913 if (url_util_ == NULL) | 822 if (url_util_ == NULL) |
| 914 return false; | 823 return false; |
| 915 | 824 |
| 916 PLUGIN_PRINTF(("Plugin::Init (url_util_=%p)\n", | 825 PLUGIN_PRINTF(("Plugin::Init (url_util_=%p)\n", |
| 917 static_cast<const void*>(url_util_))); | 826 static_cast<const void*>(url_util_))); |
| 918 | 827 |
| 919 bool status = Plugin::Init( | 828 bool status = Plugin::Init( |
| 920 browser_interface.release(), | |
| 921 static_cast<int>(argc), | 829 static_cast<int>(argc), |
| 922 // TODO(polina): Can we change the args on our end to be const to | 830 // TODO(polina): Can we change the args on our end to be const to |
| 923 // avoid these ugly casts? | 831 // avoid these ugly casts? |
| 924 const_cast<char**>(argn), | 832 const_cast<char**>(argn), |
| 925 const_cast<char**>(argv)); | 833 const_cast<char**>(argv)); |
| 926 if (status) { | 834 if (status) { |
| 927 // Look for the developer attribute; if it's present, enable 'dev' | 835 // Look for the developer attribute; if it's present, enable 'dev' |
| 928 // interfaces. | 836 // interfaces. |
| 929 const char* dev_settings = LookupArgument(kDevAttribute); | 837 const char* dev_settings = LookupArgument(kDevAttribute); |
| 930 enable_dev_interfaces_ = (dev_settings != NULL); | 838 enable_dev_interfaces_ = (dev_settings != NULL); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 965 " WARNING: 'nacl' property is incorrect. Use 'src'.\n")); | 873 " WARNING: 'nacl' property is incorrect. Use 'src'.\n")); |
| 966 } | 874 } |
| 967 } else { | 875 } else { |
| 968 // Issue a GET for the manifest_url. The manifest file will be parsed to | 876 // Issue a GET for the manifest_url. The manifest file will be parsed to |
| 969 // determine the nexe URL. | 877 // determine the nexe URL. |
| 970 // Sets src property to full manifest URL. | 878 // Sets src property to full manifest URL. |
| 971 RequestNaClManifest(manifest_url); | 879 RequestNaClManifest(manifest_url); |
| 972 } | 880 } |
| 973 } | 881 } |
| 974 | 882 |
| 975 // Export a property to allow us to get the last error description. | |
| 976 AddPropertyGet(GetLastError, "lastError", "s"); | |
| 977 // Export a property to allow us to get the nexe exit status. | |
| 978 AddPropertyGet(GetExitStatus, "exitStatus", "i"); | |
| 979 | |
| 980 PLUGIN_PRINTF(("Plugin::Init (status=%d)\n", status)); | 883 PLUGIN_PRINTF(("Plugin::Init (status=%d)\n", status)); |
| 981 return status; | 884 return status; |
| 982 } | 885 } |
| 983 | 886 |
| 984 | 887 |
| 985 Plugin::Plugin(PP_Instance pp_instance) | 888 Plugin::Plugin(PP_Instance pp_instance) |
| 986 : pp::InstancePrivate(pp_instance), | 889 : pp::InstancePrivate(pp_instance), |
| 987 browser_interface_(NULL), | |
| 988 scriptable_handle_(NULL), | 890 scriptable_handle_(NULL), |
| 989 argc_(-1), | 891 argc_(-1), |
| 990 argn_(NULL), | 892 argn_(NULL), |
| 991 argv_(NULL), | 893 argv_(NULL), |
| 992 main_subprocess_("main subprocess", NULL, NULL, NULL), | 894 main_subprocess_("main subprocess", NULL, NULL), |
| 993 nacl_ready_state_(UNSENT), | 895 nacl_ready_state_(UNSENT), |
| 994 nexe_error_reported_(false), | 896 nexe_error_reported_(false), |
| 995 wrapper_factory_(NULL), | 897 wrapper_factory_(NULL), |
| 996 last_error_string_(""), | 898 last_error_string_(""), |
| 997 ppapi_proxy_(NULL), | 899 ppapi_proxy_(NULL), |
| 998 enable_dev_interfaces_(false), | 900 enable_dev_interfaces_(false), |
| 999 init_time_(0), | 901 init_time_(0), |
| 1000 ready_time_(0), | 902 ready_time_(0), |
| 1001 nexe_size_(0), | 903 nexe_size_(0), |
| 1002 time_of_last_progress_event_(0) { | 904 time_of_last_progress_event_(0) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1052 // threads. | 954 // threads. |
| 1053 // | 955 // |
| 1054 // The main_subprocess object, which wraps the main service_runtime | 956 // The main_subprocess object, which wraps the main service_runtime |
| 1055 // object, is dtor'd implicitly after the explicit code below runs, | 957 // object, is dtor'd implicitly after the explicit code below runs, |
| 1056 // so the main service runtime object will not have been dtor'd, | 958 // so the main service runtime object will not have been dtor'd, |
| 1057 // though the Shutdown method may have been called, during the | 959 // though the Shutdown method may have been called, during the |
| 1058 // lifetime of the service threads. | 960 // lifetime of the service threads. |
| 1059 ShutDownSubprocesses(); | 961 ShutDownSubprocesses(); |
| 1060 | 962 |
| 1061 delete wrapper_factory_; | 963 delete wrapper_factory_; |
| 1062 delete browser_interface_; | |
| 1063 delete[] argv_; | 964 delete[] argv_; |
| 1064 delete[] argn_; | 965 delete[] argn_; |
| 1065 | 966 |
| 1066 HistogramTimeSmall( | 967 HistogramTimeSmall( |
| 1067 "NaCl.Perf.ShutdownTime.Total", | 968 "NaCl.Perf.ShutdownTime.Total", |
| 1068 (NaClGetTimeOfDayMicroseconds() - shutdown_start) | 969 (NaClGetTimeOfDayMicroseconds() - shutdown_start) |
| 1069 / NACL_MICROS_PER_MILLI); | 970 / NACL_MICROS_PER_MILLI); |
| 1070 | 971 |
| 1071 PLUGIN_PRINTF(("Plugin::~Plugin (this=%p, return)\n", | 972 PLUGIN_PRINTF(("Plugin::~Plugin (this=%p, return)\n", |
| 1072 static_cast<void*>(this))); | 973 static_cast<void*>(this))); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1434 if (nacl_ready_state() == DONE && !nexe_error_reported()) { // After loadEnd. | 1335 if (nacl_ready_state() == DONE && !nexe_error_reported()) { // After loadEnd. |
| 1435 int64_t crash_time = NaClGetTimeOfDayMicroseconds(); | 1336 int64_t crash_time = NaClGetTimeOfDayMicroseconds(); |
| 1436 // Crashes will be more likely near startup, so use a medium histogram | 1337 // Crashes will be more likely near startup, so use a medium histogram |
| 1437 // instead of a large one. | 1338 // instead of a large one. |
| 1438 HistogramTimeMedium( | 1339 HistogramTimeMedium( |
| 1439 "NaCl.ModuleUptime.Crash", | 1340 "NaCl.ModuleUptime.Crash", |
| 1440 (crash_time - ready_time_) / NACL_MICROS_PER_MILLI); | 1341 (crash_time - ready_time_) / NACL_MICROS_PER_MILLI); |
| 1441 | 1342 |
| 1442 nacl::string message = nacl::string("NaCl module crashed"); | 1343 nacl::string message = nacl::string("NaCl module crashed"); |
| 1443 set_last_error_string(message); | 1344 set_last_error_string(message); |
| 1444 browser_interface()->AddToConsole(this, message); | 1345 AddToConsole(message); |
| 1445 | 1346 |
| 1446 EnqueueProgressEvent(kProgressEventCrash); | 1347 EnqueueProgressEvent(kProgressEventCrash); |
| 1447 set_nexe_error_reported(true); | 1348 set_nexe_error_reported(true); |
| 1448 CHECK(ppapi_proxy_ == NULL || !ppapi_proxy_->is_valid()); | 1349 CHECK(ppapi_proxy_ == NULL || !ppapi_proxy_->is_valid()); |
| 1449 ShutdownProxy(); | 1350 ShutdownProxy(); |
| 1450 } | 1351 } |
| 1451 // else ReportLoadError() and ReportAbortError() will be used by loading code | 1352 // else ReportLoadError() and ReportAbortError() will be used by loading code |
| 1452 // to provide error handling and proxy shutdown. | 1353 // to provide error handling and proxy shutdown. |
| 1453 // | 1354 // |
| 1454 // NOTE: not all crashes during load will make it here. | 1355 // NOTE: not all crashes during load will make it here. |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1816 void Plugin::ReportLoadError(const ErrorInfo& error_info) { | 1717 void Plugin::ReportLoadError(const ErrorInfo& error_info) { |
| 1817 PLUGIN_PRINTF(("Plugin::ReportLoadError (error='%s')\n", | 1718 PLUGIN_PRINTF(("Plugin::ReportLoadError (error='%s')\n", |
| 1818 error_info.message().c_str())); | 1719 error_info.message().c_str())); |
| 1819 // Set the readyState attribute to indicate we need to start over. | 1720 // Set the readyState attribute to indicate we need to start over. |
| 1820 set_nacl_ready_state(DONE); | 1721 set_nacl_ready_state(DONE); |
| 1821 set_nexe_error_reported(true); | 1722 set_nexe_error_reported(true); |
| 1822 // Report an error in lastError and on the JavaScript console. | 1723 // Report an error in lastError and on the JavaScript console. |
| 1823 nacl::string message = nacl::string("NaCl module load failed: ") + | 1724 nacl::string message = nacl::string("NaCl module load failed: ") + |
| 1824 error_info.message(); | 1725 error_info.message(); |
| 1825 set_last_error_string(message); | 1726 set_last_error_string(message); |
| 1826 browser_interface()->AddToConsole(this, message); | 1727 AddToConsole(message); |
| 1827 ShutdownProxy(); | 1728 ShutdownProxy(); |
| 1828 // Inform JavaScript that loading encountered an error and is complete. | 1729 // Inform JavaScript that loading encountered an error and is complete. |
| 1829 EnqueueProgressEvent(kProgressEventError); | 1730 EnqueueProgressEvent(kProgressEventError); |
| 1830 EnqueueProgressEvent(kProgressEventLoadEnd); | 1731 EnqueueProgressEvent(kProgressEventLoadEnd); |
| 1831 | 1732 |
| 1832 // UMA | 1733 // UMA |
| 1833 HistogramEnumerateLoadStatus(error_info.error_code()); | 1734 HistogramEnumerateLoadStatus(error_info.error_code()); |
| 1834 } | 1735 } |
| 1835 | 1736 |
| 1836 | 1737 |
| 1837 void Plugin::ReportLoadAbort() { | 1738 void Plugin::ReportLoadAbort() { |
| 1838 PLUGIN_PRINTF(("Plugin::ReportLoadAbort\n")); | 1739 PLUGIN_PRINTF(("Plugin::ReportLoadAbort\n")); |
| 1839 // Set the readyState attribute to indicate we need to start over. | 1740 // Set the readyState attribute to indicate we need to start over. |
| 1840 set_nacl_ready_state(DONE); | 1741 set_nacl_ready_state(DONE); |
| 1841 set_nexe_error_reported(true); | 1742 set_nexe_error_reported(true); |
| 1842 // Report an error in lastError and on the JavaScript console. | 1743 // Report an error in lastError and on the JavaScript console. |
| 1843 nacl::string error_string("NaCl module load failed: user aborted"); | 1744 nacl::string error_string("NaCl module load failed: user aborted"); |
| 1844 set_last_error_string(error_string); | 1745 set_last_error_string(error_string); |
| 1845 browser_interface()->AddToConsole(this, error_string); | 1746 AddToConsole(error_string); |
| 1846 ShutdownProxy(); | 1747 ShutdownProxy(); |
| 1847 // Inform JavaScript that loading was aborted and is complete. | 1748 // Inform JavaScript that loading was aborted and is complete. |
| 1848 EnqueueProgressEvent(kProgressEventAbort); | 1749 EnqueueProgressEvent(kProgressEventAbort); |
| 1849 EnqueueProgressEvent(kProgressEventLoadEnd); | 1750 EnqueueProgressEvent(kProgressEventLoadEnd); |
| 1850 | 1751 |
| 1851 // UMA | 1752 // UMA |
| 1852 HistogramEnumerateLoadStatus(ERROR_LOAD_ABORTED); | 1753 HistogramEnumerateLoadStatus(ERROR_LOAD_ABORTED); |
| 1853 } | 1754 } |
| 1854 | 1755 |
| 1855 void Plugin::UpdateDownloadProgress( | 1756 void Plugin::UpdateDownloadProgress( |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2037 | 1938 |
| 2038 std::string scheme = canonicalized.AsString().substr(comps.scheme.begin, | 1939 std::string scheme = canonicalized.AsString().substr(comps.scheme.begin, |
| 2039 comps.scheme.len); | 1940 comps.scheme.len); |
| 2040 if (scheme == kChromeExtensionUriScheme) | 1941 if (scheme == kChromeExtensionUriScheme) |
| 2041 return SCHEME_CHROME_EXTENSION; | 1942 return SCHEME_CHROME_EXTENSION; |
| 2042 if (scheme == kDataUriScheme) | 1943 if (scheme == kDataUriScheme) |
| 2043 return SCHEME_DATA; | 1944 return SCHEME_DATA; |
| 2044 return SCHEME_OTHER; | 1945 return SCHEME_OTHER; |
| 2045 } | 1946 } |
| 2046 | 1947 |
| 1948 void Plugin::AddToConsole(const nacl::string& text) { | |
| 1949 pp::Module* module = pp::Module::Get(); | |
| 1950 const PPB_Var* var_interface = | |
| 1951 static_cast<const PPB_Var*>( | |
| 1952 module->GetBrowserInterface(PPB_VAR_INTERFACE)); | |
| 1953 nacl::string prefix_string("NativeClient"); | |
| 1954 PP_Var prefix = | |
| 1955 var_interface->VarFromUtf8(prefix_string.c_str(), | |
| 1956 static_cast<uint32_t>(prefix_string.size())); | |
| 1957 PP_Var str = var_interface->VarFromUtf8(text.c_str(), | |
| 1958 static_cast<uint32_t>(text.size())); | |
| 1959 const PPB_Console_Dev* console_interface = | |
| 1960 static_cast<const PPB_Console_Dev*>( | |
| 1961 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)); | |
| 1962 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); | |
| 1963 var_interface->Release(prefix); | |
| 1964 var_interface->Release(str); | |
| 1965 } | |
| 1966 | |
| 2047 } // namespace plugin | 1967 } // namespace plugin |
| OLD | NEW |