Chromium Code Reviews

Side by Side Diff: ppapi/c/dev/ppb_messaging_dev.h

Issue 6716005: A proposal and implementation for an initial postMessage interface. These in... (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.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/c/dev/ppp_messaging_dev.h » ('j') | ppapi/cpp/instance.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5 #ifndef PPAPI_C_DEV_PPB_MESSAGING_DEV_H_
6 #define PPAPI_C_DEV_PPB_MESSAGING_DEV_H_
7
8 #include "ppapi/c/pp_instance.h"
9 #include "ppapi/c/pp_var.h"
10
11 #define PPB_MESSAGING_DEV_INTERFACE "PPB_Messaging(Dev);0.1"
12
13 /**
14 * @file
15 * This file defines the PPB_Messaging_Dev interface implemented by the browser.
16 * The PPB_Messaging_Dev interface contains pointers to functions related to
17 * sending messages to the JavaScript onmessage handler on the DOM element
18 * associated with a specific module instance.
19 *
20 * @addtogroup Interfaces
21 * @{
22 */
23
24 /**
25 * The PPB_Messaging_Dev interface contains pointers to functions related to
26 * sending messages to the JavaScript onmessage handler on the DOM element
27 * associated with a specific module instance.
28 */
29 struct PPB_Messaging_Dev {
30 /**
31 * @a PostMessage is a pointer to a function which asynchronously invokes the
32 * onmessage handler on the DOM element for the given module instance, if one
33 * exists. This means that a call to @a PostMessage will not block while the
34 * message is processed.
35 *
36 * @param message is a PP_Var containing the data to be sent to JavaScript.
37 * Currently, it can have an int32_t, double, bool, or string value (objects
38 * are not supported.)
39 *
40 * The onmessage handler in JavaScript code will receive an object conforming
41 * to the MessageEvent interface. In particular, the value of @a message will
42 * be contained as a property called @a data in the received MessageEvent.
43 * This is analogous to listening for messages from Web Workers.
44 *
45 * See:
46 * http://www.whatwg.org/specs/web-workers/current-work/
47 *
48 * For example:
49 *
50 * @verbatim
51 *
52 * <body>
53 * <object id="plugin"
54 * type="application/x-ppapi-postMessage-example"/>
55 * <script type="text/javascript">
56 * document.getElementById('plugin').onmessage = function(message) {
57 * alert(message.data);
58 * }
59 * </script>
60 * </body>
61 *
62 * @endverbatim
63 *
64 * If the module instance then invokes @a PostMessage() as follows:
65 * <code>
66 * char hello_world[] = "Hello world!";
67 * PP_Var hello_var = ppb_var_if->VarFromUtf8(instance,
68 * hello_world,
69 * sizeof(hello_world));
70 * ppb_messaging_if->PostMessage(instance, hello_var);
71 * </code>
72 *
73 * The browser will pop-up an alert saying "Hello world!".
74 */
75 void (*PostMessage)(PP_Instance instance, struct PP_Var message);
76 };
77 /**
78 * @}
79 */
80
81 #endif /* PPAPI_C_DEV_PPB_MESSAGING_DEV_H_ */
82
OLDNEW
« no previous file with comments | « no previous file | ppapi/c/dev/ppp_messaging_dev.h » ('j') | ppapi/cpp/instance.h » ('J')

Powered by Google App Engine