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

Unified Diff: ppapi/c/ppb_instance.h

Issue 6538028: A proposal for an initial postMessage interface. This will allow JavaScript ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | ppapi/c/ppp_instance.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/c/ppb_instance.h
===================================================================
--- ppapi/c/ppb_instance.h (revision 75765)
+++ ppapi/c/ppb_instance.h (working copy)
@@ -10,7 +10,7 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
-#define PPB_INSTANCE_INTERFACE "PPB_Instance;0.4"
+#define PPB_INSTANCE_INTERFACE "PPB_Instance;0.5"
/**
* @file
@@ -107,6 +107,44 @@
struct PP_Var (*ExecuteScript)(PP_Instance instance,
struct PP_Var script,
struct PP_Var* exception);
+
+ /**
+ * @a PostMessage asynchronously invokes the onmessage handler on the DOM
polina 2011/03/03 00:22:16 Btw, note that our tech writers are changing all t
+ * element for this module instance, if one exists. @a message is a PP_Var
+ * containing the data to be sent to JavaScript. Currently, it can have an
+ * int32_t, double, bool, or string value (objects are not currently
polina 2011/03/03 00:22:16 Thanks for the helpful clarification. I would say
+ * supported.)
+ *
+ * The onmessage handler in JavaScript code will receive an object conforming
+ * to the MessageEvent interface. In particular, the value of @a message will
+ * be contained as a property called @a data in the received MessageEvent.
+ * This is analogous to listening for messages from Web Workers.
+ *
+ * See:
+ * http://www.whatwg.org/specs/web-workers/current-work/
+ *
+ * For example:
+ *
+ * <body>
+ * <object id="plugin"
+ * type="application/x-ppapi-postMessage-example"/>
+ * <script type="text/javascript">
+ * document.getElementById('plugin').onmessage = function(message) {
+ * alert(message.data);
+ * }
+ * </script>
+ * </body>
+ *
+ * If the module instance then invokes @a PostMessage() as follows:
+ * char hello_world[] = "Hello world!";
+ * PP_Var hello_var = ppb_var_if->VarFromUtf8(instance,
+ * hello_world,
+ * sizeof(hello_world));
+ * the_ppb_instance->PostMessage(instance, hello_var);
+ *
+ * The browser will pop-up an alert saying "Hello world!".
+ */
+ void (*PostMessage)(PP_Instance instance, struct PP_Var message);
};
/**
* @}
« no previous file with comments | « no previous file | ppapi/c/ppp_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698