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

Issue 6538028: A proposal for an initial postMessage interface. This will allow JavaScript ... (Closed)

Created:
9 years, 10 months ago by dmichael(do not use this one)
Modified:
9 years, 7 months ago
CC:
chromium-reviews, piman+watch_chromium.org
Visibility:
Public.

Description

Based on Neb's suggestion to take these functions out of the interface, I started a new CL: http://codereview.chromium.org/6716005/ A proposal and implementation for an initial postMessage interface. This will allow JavaScript to send data asynchronously to a module, and the module to asynchronously send data to a JavaScript message handler. This also adds (in an admittedly unsophisticated way) backwards compatibility so that existing apps & plugins should still function with ToT Chrome, and should also compile & work without code changes when DEPSing the latest in. Overview: From JavaScript, you can invoke 'postMessage' on the embedded module. That results in a call to 'PPP_Instance::HandleMessage'. From Native Code, you can invoke 'PPB_Instance::PostMessage', which results in a call to an 'onmessage' function on the embedded module in the JavaScript code (if one has been registered). Please see the examples in PPP_Instance and PPB_Instance. Restrictions: The first implementation will support only intrinsic values and strings (all types that PP_Var supports except for objects). Sending more complex data will require packaging it in to a string first (e.g., via JSON). In a future version, I would like to add support for structured data via the structured clone algorithm. I have ideas about how the data would be sent, but it will be a lot more complex than this initial proposal. This also does not support MessagePorts. Those might be desirable in the future, but they are not necessary for a first implementation. BUG=None TEST=test_post_message.h/.cc, manually testing of existing NaCl SDK & Gallery examples to check backwards compatibility.

Patch Set 1 : '' #

Total comments: 17

Patch Set 2 : '' #

Total comments: 4

Patch Set 3 : '' #

Total comments: 23

Patch Set 4 : '' #

Total comments: 2

Patch Set 5 : '' #

Total comments: 4

Patch Set 6 : '' #

Total comments: 11
Unified diffs Side-by-side diffs Delta from patch set Stats (+1028 lines, -43 lines) Patch
M ppapi/c/ppb_instance.h View 1 2 3 4 5 2 chunks +48 lines, -1 line 2 comments Download
M ppapi/c/ppp_instance.h View 1 2 3 4 5 2 chunks +49 lines, -3 lines 0 comments Download
M ppapi/cpp/instance.h View 1 2 3 4 5 3 chunks +7 lines, -1 line 1 comment Download
M ppapi/cpp/instance.cc View 1 2 3 4 5 2 chunks +10 lines, -0 lines 0 comments Download
M ppapi/cpp/module.cc View 1 2 3 4 5 3 chunks +13 lines, -2 lines 0 comments Download
A ppapi/examples/scripting/post_message.cc View 1 2 3 4 5 1 chunk +57 lines, -0 lines 0 comments Download
A ppapi/examples/scripting/post_message.html View 1 2 3 4 5 1 chunk +37 lines, -0 lines 0 comments Download
M ppapi/ppapi_tests.gypi View 1 2 3 4 5 2 chunks +11 lines, -0 lines 0 comments Download
M ppapi/tests/test_case.h View 1 2 3 4 5 4 chunks +17 lines, -5 lines 1 comment Download
M ppapi/tests/test_case.cc View 1 2 3 4 5 2 chunks +3 lines, -1 line 0 comments Download
A ppapi/tests/test_post_message.h View 1 2 3 4 1 chunk +53 lines, -0 lines 1 comment Download
A ppapi/tests/test_post_message.cc View 1 2 3 4 1 chunk +163 lines, -0 lines 0 comments Download
M ppapi/tests/testing_instance.h View 1 2 3 4 5 4 chunks +12 lines, -5 lines 2 comments Download
M ppapi/tests/testing_instance.cc View 1 2 3 4 5 5 chunks +12 lines, -7 lines 0 comments Download
M webkit/glue/webkit_glue.gypi View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
A webkit/plugins/ppapi/message_channel.h View 1 2 3 4 1 chunk +81 lines, -0 lines 0 comments Download
A webkit/plugins/ppapi/message_channel.cc View 1 2 3 4 1 chunk +343 lines, -0 lines 1 comment Download
M webkit/plugins/ppapi/plugin_module.cc View 1 2 3 4 5 3 chunks +25 lines, -5 lines 2 comments Download
M webkit/plugins/ppapi/ppapi_plugin_instance.h View 1 2 3 4 5 7 chunks +23 lines, -2 lines 0 comments Download
M webkit/plugins/ppapi/ppapi_plugin_instance.cc View 1 2 3 4 5 8 chunks +44 lines, -5 lines 0 comments Download
M webkit/plugins/ppapi/ppapi_unittest.cc View 1 2 3 4 5 3 chunks +8 lines, -2 lines 0 comments Download
M webkit/plugins/ppapi/ppapi_webplugin_impl.cc View 1 2 3 4 5 2 chunks +6 lines, -2 lines 1 comment Download
M webkit/plugins/ppapi/resource_tracker_unittest.cc View 1 2 3 4 5 2 chunks +4 lines, -2 lines 0 comments Download

Messages

Total messages: 40 (0 generated)
Mark Seaborn
http://codereview.chromium.org/6538028/diff/2002/ppapi/c/dev/pp_message_event_dev.h File ppapi/c/dev/pp_message_event_dev.h (right): http://codereview.chromium.org/6538028/diff/2002/ppapi/c/dev/pp_message_event_dev.h#newcode19 ppapi/c/dev/pp_message_event_dev.h:19: * instrinsic type or string (but not structured data ...
9 years, 10 months ago (2011-02-17 19:18:47 UTC) #1
darin (slow to review)
Thanks for putting this together. I've dumped some counter proposal ideas below. http://codereview.chromium.org/6538028/diff/2002/ppapi/c/dev/pp_message_event_dev.h File ppapi/c/dev/pp_message_event_dev.h ...
9 years, 10 months ago (2011-02-17 19:20:52 UTC) #2
darin (slow to review)
On Thu, Feb 17, 2011 at 11:20 AM, <darin@chromium.org> wrote: > Thanks for putting this ...
9 years, 10 months ago (2011-02-17 19:27:30 UTC) #3
dmichael(do not use this one)
Some counterpoint. I'm not averse to doing MessagePort, I was just trying to defer it ...
9 years, 10 months ago (2011-02-17 20:06:42 UTC) #4
dmichael(do not use this one)
http://codereview.chromium.org/6538028/diff/2002/ppapi/c/dev/pp_message_event_dev.h File ppapi/c/dev/pp_message_event_dev.h (right): http://codereview.chromium.org/6538028/diff/2002/ppapi/c/dev/pp_message_event_dev.h#newcode19 ppapi/c/dev/pp_message_event_dev.h:19: * instrinsic type or string (but not structured data ...
9 years, 10 months ago (2011-02-17 20:07:03 UTC) #5
brettw
http://codereview.chromium.org/6538028/diff/2002/ppapi/c/dev/pp_message_event_dev.h File ppapi/c/dev/pp_message_event_dev.h (right): http://codereview.chromium.org/6538028/diff/2002/ppapi/c/dev/pp_message_event_dev.h#newcode61 ppapi/c/dev/pp_message_event_dev.h:61: struct PP_Var source; Yeah, I would probably just delete ...
9 years, 10 months ago (2011-02-17 20:40:01 UTC) #6
dmichael(do not use this one)
I fixed a couple little things based on the feedback so far. http://codereview.chromium.org/6538028/diff/2002/ppapi/c/dev/pp_message_event_dev.h File ppapi/c/dev/pp_message_event_dev.h ...
9 years, 10 months ago (2011-02-17 22:18:22 UTC) #7
brettw
LGTM. We should probably check that Darin is happy with the overall direction before checking ...
9 years, 10 months ago (2011-02-21 04:58:29 UTC) #8
dmichael(do not use this one)
I'll wait for Darin to comment, and I'll look in to the struct-owning-PP_Var thing. I'd ...
9 years, 10 months ago (2011-02-22 15:24:20 UTC) #9
brettw
On Tue, Feb 22, 2011 at 7:22 AM, David Michael <dmichael@google.com> wrote: > I'll wait ...
9 years, 10 months ago (2011-02-22 16:10:37 UTC) #10
darin (slow to review)
I'm concerned that PostMessage needs to pass both target and source origins since the non-NaCl ...
9 years, 10 months ago (2011-02-23 06:32:27 UTC) #11
darin (slow to review)
Please keep in mind that we want to allow NEXEs to be loaded cross-origin (subject ...
9 years, 10 months ago (2011-02-23 06:39:03 UTC) #12
darin (slow to review)
On 2011/02/17 20:40:01, brettw wrote: > http://codereview.chromium.org/6538028/diff/2002/ppapi/c/dev/pp_message_event_dev.h > File ppapi/c/dev/pp_message_event_dev.h (right): > > http://codereview.chromium.org/6538028/diff/2002/ppapi/c/dev/pp_message_event_dev.h#newcode61 > ...
9 years, 10 months ago (2011-02-23 06:42:04 UTC) #13
Mark Seaborn
On 22 February 2011 22:39, <darin@chromium.org> wrote: > Please keep in mind that we want ...
9 years, 10 months ago (2011-02-23 07:04:56 UTC) #14
darin (slow to review)
On Tue, Feb 22, 2011 at 11:04 PM, Mark Seaborn <mseaborn@chromium.org>wrote: > On 22 February ...
9 years, 10 months ago (2011-02-23 08:22:46 UTC) #15
darin (slow to review)
OK, I've convinced myself that the argument I was making is bogus :-) Here's the ...
9 years, 10 months ago (2011-02-23 18:09:28 UTC) #16
dmichael(do not use this one)
On Wed, Feb 23, 2011 at 11:09 AM, Darin Fisher <darin@chromium.org> wrote: > OK, I've ...
9 years, 10 months ago (2011-02-23 18:36:27 UTC) #17
darin (slow to review)
On Wed, Feb 23, 2011 at 10:33 AM, David Michael <dmichael@google.com> wrote: > > > ...
9 years, 10 months ago (2011-02-23 21:00:54 UTC) #18
dmichael(do not use this one)
Okay, one more try. This changes the PP_MessageEvent argument to just a PP_Var, since we ...
9 years, 10 months ago (2011-02-23 22:16:49 UTC) #19
darin (slow to review)
LGTM http://codereview.chromium.org/6538028/diff/19001/ppapi/c/ppp_instance.h File ppapi/c/ppp_instance.h (right): http://codereview.chromium.org/6538028/diff/19001/ppapi/c/ppp_instance.h#newcode175 ppapi/c/ppp_instance.h:175: struct PP_Var (*GetInstanceObject)(PP_Instance instance); I think now is ...
9 years, 10 months ago (2011-02-23 22:36:46 UTC) #20
dmichael(do not use this one)
Terrific, thank you all for the great comments! http://codereview.chromium.org/6538028/diff/19001/ppapi/c/ppp_instance.h File ppapi/c/ppp_instance.h (right): http://codereview.chromium.org/6538028/diff/19001/ppapi/c/ppp_instance.h#newcode175 ppapi/c/ppp_instance.h:175: struct ...
9 years, 10 months ago (2011-02-23 22:45:00 UTC) #21
darin (slow to review)
On Wed, Feb 23, 2011 at 2:45 PM, <dmichael@google.com> wrote: > Terrific, thank you all ...
9 years, 10 months ago (2011-02-23 22:51:06 UTC) #22
polina
http://codereview.chromium.org/6538028/diff/17003/ppapi/c/ppb_instance.h File ppapi/c/ppb_instance.h (right): http://codereview.chromium.org/6538028/diff/17003/ppapi/c/ppb_instance.h#newcode112 ppapi/c/ppb_instance.h:112: * PostMessage asynchronously invokes the onmessage handler of the ...
9 years, 10 months ago (2011-02-26 08:00:08 UTC) #23
brettw
http://codereview.chromium.org/6538028/diff/17003/ppapi/c/ppp_instance.h File ppapi/c/ppp_instance.h (right): http://codereview.chromium.org/6538028/diff/17003/ppapi/c/ppp_instance.h#newcode194 ppapi/c/ppp_instance.h:194: void (*HandleMessage)(PP_Instance instance, struct PP_Var message); We decided not ...
9 years, 10 months ago (2011-02-26 17:11:17 UTC) #24
polina
http://codereview.chromium.org/6538028/diff/17003/ppapi/c/ppp_instance.h File ppapi/c/ppp_instance.h (right): http://codereview.chromium.org/6538028/diff/17003/ppapi/c/ppp_instance.h#newcode194 ppapi/c/ppp_instance.h:194: void (*HandleMessage)(PP_Instance instance, struct PP_Var message); On 2011/02/26 17:11:17, ...
9 years, 10 months ago (2011-02-26 20:06:36 UTC) #25
dmichael(do not use this one)
I really want to keep the 'onmessage' name in the JavaScript side, at least. If ...
9 years, 10 months ago (2011-02-27 02:10:39 UTC) #26
darin (slow to review)
Ditto. -Darin On Sat, Feb 26, 2011 at 6:10 PM, David Michael <dmichael@google.com> wrote: > ...
9 years, 10 months ago (2011-02-27 03:27:26 UTC) #27
darin (slow to review)
Er, I mean... I agree with your argument for onmessage, but I also feel strongly ...
9 years, 10 months ago (2011-02-27 03:28:19 UTC) #28
dmichael(do not use this one)
Tweaked to address some of Polina's comments. http://codereview.chromium.org/6538028/diff/17003/ppapi/c/ppb_instance.h File ppapi/c/ppb_instance.h (right): http://codereview.chromium.org/6538028/diff/17003/ppapi/c/ppb_instance.h#newcode112 ppapi/c/ppb_instance.h:112: * PostMessage ...
9 years, 9 months ago (2011-02-28 15:59:28 UTC) #29
polina
http://codereview.chromium.org/6538028/diff/17003/ppapi/c/ppb_instance.h File ppapi/c/ppb_instance.h (right): http://codereview.chromium.org/6538028/diff/17003/ppapi/c/ppb_instance.h#newcode130 ppapi/c/ppb_instance.h:130: * If the module then invokes PostMessage as follows: ...
9 years, 9 months ago (2011-03-03 00:22:15 UTC) #30
Mark Seaborn
dmichael wrote: > A proposal for an initial postMessage interface. This will allow JavaScript > ...
9 years, 9 months ago (2011-03-04 19:59:09 UTC) #31
sehr (please use chromium)
One typo, one question. http://codereview.chromium.org/6538028/diff/45005/ppapi/cpp/instance.h File ppapi/cpp/instance.h (right): http://codereview.chromium.org/6538028/diff/45005/ppapi/cpp/instance.h#newcode75 ppapi/cpp/instance.h:75: /** See PPP_Instance.HandleEvent. */ s/Event/Message/ ...
9 years, 9 months ago (2011-03-14 23:47:46 UTC) #32
dmichael(do not use this one)
I think the implementation is ready for review. Thanks for looking! http://codereview.chromium.org/6538028/diff/45005/ppapi/cpp/instance.h File ppapi/cpp/instance.h (right): ...
9 years, 9 months ago (2011-03-16 21:08:48 UTC) #33
brettw
I didn't check all the bindings, neb may be the best person do to that. ...
9 years, 9 months ago (2011-03-16 21:34:11 UTC) #34
neb
Jumping in late, my main concern is with sticking this in the catch-all PPB_Instance. This ...
9 years, 9 months ago (2011-03-16 21:41:22 UTC) #35
polina
I agree with Neb. I have also been wondering why we were extending *_Instance interfaces. ...
9 years, 9 months ago (2011-03-17 02:40:26 UTC) #36
polina
http://codereview.chromium.org/6538028/diff/54012/ppapi/cpp/instance.h File ppapi/cpp/instance.h (right): http://codereview.chromium.org/6538028/diff/54012/ppapi/cpp/instance.h#newcode76 ppapi/cpp/instance.h:76: virtual void HandleMessage(const Var& message_data); This is called |message| ...
9 years, 9 months ago (2011-03-17 02:59:28 UTC) #37
dmichael(do not use this one)
On 2011/03/17 02:40:26, polina wrote: > I agree with Neb. I have also been wondering ...
9 years, 9 months ago (2011-03-17 14:41:57 UTC) #38
brettw
On Thu, Mar 17, 2011 at 7:41 AM, <dmichael@google.com> wrote: > On 2011/03/17 02:40:26, polina ...
9 years, 9 months ago (2011-03-17 16:13:46 UTC) #39
dmichael(do not use this one)
9 years, 9 months ago (2011-03-21 21:43:35 UTC) #40
Closed this CL, started a new one at:  http://codereview.chromium.org/6716005/
to account for Neb's suggestion of leaving PPB_Instance and PPP_Instance alone.

http://codereview.chromium.org/6538028/diff/54012/ppapi/c/ppb_instance.h
File ppapi/c/ppb_instance.h (right):

http://codereview.chromium.org/6538028/diff/54012/ppapi/c/ppb_instance.h#newc...
ppapi/c/ppb_instance.h:115: * @a PostMessage is a pointer to a function which
asynchronously invokes th
On 2011/03/16 21:34:11, brettw wrote:
> th -> the
Done.

http://codereview.chromium.org/6538028/diff/54012/ppapi/tests/testing_instance.h
File ppapi/tests/testing_instance.h (right):

http://codereview.chromium.org/6538028/diff/54012/ppapi/tests/testing_instanc...
ppapi/tests/testing_instance.h:48: bool nacl_mode() { return nacl_mode_; }
On 2011/03/16 21:34:11, brettw wrote:
> This should be const.
Nice catch.  Turns out I didn't end up using it, so I just cut it.

http://codereview.chromium.org/6538028/diff/54012/webkit/plugins/ppapi/plugin...
File webkit/plugins/ppapi/plugin_module.cc (right):

http://codereview.chromium.org/6538028/diff/54012/webkit/plugins/ppapi/plugin...
webkit/plugins/ppapi/plugin_module.cc:460: instance = new
PluginInstance(delegate, this, plugin_instance_interface,
On 2011/03/16 21:34:11, brettw wrote:
> What about just passing the instance interface object by value? It should be
> fairly small and reasonable to copy, and then you don't need to worry about
the
> ownership complexity.
Good idea.  But since I'm going to follow Neb's suggestion, I'm not going to
have to worry about backwards compatibility.  Somebody (maybe Neb or I?) will
have to deal with it later when we hack functions out of PPP_Instance.

Powered by Google App Engine
This is Rietveld 408576698