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

Issue 2514323004: Convert NaCl renderer-browser messages to mojo. (Closed)

Created:
4 years ago by Sam McNally
Modified:
3 years, 8 months ago
CC:
chromium-reviews, qsr+mojo_chromium.org, droger+watchlist_chromium.org, viettrungluu+watch_chromium.org, blundell+watchlist_chromium.org, sdefresne+watchlist_chromium.org, jam, yzshen+watch_chromium.org, abarth-chromium, Aaron Boodman, fuzzing_chromium.org, darin-cc_chromium.org, darin (slow to review), chrome-apps-syd-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Convert NaCl renderer-browser messages to mojo. BUG=577685

Patch Set 1 : #

Patch Set 2 : rebase #

Patch Set 3 : rebase #

Patch Set 4 : rebase #

Total comments: 6

Patch Set 5 : rebase #

Patch Set 6 : #

Patch Set 7 : rebase #

Patch Set 8 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+586 lines, -1553 lines) Patch
M chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc View 1 2 3 4 5 6 2 chunks +5 lines, -2 lines 0 comments Download
M chrome/browser/chrome_content_browser_client.cc View 1 2 3 4 5 6 3 chunks +8 lines, -9 lines 0 comments Download
M chrome/browser/chrome_content_browser_manifest_overlay.json View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M components/nacl/browser/BUILD.gn View 1 chunk +2 lines, -2 lines 0 comments Download
M components/nacl/browser/bad_message.h View 2 chunks +3 lines, -8 lines 0 comments Download
M components/nacl/browser/bad_message.cc View 1 chunk +18 lines, -4 lines 0 comments Download
M components/nacl/browser/nacl_file_host.h View 1 2 3 4 5 2 chunks +13 lines, -17 lines 0 comments Download
M components/nacl/browser/nacl_file_host.cc View 9 chunks +58 lines, -92 lines 0 comments Download
A + components/nacl/browser/nacl_host_impl.h View 1 2 3 4 5 6 7 2 chunks +56 lines, -65 lines 0 comments Download
A + components/nacl/browser/nacl_host_impl.cc View 1 2 3 4 5 6 7 4 chunks +117 lines, -198 lines 0 comments Download
M components/nacl/browser/nacl_host_message_filter.h View 1 chunk +0 lines, -105 lines 0 comments Download
M components/nacl/browser/nacl_host_message_filter.cc View 1 chunk +0 lines, -387 lines 0 comments Download
M components/nacl/browser/nacl_process_host.h View 1 8 chunks +14 lines, -18 lines 0 comments Download
M components/nacl/browser/nacl_process_host.cc View 1 2 3 4 5 6 7 12 chunks +29 lines, -55 lines 0 comments Download
M components/nacl/browser/pnacl_host.h View 2 chunks +1 line, -4 lines 0 comments Download
M components/nacl/browser/pnacl_host.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M components/nacl/browser/pnacl_host_unittest.cc View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M components/nacl/common/BUILD.gn View 1 2 3 4 5 6 4 chunks +7 lines, -4 lines 0 comments Download
M components/nacl/common/OWNERS View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M components/nacl/common/nacl.mojom View 2 chunks +108 lines, -0 lines 0 comments Download
M components/nacl/common/nacl.typemap View 1 chunk +12 lines, -3 lines 0 comments Download
D components/nacl/common/nacl_host_messages.h View 1 chunk +0 lines, -131 lines 0 comments Download
D components/nacl/common/nacl_host_messages.cc View 1 chunk +0 lines, -40 lines 0 comments Download
M components/nacl/common/nacl_types.h View 1 chunk +0 lines, -63 lines 0 comments Download
M components/nacl/common/nacl_types.cc View 1 chunk +0 lines, -61 lines 0 comments Download
M components/nacl/common/nacl_types_param_traits.h View 1 chunk +19 lines, -0 lines 0 comments Download
M components/nacl/common/pnacl_types.h View 1 chunk +1 line, -1 line 0 comments Download
M components/nacl/renderer/nexe_load_manager.h View 1 2 3 4 5 4 chunks +9 lines, -4 lines 0 comments Download
M components/nacl/renderer/nexe_load_manager.cc View 6 chunks +8 lines, -13 lines 0 comments Download
M components/nacl/renderer/pnacl_translation_resource_host.h View 2 chunks +6 lines, -37 lines 0 comments Download
M components/nacl/renderer/pnacl_translation_resource_host.cc View 2 chunks +22 lines, -115 lines 0 comments Download
M components/nacl/renderer/ppb_nacl_private_impl.cc View 1 2 3 4 5 6 7 16 chunks +63 lines, -99 lines 0 comments Download
M extensions/shell/browser/shell_content_browser_client.cc View 1 2 3 4 5 6 2 chunks +0 lines, -8 lines 0 comments Download
M ipc/ipc_message_start.h View 1 2 3 1 chunk +0 lines, -1 line 0 comments Download
M tools/ipc_fuzzer/message_lib/all_messages.h View 1 chunk +0 lines, -3 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 90 (81 generated)
Sam McNally
4 years ago (2016-12-20 11:08:14 UTC) #58
bradnelson
Wow, that's quite a refactor. I'm a little concerned about subtle issues around crashes, shutdown ...
3 years, 11 months ago (2017-01-09 07:51:00 UTC) #67
Sam McNally
ping
3 years, 11 months ago (2017-01-19 05:42:34 UTC) #68
Mark Seaborn
I have two requests (sorry for the length): 1) Is there someone who is familiar ...
3 years, 11 months ago (2017-01-20 04:08:45 UTC) #69
Sam McNally
+tibell for mojo conversion review
3 years, 11 months ago (2017-01-22 22:45:02 UTC) #71
tibell
https://codereview.chromium.org/2514323004/diff/270001/components/nacl/browser/nacl_file_host.h File components/nacl/browser/nacl_file_host.h (right): https://codereview.chromium.org/2514323004/diff/270001/components/nacl/browser/nacl_file_host.h#newcode44 components/nacl/browser/nacl_file_host.h:44: const scoped_refptr<base::TaskRunner>& origin_task_runner, Could you document what |origin_task_runner| is ...
3 years, 10 months ago (2017-01-31 01:24:13 UTC) #76
Sam McNally
https://codereview.chromium.org/2514323004/diff/270001/components/nacl/browser/nacl_file_host.h File components/nacl/browser/nacl_file_host.h (right): https://codereview.chromium.org/2514323004/diff/270001/components/nacl/browser/nacl_file_host.h#newcode44 components/nacl/browser/nacl_file_host.h:44: const scoped_refptr<base::TaskRunner>& origin_task_runner, On 2017/01/31 01:24:12, tibell wrote: > ...
3 years, 10 months ago (2017-02-07 00:13:19 UTC) #79
tibell
lgtm
3 years, 10 months ago (2017-02-08 04:38:13 UTC) #82
Sam McNally
3 years, 10 months ago (2017-02-22 23:52:10 UTC) #90
On 2017/01/20 04:08:45, Mark Seaborn wrote:
> I have two requests (sorry for the length):
> 
> 1) Is there someone who is familiar with the Chrome IPC -> Mojo transition who
> could do an initial review of changes like this, before handing the review
over
> to component owners?  That would be much easier.
> 
> I don't work actively on Chrome now and so I'm not very familiar with how Mojo
> IPC works -- so I don't know the details of the threading model, object
> ownership, etc.  Even when I've been more actively working on Chrome, Chrome
IPC
> is abstruse enough that some of those issues are hard to understand. :-)
> 
> I suspect a review by a Mojo/IPC reviewer might raise some questions about
what
> the code does which we component owners can then answer. It should lead to a
> more thorough review.
> 
> 2) Have you got any suggestions on how to approach reviewing a big CL like
this?
>  For example:
> 
> What types of conversion did you apply in this CL?  Some of it is obvious,
like
> changing the message handlers to Mojo format in nacl_host.h.  Other parts are
> less obvious, like nacl_file_host.cc, where some functions now take a callback
+
> extra args instead of an IPC::Message.

https://www.chromium.org/developers/design-documents/mojo/mojo-migration-guide
describes the general process.
https://www.chromium.org/developers/design-documents/mojo/type-mapping covers
type mapping.

The transformations involved on the existing code are:
- Sending message requires a connection rather than just an IPC::Sender =>
ppb_nacl_private_impl has a renderer-process-wide connection that the whole
process shares.
- Responses are modelled as callbacks instead of a separate response message =>
no MessageFilters needed in the renderer, just functions to handle the
responses.
- Sync and async responses are always callbacks rather than an IPC::Message*
that needs to be sent on the MessageFilter => implementation details are passed
a callback instead of a response message and MessageFilter.
- Responses have to be sent (by calling the callback) on the same thread that
received the request => implementation details are sometimes passed a TaskRunner
where the callback should be run.

> 
> Are there any docs on what issues arise for Chrome IPC -> Mojo conversions in
> general?

See the migration guide linked above, in particular
https://www.chromium.org/developers/design-documents/mojo/mojo-migration-guid....
In this case, the NaClHostMessageFilter replacement (NaClHostImpl) is still
ref-counted, but maintains a self-reference that's cleared when the mojo
connection breaks, providing similar lifetime to before.

Beyond that, ensuring that callbacks are called on the right thread is more
complicated than the thread-safe MessageFilter::Send of the old version.
> 
> What process did you go through to create this CL?  e.g. Was it incremental,
or
> did it only compile after you converted the last piece?  What do you want us
> owners to look for?  Are there any parts you are less sure about that I should
> look at more closely?

The steps were:
1. Generate a mojo interface from the IPC messages (merging response IPCs into
mojo message responses), using native-style typemapping to try to limit the CL
size.
2. Convert the browser side.
3. Convert the renderer side.
4. Delete old IPC messages.
4. Discover that native-style typemapping doesn't allow handles (files, other
channels, shared memory).
5. Add real mojo structs for structs containing handles.
6. Fixing up error cases (making bad message reporting work without a
MessageFilter, ensuring that every message expecting a response gets one)

The code compiled after each step, but didn't work until after step 5.

My main concerns would be with edge cases not covered by tests: handling errors
or invalid messages from the renderer.

Powered by Google App Engine
This is Rietveld 408576698