Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2011 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 "native_client/src/trusted/plugin/service_runtime.h" | 9 #include "native_client/src/trusted/plugin/service_runtime.h" |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 | 44 |
| 45 #include "native_client/src/trusted/weak_ref/call_on_main_thread.h" | 45 #include "native_client/src/trusted/weak_ref/call_on_main_thread.h" |
| 46 | 46 |
| 47 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" | 47 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" |
| 48 #include "native_client/src/trusted/service_runtime/include/sys/nacl_imc_api.h" | 48 #include "native_client/src/trusted/service_runtime/include/sys/nacl_imc_api.h" |
| 49 | 49 |
| 50 #include "ppapi/c/pp_errors.h" | 50 #include "ppapi/c/pp_errors.h" |
| 51 #include "ppapi/cpp/core.h" | 51 #include "ppapi/cpp/core.h" |
| 52 #include "ppapi/cpp/completion_callback.h" | 52 #include "ppapi/cpp/completion_callback.h" |
| 53 | 53 |
| 54 // This is here due to a Windows API collision. | |
| 55 #ifdef PostMessage | |
| 56 #undef PostMessage | |
| 57 #endif | |
|
dmichael (off chromium)
2011/12/07 19:02:13
Wouldn't it have worked to just move this above th
bsy
2011/12/07 21:18:32
you were looking at an old change set. this chang
| |
| 58 | |
| 54 using std::vector; | 59 using std::vector; |
| 55 | 60 |
| 56 namespace plugin { | 61 namespace plugin { |
| 57 | 62 |
| 58 PluginReverseInterface::PluginReverseInterface( | 63 PluginReverseInterface::PluginReverseInterface( |
| 59 nacl::WeakRefAnchor* anchor, | 64 nacl::WeakRefAnchor* anchor, |
| 60 Plugin* plugin, | 65 Plugin* plugin, |
| 61 ServiceRuntime* service_runtime, | 66 ServiceRuntime* service_runtime, |
| 62 pp::CompletionCallback init_done_cb, | 67 pp::CompletionCallback init_done_cb, |
| 63 pp::CompletionCallback crash_cb) | 68 pp::CompletionCallback crash_cb) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 90 CHECK(continuation != NULL); | 95 CHECK(continuation != NULL); |
| 91 NaClLog(4, "PluginReverseInterface::Log(%s)\n", message.c_str()); | 96 NaClLog(4, "PluginReverseInterface::Log(%s)\n", message.c_str()); |
| 92 plugin::WeakRefCallOnMainThread( | 97 plugin::WeakRefCallOnMainThread( |
| 93 anchor_, | 98 anchor_, |
| 94 0, /* delay in ms */ | 99 0, /* delay in ms */ |
| 95 ALLOW_THIS_IN_INITIALIZER_LIST(this), | 100 ALLOW_THIS_IN_INITIALIZER_LIST(this), |
| 96 &plugin::PluginReverseInterface::Log_MainThreadContinuation, | 101 &plugin::PluginReverseInterface::Log_MainThreadContinuation, |
| 97 continuation); | 102 continuation); |
| 98 } | 103 } |
| 99 | 104 |
| 105 void PluginReverseInterface::DoPostMessage(nacl::string message) { | |
| 106 PostMessageResource* continuation = new PostMessageResource(message); | |
| 107 CHECK(continuation != NULL); | |
| 108 NaClLog(4, "PluginReverseInterface::DoPostMessage(%s)\n", message.c_str()); | |
| 109 plugin::WeakRefCallOnMainThread( | |
| 110 anchor_, | |
| 111 0, /* delay in ms */ | |
| 112 ALLOW_THIS_IN_INITIALIZER_LIST(this), | |
| 113 &plugin::PluginReverseInterface::PostMessage_MainThreadContinuation, | |
| 114 continuation); | |
| 115 } | |
| 116 | |
| 100 void PluginReverseInterface::StartupInitializationComplete() { | 117 void PluginReverseInterface::StartupInitializationComplete() { |
| 101 NaClLog(0, "PluginReverseInterface::StartupInitializationComplete\n"); | 118 NaClLog(0, "PluginReverseInterface::StartupInitializationComplete\n"); |
| 102 if (init_done_cb_.pp_completion_callback().func != NULL) { | 119 if (init_done_cb_.pp_completion_callback().func != NULL) { |
| 103 NaClLog(0, | 120 NaClLog(0, |
| 104 "PluginReverseInterface::StartupInitializationComplete:" | 121 "PluginReverseInterface::StartupInitializationComplete:" |
| 105 " invoking CB\n"); | 122 " invoking CB\n"); |
| 106 pp::Module::Get()->core()->CallOnMainThread(0, init_done_cb_, PP_OK); | 123 pp::Module::Get()->core()->CallOnMainThread(0, init_done_cb_, PP_OK); |
| 107 } else { | 124 } else { |
| 108 NaClLog(0, | 125 NaClLog(0, |
| 109 "PluginReverseInterface::StartupInitializationComplete:" | 126 "PluginReverseInterface::StartupInitializationComplete:" |
| 110 " init_done_cb_ not valid, skipping.\n"); | 127 " init_done_cb_ not valid, skipping.\n"); |
| 111 } | 128 } |
| 112 } | 129 } |
| 113 | 130 |
| 114 void PluginReverseInterface::Log_MainThreadContinuation( | 131 void PluginReverseInterface::Log_MainThreadContinuation( |
| 115 LogToJavaScriptConsoleResource* p, | 132 LogToJavaScriptConsoleResource* p, |
| 116 int32_t err) { | 133 int32_t err) { |
| 117 UNREFERENCED_PARAMETER(err); | 134 UNREFERENCED_PARAMETER(err); |
| 118 NaClLog(4, | 135 NaClLog(4, |
| 119 "PluginReverseInterface::Log_MainThreadContinuation(%s)\n", | 136 "PluginReverseInterface::Log_MainThreadContinuation(%s)\n", |
| 120 p->message.c_str()); | 137 p->message.c_str()); |
| 121 plugin_->browser_interface()->AddToConsole(static_cast<Plugin*>(plugin_), | 138 plugin_->browser_interface()->AddToConsole(static_cast<Plugin*>(plugin_), |
| 122 p->message); | 139 p->message); |
| 123 } | 140 } |
| 141 void PluginReverseInterface::PostMessage_MainThreadContinuation( | |
| 142 PostMessageResource* p, | |
| 143 int32_t err) { | |
| 144 UNREFERENCED_PARAMETER(err); | |
| 145 NaClLog(4, | |
| 146 "PluginReverseInterface::PostMessage_MainThreadContinuation(%s)\n", | |
| 147 p->message.c_str()); | |
| 148 plugin_->PostMessage(std::string("DEBUG_POSTMESSAGE:") + p->message); | |
| 149 } | |
| 124 | 150 |
| 125 bool PluginReverseInterface::EnumerateManifestKeys( | 151 bool PluginReverseInterface::EnumerateManifestKeys( |
| 126 std::set<nacl::string>* out_keys) { | 152 std::set<nacl::string>* out_keys) { |
| 127 Manifest const* mp = plugin_->manifest(); | 153 Manifest const* mp = plugin_->manifest(); |
| 128 | 154 |
| 129 if (!mp->GetFileKeys(out_keys)) { | 155 if (!mp->GetFileKeys(out_keys)) { |
| 130 return false; | 156 return false; |
| 131 } | 157 } |
| 132 | 158 |
| 133 return true; | 159 return true; |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 nacl::MutexLocker take(&mu_); | 606 nacl::MutexLocker take(&mu_); |
| 581 return exit_status_; | 607 return exit_status_; |
| 582 } | 608 } |
| 583 | 609 |
| 584 void ServiceRuntime::set_exit_status(int exit_status) { | 610 void ServiceRuntime::set_exit_status(int exit_status) { |
| 585 nacl::MutexLocker take(&mu_); | 611 nacl::MutexLocker take(&mu_); |
| 586 exit_status_ = exit_status & 0xff; | 612 exit_status_ = exit_status & 0xff; |
| 587 } | 613 } |
| 588 | 614 |
| 589 } // namespace plugin | 615 } // namespace plugin |
| OLD | NEW |