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

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, 9 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') | ppapi/cpp/instance.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/c/ppb_instance.h
===================================================================
--- ppapi/c/ppb_instance.h (revision 77426)
+++ ppapi/c/ppb_instance.h (working copy)
@@ -10,8 +10,11 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
-#define PPB_INSTANCE_INTERFACE "PPB_Instance;0.4"
+#define PPB_INSTANCE_INTERFACE_0_4 "PPB_Instance;0.4"
+#define PPB_INSTANCE_INTERFACE_0_5 "PPB_Instance;0.5"
+#define PPB_INSTANCE_INTERFACE PPB_INSTANCE_INTERFACE_0_5
+
/**
* @file
* This file defines the PPB_Instance interface implemented by the
@@ -107,6 +110,50 @@
struct PP_Var (*ExecuteScript)(PP_Instance instance,
struct PP_Var script,
struct PP_Var* exception);
+
+ /**
+ * @a PostMessage is a pointer to a function which asynchronously invokes th
brettw 2011/03/16 21:34:11 th -> the
dmichael(do not use this one) 2011/03/21 21:43:35 Done.
+ * onmessage handler on the DOM 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 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:
+ *
+ * \verbatim
+ *
+ * <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>
+ *
+ * \endverbatim
+ *
+ * If the module instance then invokes @a PostMessage() as follows:
+ * <code>
+ * 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);
+ * </code>
+ *
+ * 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') | ppapi/cpp/instance.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698