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

Issue 2663603002: Convert utility process ImageWriter IPC to mojo (Closed)

Created:
3 years, 10 months ago by Noel Gordon
Modified:
3 years, 9 months ago
CC:
Aaron Boodman, abarth-chromium, chromium-apps-reviews_chromium.org, chromium-reviews, darin (slow to review), extensions-reviews_chromium.org, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Convert utility process ImageWriter IPC to mojo Add extensions::mojo::RemovableStorageWriter Define a new mojo interface that is exposed by the utility process to the browser. Update the extensions private api image writer caller to use the new interface, rather than IPC, for image writing. Add mojo RemovableStorageWriterClient interface Define a mojo interface to send to utility process image writer, which it can use to send Write and Verify operation progress and completion status back to the caller. Use content::UtilityProcessMojoClient The code used content::UtilityProcessHost to control the utility process. Replace that with the mojo utility client. The mojo channel that connects the caller and the utility process can now be intentionally disconnected, from either end, to implement the Cancel operation. Add a browsertest for WriteCancel and VerifyCancel. Enforce image_writer_utility_client state The original code had state, but never checked the state assumption: that a WRITE or VERIFY operation could be in progress - just never at the same time. Add ResetRequest() between operations to reset state. Add DCHECK at when any new operation is requested to DCHECK that the previous operation if any has been completed. Remove the utility process IPC whitelist The image writer IPC (removed in this CL) were the last remaining entries in the utility process IPC whitelist (these IPC ran elevated on WIN). The whitelist is now unused. Remove all its code and associated files. Define a new member utility_process_running_elevated_, and use it to prevent IPC from being processed if the utility process is elevated. Add image_writer_utility_client_browsertest Again a utility process service with no test. Add a browsertest for Write and Verify operations (invalid, valid, and cancel). Note: the browsertest can't test the low-level USB driver code on any port since our bots don't have USB sticks. To test that aspect, I manually tested with the ChromeOS Recovery Tool [1] and was able to write and verify a ChromeOS image to my USB stick on both Windows and Mac OSX. ImageWriterHandler Add a test mode to allow the class to be browser-tested (with the caveats mentioned above). Add reference to bug 352442: file handles to the device and image files must remain open between Write and Verify operations. Add WriteVerify test fixture to specifically test that case. [1] http://bit.ly/2jFtsZZ BUG=680928 Review-Url: https://codereview.chromium.org/2663603002 Cr-Commit-Position: refs/heads/master@{#449296} Committed: https://chromium.googlesource.com/chromium/src/+/6b03ae83bd948f7389a359acfd3ef8055c142c45

Patch Set 1 #

Patch Set 2 : Rename test NoSource to NoImage. #

Patch Set 3 : Whitelist gone: remove whitelist OWNERS file. #

Patch Set 4 : Remove redundant fwd declaration. #

Patch Set 5 : Use UtilityProcess rather than Host, add VerifyFailure test. #

Patch Set 6 : Remove image_writer::error references that could bit-rot. #

Patch Set 7 : Expose utility process mojo respecting WIN elevation. #

Patch Set 8 : Remove test DLOG, minor name changes. #

Total comments: 28

Patch Set 9 : Review comments. #

Total comments: 17

Patch Set 10 : Review comments. #

Total comments: 5

Patch Set 11 : Use https: in bug references, minor comment fixes. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+635 lines, -305 lines) Patch
M chrome/browser/chrome_content_utility_manifest_overlay.json View 1 chunk +1 line, -0 lines 0 comments Download
M chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.h View 1 2 3 4 5 6 7 8 9 10 3 chunks +34 lines, -30 lines 0 comments Download
M chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc View 1 2 3 4 5 6 7 8 2 chunks +112 lines, -104 lines 0 comments Download
A chrome/browser/extensions/api/image_writer_private/image_writer_utility_client_browsertest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +316 lines, -0 lines 0 comments Download
M chrome/common/extensions/BUILD.gn View 1 chunk +1 line, -0 lines 0 comments Download
M chrome/common/extensions/chrome_utility_extensions_messages.h View 2 chunks +0 lines, -31 lines 0 comments Download
A chrome/common/extensions/removable_storage_writer.mojom View 1 chunk +34 lines, -0 lines 0 comments Download
M chrome/test/BUILD.gn View 1 2 3 4 5 6 7 8 1 chunk +1 line, -0 lines 0 comments Download
M chrome/utility/BUILD.gn View 1 chunk +0 lines, -2 lines 0 comments Download
D chrome/utility/OWNERS View 1 2 1 chunk +0 lines, -3 lines 0 comments Download
M chrome/utility/chrome_content_utility_client.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -4 lines 0 comments Download
M chrome/utility/chrome_content_utility_client.cc View 1 2 3 4 5 6 7 8 5 chunks +8 lines, -22 lines 0 comments Download
D chrome/utility/chrome_content_utility_ipc_whitelist.h View 1 chunk +0 lines, -18 lines 0 comments Download
D chrome/utility/chrome_content_utility_ipc_whitelist.cc View 1 chunk +0 lines, -25 lines 0 comments Download
M chrome/utility/extensions/extensions_handler.cc View 1 2 3 4 5 6 7 8 3 chunks +38 lines, -0 lines 0 comments Download
M chrome/utility/image_writer/image_writer_handler.h View 1 2 3 2 chunks +17 lines, -20 lines 0 comments Download
M chrome/utility/image_writer/image_writer_handler.cc View 1 2 3 4 5 6 7 8 9 10 5 chunks +72 lines, -45 lines 0 comments Download
M chrome/utility/image_writer/image_writer_unittest.cc View 1 chunk +0 lines, -1 line 0 comments Download

Messages

Total messages: 89 (64 generated)
Noel Gordon
+ sammc, tibell for the mojo + dcheng for IPC security
3 years, 10 months ago (2017-02-02 06:40:19 UTC) #33
Sam McNally
https://codereview.chromium.org/2663603002/diff/160001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc File chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc (right): https://codereview.chromium.org/2663603002/diff/160001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc#newcode8 chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc:8: #include "base/callback.h" Remove. https://codereview.chromium.org/2663603002/diff/160001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc#newcode52 chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc:52: ImageWriterUtilityClient* const image_writer_utility_client_; Comment ...
3 years, 10 months ago (2017-02-02 21:54:17 UTC) #34
Noel Gordon
https://codereview.chromium.org/2663603002/diff/160001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc File chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc (right): https://codereview.chromium.org/2663603002/diff/160001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc#newcode8 chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc:8: #include "base/callback.h" On 2017/02/02 21:54:17, Sam McNally wrote: > ...
3 years, 10 months ago (2017-02-03 13:54:57 UTC) #39
Sam McNally
lgtm
3 years, 10 months ago (2017-02-03 18:18:25 UTC) #42
dcheng
https://codereview.chromium.org/2663603002/diff/180001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc File chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc (right): https://codereview.chromium.org/2663603002/diff/180001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc#newcode158 chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc:158: ResetRequest(); It seems like we call ResetRequest() a lot ...
3 years, 10 months ago (2017-02-06 05:52:02 UTC) #43
tibell
lgtm https://codereview.chromium.org/2663603002/diff/180001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.h File chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.h (right): https://codereview.chromium.org/2663603002/diff/180001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.h#newcode73 chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.h:73: void OperationProgress(int64_t progress); Optional: What's |progress|? A percentage?
3 years, 10 months ago (2017-02-06 22:36:22 UTC) #44
Noel Gordon
https://codereview.chromium.org/2663603002/diff/180001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.h File chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.h (right): https://codereview.chromium.org/2663603002/diff/180001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.h#newcode73 chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.h:73: void OperationProgress(int64_t progress); On 2017/02/06 22:36:22, tibell wrote: > ...
3 years, 10 months ago (2017-02-07 00:22:31 UTC) #45
Noel Gordon
https://codereview.chromium.org/2663603002/diff/180001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc File chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc (right): https://codereview.chromium.org/2663603002/diff/180001/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc#newcode158 chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc:158: ResetRequest(); On 2017/02/06 05:52:02, dcheng wrote: > It seems ...
3 years, 10 months ago (2017-02-07 11:31:09 UTC) #50
dcheng
mojo lgtm https://codereview.chromium.org/2663603002/diff/180001/chrome/utility/image_writer/image_writer_handler.cc File chrome/utility/image_writer/image_writer_handler.cc (right): https://codereview.chromium.org/2663603002/diff/180001/chrome/utility/image_writer/image_writer_handler.cc#newcode17 chrome/utility/image_writer/image_writer_handler.cc:17: extensions::mojom::RemovableStorageWriter::kTestDevice; On 2017/02/07 11:31:09, noel gordon wrote: ...
3 years, 10 months ago (2017-02-08 09:31:19 UTC) #51
Noel Gordon
https://codereview.chromium.org/2663603002/diff/200001/chrome/utility/image_writer/image_writer_handler.cc File chrome/utility/image_writer/image_writer_handler.cc (right): https://codereview.chromium.org/2663603002/diff/200001/chrome/utility/image_writer/image_writer_handler.cc#newcode45 chrome/utility/image_writer/image_writer_handler.cc:45: // http://crbug.com/352442 On 2017/02/08 09:31:18, dcheng wrote: > Nit: ...
3 years, 10 months ago (2017-02-08 12:13:00 UTC) #54
Noel Gordon
On 2017/02/08 09:31:19, dcheng wrote: > mojo lgtm > > https://codereview.chromium.org/2663603002/diff/180001/chrome/utility/image_writer/image_writer_handler.cc > File chrome/utility/image_writer/image_writer_handler.cc (right): ...
3 years, 10 months ago (2017-02-08 12:59:12 UTC) #56
Noel Gordon
+ jochen for OWNERS.
3 years, 10 months ago (2017-02-08 13:00:13 UTC) #58
dcheng
https://codereview.chromium.org/2663603002/diff/200001/chrome/utility/image_writer/image_writer_handler.cc File chrome/utility/image_writer/image_writer_handler.cc (right): https://codereview.chromium.org/2663603002/diff/200001/chrome/utility/image_writer/image_writer_handler.cc#newcode45 chrome/utility/image_writer/image_writer_handler.cc:45: // http://crbug.com/352442 On 2017/02/08 12:12:59, noel gordon wrote: > ...
3 years, 10 months ago (2017-02-09 01:25:36 UTC) #65
Noel Gordon
On 2017/02/09 01:25:36, dcheng wrote: > https://codereview.chromium.org/2663603002/diff/200001/chrome/utility/image_writer/image_writer_handler.cc > File chrome/utility/image_writer/image_writer_handler.cc (right): > > https://codereview.chromium.org/2663603002/diff/200001/chrome/utility/image_writer/image_writer_handler.cc#newcode45 > ...
3 years, 10 months ago (2017-02-09 12:40:19 UTC) #70
Noel Gordon
On 2017/02/09 12:40:19, noel gordon wrote: > That kinds thing really annoys me due to ...
3 years, 10 months ago (2017-02-09 12:41:38 UTC) #71
jochen (gone - plz use gerrit)
lgtm
3 years, 10 months ago (2017-02-09 13:14:11 UTC) #72
jochen (gone - plz use gerrit)
lgtm
3 years, 10 months ago (2017-02-09 13:14:19 UTC) #73
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2663603002/220001
3 years, 10 months ago (2017-02-09 13:17:50 UTC) #76
commit-bot: I haz the power
Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_android_rel_ng/builds/229166)
3 years, 10 months ago (2017-02-09 14:42:10 UTC) #78
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2663603002/220001
3 years, 10 months ago (2017-02-09 14:56:13 UTC) #80
commit-bot: I haz the power
Committed patchset #11 (id:220001) as https://chromium.googlesource.com/chromium/src/+/6b03ae83bd948f7389a359acfd3ef8055c142c45
3 years, 10 months ago (2017-02-09 15:29:03 UTC) #83
dcheng
On 2017/02/09 12:40:19, noel gordon wrote: > On 2017/02/09 01:25:36, dcheng wrote: > > > ...
3 years, 10 months ago (2017-02-11 01:19:15 UTC) #86
dcheng
On 2017/02/11 01:19:15, dcheng wrote: > On 2017/02/09 12:40:19, noel gordon wrote: > > On ...
3 years, 10 months ago (2017-02-20 03:04:32 UTC) #87
dcheng
On 2017/02/20 03:04:32, dcheng wrote: > On 2017/02/11 01:19:15, dcheng wrote: > > On 2017/02/09 ...
3 years, 9 months ago (2017-02-27 03:20:51 UTC) #88
Noel Gordon
3 years, 9 months ago (2017-03-17 05:58:35 UTC) #89
Message was sent while issue was closed.
On 2017/02/27 03:20:51, dcheng wrote:
> On 2017/02/20 03:04:32, dcheng wrote:
> > On 2017/02/11 01:19:15, dcheng wrote:
> > > On 2017/02/09 12:40:19, noel gordon wrote:
> > > > On 2017/02/09 01:25:36, dcheng wrote:
> > > > >
> > > >
> > >
> >
>
https://codereview.chromium.org/2663603002/diff/200001/chrome/utility/image_w...
> > > > > File chrome/utility/image_writer/image_writer_handler.cc (right):
> > > > > 
> > > > >
> > > >
> > >
> >
>
https://codereview.chromium.org/2663603002/diff/200001/chrome/utility/image_w...
> > > > > chrome/utility/image_writer/image_writer_handler.cc:45: //
> > > > > http://crbug.com/352442
> > > > > On 2017/02/08 12:12:59, noel gordon wrote:
> > > > > > On 2017/02/08 09:31:18, dcheng wrote:
> > > > > > > Nit: pointer to the bug is good, but a brief explanation of why
this
> > > logic
> > > > > is
> > > > > > > necessary would be useful as well
> > > > > > > 
> > > > > > > Also, http => https ;-)
> > > > > > 
> > > > > > Done.  I think the URL is the best pointer I can give to the
details. 
> > > Also
> > > > a
> > > > > > brief explanation of the bug is given in the ChangeLog, and that
saves
> > me
> > > > > > repeating myself twice :)
> > > > > > 
> > > > > > Comments are not code, and too often don't match the actual code,
> > leading
> > > to
> > > > > > maintenance burden and other issues.  Better to rephrase them into
> > actual
> > > > code
> > > > > > if possible.  It's not always possible, so ensure the comment adds
> > value.
> > > > [1]
> > > > > >   
> > > > > > [1]
> > https://lists.webkit.org/pipermail/webkit-dev/2011-January/015769.html
> > > > > 
> > > > > Hmm... I personally don't like bug URLs as the only explanation,
because
> > you
> > > > > often have to read through all the comments and try to reverse
engineer
> > what
> > > > the
> > > > > original bug was from the comments/diffs.
> > > > 
> > > > The bug URL is not the only explanation though.  Recommend you try the
> blame
> > > > layer in codesearch: it is fast, saves you having to read a bug since
> you'd
> > > like
> > > > to avoid that, and it even comes with change description and left-right
> code
> > > > diffs.
> > > 
> > > 1) I'm not asking for a "what" comment, I'm asking for a "why" comment.
The
> > > "why" is we need to keep file handles open if we're doing consecutive
> > operations
> > > on the same image/target device, to avoid <weird failures>. This is not
> > > something I can easily deduce from the code.
> > > 2) This isn't WebKit. We've been trying to encourage more comments
> throughout
> > > the codebase.
> > > 
> > > > 
> > > > > As best as I can tell, we just want to
> > > > > avoid creating a new ImageWriter if the image path and the target
device
> > are
> > > > > identical, so we can keep any existing file handles open.
> > > > >
> > > > > Given that the Mojo set up / ImageWriter setup looks largely shared,
> > another
> > > > > option is to just factor it out into a helper method. Then the comment
> > won't
> > > > be
> > > > > duplicated =)
> > > > 
> > > > Possible.  A possible con would be blame would be assigned to me, and
> would
> > > also
> > > > require you to click through more layers of blame to find the relevant
> > change.
> > > 
> > > > That kinds thing really annoys me due to the waste of precious developer
> > time.
> > > 
> > > Skipping through one revision for blame isn't hard and happens all the
time.
> > > This isn't a good reason not to refactor duplicated code. Ultimately, I do
> not
> > > think the comment meets the bar of readability for chromium. Please
refactor
> > out
> > > the common code and make it self-sufficient.
> > 
> > (Pinging to make sure this doesn't get lost even though the CL is already
> > committed)
> 
> Can you please address my comments in a followup CL? Thanks!

Done.

Powered by Google App Engine
This is Rietveld 408576698