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

Unified Diff: components/nacl/renderer/ppb_nacl_private_impl.cc

Issue 268793002: Pepper: Move DoPostMessage out of trusted plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix threading behavior 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/public/renderer/pepper_plugin_instance.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/nacl/renderer/ppb_nacl_private_impl.cc
diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc
index 3361f61783c86f485bdf6ae9bcb5224e1ec5a44a..43762cebbfae908ca9cf82d3ea997d6c7700965d 100644
--- a/components/nacl/renderer/ppb_nacl_private_impl.cc
+++ b/components/nacl/renderer/ppb_nacl_private_impl.cc
@@ -45,6 +45,7 @@
#include "ppapi/shared_impl/ppapi_permissions.h"
#include "ppapi/shared_impl/ppapi_preferences.h"
#include "ppapi/shared_impl/var.h"
+#include "ppapi/shared_impl/var_tracker.h"
#include "ppapi/thunk/enter.h"
#include "third_party/WebKit/public/platform/WebURLLoader.h"
#include "third_party/WebKit/public/web/WebDocument.h"
@@ -1232,6 +1233,25 @@ PP_Var GetCpuFeatureAttrs() {
attrs.begin(), attrs.end(), std::string(), CommaAccumulator));
}
+void PostMessageToJavaScriptMainThread(PP_Instance instance,
+ const std::string& message) {
+ content::PepperPluginInstance* plugin_instance =
+ content::PepperPluginInstance::Get(instance);
+ if (plugin_instance) {
+ PP_Var message_var = ppapi::StringVar::StringToPPVar(message);
+ plugin_instance->PostMessageToJavaScript(message_var);
+ ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(message_var);
+ }
+}
+
+void PostMessageToJavaScript(PP_Instance instance, const char* message) {
+ ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
+ FROM_HERE,
+ base::Bind(&PostMessageToJavaScriptMainThread,
+ instance,
+ std::string(message)));
+}
+
const PPB_NaCl_Private nacl_interface = {
&LaunchSelLdr,
&StartPpapiProxy,
@@ -1278,7 +1298,8 @@ const PPB_NaCl_Private nacl_interface = {
&ManifestGetProgramURL,
&ManifestResolveKey,
&GetPNaClResourceInfo,
- &GetCpuFeatureAttrs
+ &GetCpuFeatureAttrs,
+ &PostMessageToJavaScript
};
} // namespace
« no previous file with comments | « no previous file | content/public/renderer/pepper_plugin_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698