Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: ppapi/native_client/src/trusted/plugin/service_runtime.cc

Issue 268793002: Pepper: Move DoPostMessage out of trusted plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 15 matching lines...) Expand all
26 #include "native_client/src/shared/platform/nacl_sync.h" 26 #include "native_client/src/shared/platform/nacl_sync.h"
27 #include "native_client/src/shared/platform/nacl_sync_checked.h" 27 #include "native_client/src/shared/platform/nacl_sync_checked.h"
28 #include "native_client/src/shared/platform/nacl_sync_raii.h" 28 #include "native_client/src/shared/platform/nacl_sync_raii.h"
29 #include "native_client/src/shared/platform/scoped_ptr_refcount.h" 29 #include "native_client/src/shared/platform/scoped_ptr_refcount.h"
30 #include "native_client/src/trusted/desc/nacl_desc_imc.h" 30 #include "native_client/src/trusted/desc/nacl_desc_imc.h"
31 // remove when we no longer need to cast the DescWrapper below. 31 // remove when we no longer need to cast the DescWrapper below.
32 #include "native_client/src/trusted/desc/nacl_desc_io.h" 32 #include "native_client/src/trusted/desc/nacl_desc_io.h"
33 #include "native_client/src/trusted/desc/nrd_xfer.h" 33 #include "native_client/src/trusted/desc/nrd_xfer.h"
34 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" 34 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h"
35 35
36 // This is here due to a Windows API collision; plugin.h through
37 // file_downloader.h transitively includes Instance.h which defines a
38 // PostMessage method, so this undef must appear before any of those.
39 #ifdef PostMessage
40 #undef PostMessage
41 #endif
42 #include "native_client/src/public/imc_types.h" 36 #include "native_client/src/public/imc_types.h"
43 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" 37 #include "native_client/src/trusted/service_runtime/nacl_error_code.h"
44 #include "native_client/src/trusted/validator/nacl_file_info.h" 38 #include "native_client/src/trusted/validator/nacl_file_info.h"
45 39
46 #include "ppapi/c/pp_errors.h" 40 #include "ppapi/c/pp_errors.h"
47 #include "ppapi/cpp/core.h" 41 #include "ppapi/cpp/core.h"
48 #include "ppapi/cpp/completion_callback.h" 42 #include "ppapi/cpp/completion_callback.h"
49 43
50 #include "ppapi/native_client/src/trusted/plugin/plugin.h" 44 #include "ppapi/native_client/src/trusted/plugin/plugin.h"
51 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" 45 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h"
52 #include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h" 46 #include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h"
53 #include "ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h" 47 #include "ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h"
54 #include "ppapi/native_client/src/trusted/plugin/srpc_client.h" 48 #include "ppapi/native_client/src/trusted/plugin/srpc_client.h"
49 #include "ppapi/native_client/src/trusted/plugin/utility.h"
55 #include "ppapi/native_client/src/trusted/weak_ref/call_on_main_thread.h" 50 #include "ppapi/native_client/src/trusted/weak_ref/call_on_main_thread.h"
56 51
57 namespace plugin { 52 namespace plugin {
58 53
59 class OpenManifestEntryAsyncCallback { 54 class OpenManifestEntryAsyncCallback {
60 public: 55 public:
61 OpenManifestEntryAsyncCallback(PP_OpenResourceCompletionCallback callback, 56 OpenManifestEntryAsyncCallback(PP_OpenResourceCompletionCallback callback,
62 void* callback_user_data) 57 void* callback_user_data)
63 : callback_(callback), callback_user_data_(callback_user_data) { 58 : callback_(callback), callback_user_data_(callback_user_data) {
64 } 59 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 214
220 void PluginReverseInterface::ShutDown() { 215 void PluginReverseInterface::ShutDown() {
221 NaClLog(4, "PluginReverseInterface::Shutdown: entered\n"); 216 NaClLog(4, "PluginReverseInterface::Shutdown: entered\n");
222 nacl::MutexLocker take(&mu_); 217 nacl::MutexLocker take(&mu_);
223 shutting_down_ = true; 218 shutting_down_ = true;
224 NaClXCondVarBroadcast(&cv_); 219 NaClXCondVarBroadcast(&cv_);
225 NaClLog(4, "PluginReverseInterface::Shutdown: broadcasted, exiting\n"); 220 NaClLog(4, "PluginReverseInterface::Shutdown: broadcasted, exiting\n");
226 } 221 }
227 222
228 void PluginReverseInterface::DoPostMessage(nacl::string message) { 223 void PluginReverseInterface::DoPostMessage(nacl::string message) {
229 PostMessageResource* continuation = new PostMessageResource(message); 224 GetNaClInterface()->PostMessageToJavaScript(plugin_->pp_instance(),
230 CHECK(continuation != NULL); 225 message.c_str());
231 NaClLog(4, "PluginReverseInterface::DoPostMessage(%s)\n", message.c_str());
232 plugin::WeakRefCallOnMainThread(
233 anchor_,
234 0, /* delay in ms */
235 this,
236 &plugin::PluginReverseInterface::PostMessage_MainThreadContinuation,
237 continuation);
238 } 226 }
239 227
240 void PluginReverseInterface::StartupInitializationComplete() { 228 void PluginReverseInterface::StartupInitializationComplete() {
241 NaClLog(4, "PluginReverseInterface::StartupInitializationComplete\n"); 229 NaClLog(4, "PluginReverseInterface::StartupInitializationComplete\n");
242 if (init_done_cb_.pp_completion_callback().func != NULL) { 230 if (init_done_cb_.pp_completion_callback().func != NULL) {
243 NaClLog(4, 231 NaClLog(4,
244 "PluginReverseInterface::StartupInitializationComplete:" 232 "PluginReverseInterface::StartupInitializationComplete:"
245 " invoking CB\n"); 233 " invoking CB\n");
246 pp::Module::Get()->core()->CallOnMainThread(0, init_done_cb_, PP_OK); 234 pp::Module::Get()->core()->CallOnMainThread(0, init_done_cb_, PP_OK);
247 } else { 235 } else {
248 NaClLog(1, 236 NaClLog(1,
249 "PluginReverseInterface::StartupInitializationComplete:" 237 "PluginReverseInterface::StartupInitializationComplete:"
250 " init_done_cb_ not valid, skipping.\n"); 238 " init_done_cb_ not valid, skipping.\n");
251 } 239 }
252 } 240 }
253 241
254 void PluginReverseInterface::PostMessage_MainThreadContinuation(
255 PostMessageResource* p,
256 int32_t err) {
257 UNREFERENCED_PARAMETER(err);
258 NaClLog(4,
259 "PluginReverseInterface::PostMessage_MainThreadContinuation(%s)\n",
260 p->message.c_str());
261 plugin_->PostMessage(std::string("DEBUG_POSTMESSAGE:") + p->message);
262 }
263
264 // TODO(bsy): OpenManifestEntry should use the manifest to ResolveKey 242 // TODO(bsy): OpenManifestEntry should use the manifest to ResolveKey
265 // and invoke StreamAsFile with a completion callback that invokes 243 // and invoke StreamAsFile with a completion callback that invokes
266 // GetPOSIXFileDesc. 244 // GetPOSIXFileDesc.
267 bool PluginReverseInterface::OpenManifestEntry(nacl::string url_key, 245 bool PluginReverseInterface::OpenManifestEntry(nacl::string url_key,
268 struct NaClFileInfo* info) { 246 struct NaClFileInfo* info) {
269 bool op_complete = false; // NB: mu_ and cv_ also controls access to this! 247 bool op_complete = false; // NB: mu_ and cv_ also controls access to this!
270 // The to_open object is owned by the weak ref callback. Because this function 248 // The to_open object is owned by the weak ref callback. Because this function
271 // waits for the callback to finish, the to_open object will be deallocated on 249 // waits for the callback to finish, the to_open object will be deallocated on
272 // the main thread before this function can return. The pointers it contains 250 // the main thread before this function can return. The pointers it contains
273 // to stack variables will not leak. 251 // to stack variables will not leak.
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 876
899 nacl::string ServiceRuntime::GetCrashLogOutput() { 877 nacl::string ServiceRuntime::GetCrashLogOutput() {
900 if (NULL != subprocess_.get()) { 878 if (NULL != subprocess_.get()) {
901 return subprocess_->GetCrashLogOutput(); 879 return subprocess_->GetCrashLogOutput();
902 } else { 880 } else {
903 return std::string(); 881 return std::string();
904 } 882 }
905 } 883 }
906 884
907 } // namespace plugin 885 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698