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

Issue 1149833007: Embed a mojo ApplicationManager in content/browser (Closed)

Created:
5 years, 7 months ago by Ken Rockot(use gerrit already)
Modified:
5 years, 4 months ago
Reviewers:
Tom Sepez, Lei Zhang, jam
CC:
chromium-reviews, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org, abarth-chromium, Aaron Boodman, darin-cc_chromium.org, darin (slow to review), ben+mojo_chromium.org, xhwang
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Embed a mojo ApplicationManager in content/browser This embeds mojo/shell's ApplicationManager in content/browser and provides a way for arbitrary browser code to connect to Mojo apps as if the browser itself were a Mojo app. This is a basic implementation of Mojo app support which only loads static apps either in the browser process or a (per-app) utility process. Future CLs will address connection to apps from arbitrary render frames (i.e. connection requests which include the requestor's origin) as well as refactoring the utility process code further so that it serves strictly as a Mojo app runner. BUG=492422 Committed: https://crrev.com/b814a5850da5aa473ad526eef4b41a82b05037a0 Cr-Commit-Position: refs/heads/master@{#332974}

Patch Set 1 #

Total comments: 5

Patch Set 2 : Added some missing docs and removed some cruft #

Total comments: 28

Patch Set 3 : Simplify static loader #

Patch Set 4 : address comments; refine DEPS, move stuff from public, simplify code #

Patch Set 5 : Move TestMojoService and TestMojoApp to content/public/test. Add to content_shell utility process. #

Patch Set 6 : fix some test dependencies #

Patch Set 7 : Make VS happy #

Patch Set 8 : <3 gyp #

Patch Set 9 : merge #

Patch Set 10 : restore missing mojo_shell_lib dependency #

Patch Set 11 : misc build fixes #

Total comments: 14

Patch Set 12 : merge, address comments #

Patch Set 13 : Kill ApplicationRegistry #

Total comments: 1

Patch Set 14 : nit #

Patch Set 15 : use ApplicationRunner #

Total comments: 1

Patch Set 16 : properly scope the AtExitManager #

Patch Set 17 : split out commandline init from app runner #

Patch Set 18 : #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+1074 lines, -37 lines) Patch
M content/browser/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +6 lines, -0 lines 0 comments Download
M content/browser/browser_main_loop.h View 1 2 3 4 5 6 7 8 2 chunks +2 lines, -0 lines 0 comments Download
M content/browser/browser_main_loop.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +5 lines, -0 lines 0 comments Download
A content/browser/mojo/mojo_app_connection_impl.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +34 lines, -0 lines 0 comments Download
A content/browser/mojo/mojo_app_connection_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +28 lines, -0 lines 0 comments Download
A content/browser/mojo/mojo_shell_context.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +70 lines, -0 lines 0 comments Download
A content/browser/mojo/mojo_shell_context.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +178 lines, -0 lines 8 comments Download
A content/browser/mojo_shell_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +60 lines, -0 lines 0 comments Download
M content/common/BUILD.gn View 1 2 3 1 chunk +3 lines, -0 lines 0 comments Download
A content/common/process_control.mojom View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +12 lines, -0 lines 0 comments Download
M content/content.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -0 lines 0 comments Download
M content/content_browser.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +10 lines, -0 lines 0 comments Download
M content/content_common_mojo_bindings.gyp View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M content/content_shell.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +2 lines, -0 lines 0 comments Download
M content/content_tests.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 9 chunks +19 lines, -0 lines 0 comments Download
M content/content_utility.gypi View 2 chunks +8 lines, -0 lines 0 comments Download
M content/public/browser/BUILD.gn View 1 chunk +1 line, -0 lines 0 comments Download
M content/public/browser/content_browser_client.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +11 lines, -0 lines 0 comments Download
A content/public/browser/mojo_app_connection.h View 1 2 3 1 chunk +43 lines, -0 lines 0 comments Download
M content/public/test/DEPS View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
A content/public/test/test_mojo_app.h View 1 2 3 4 1 chunk +50 lines, -0 lines 0 comments Download
A content/public/test/test_mojo_app.cc View 1 2 3 4 1 chunk +43 lines, -0 lines 0 comments Download
A + content/public/test/test_mojo_service.mojom View 1 2 3 4 1 chunk +4 lines, -2 lines 0 comments Download
M content/public/utility/BUILD.gn View 2 chunks +5 lines, -6 lines 0 comments Download
M content/public/utility/content_utility_client.h View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +16 lines, -0 lines 0 comments Download
M content/shell/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +2 lines, -0 lines 0 comments Download
M content/shell/app/shell_main_delegate.h View 1 2 3 4 2 chunks +3 lines, -0 lines 0 comments Download
M content/shell/app/shell_main_delegate.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +6 lines, -0 lines 0 comments Download
A + content/shell/utility/DEPS View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
A content/shell/utility/shell_content_utility_client.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +22 lines, -0 lines 0 comments Download
A content/shell/utility/shell_content_utility_client.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +31 lines, -0 lines 0 comments Download
M content/test/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 4 chunks +10 lines, -0 lines 0 comments Download
M content/utility/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +6 lines, -0 lines 0 comments Download
M content/utility/DEPS View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
A content/utility/utility_process_control_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +48 lines, -0 lines 0 comments Download
A content/utility/utility_process_control_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +54 lines, -0 lines 0 comments Download
M content/utility/utility_thread_impl.h View 1 2 3 4 5 6 7 3 chunks +13 lines, -0 lines 0 comments Download
M content/utility/utility_thread_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +12 lines, -0 lines 0 comments Download
M mojo/application/public/cpp/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +21 lines, -0 lines 0 comments Download
M mojo/application/public/cpp/application_runner.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +7 lines, -0 lines 0 comments Download
M mojo/application/public/cpp/lib/application_runner.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 4 chunks +16 lines, -18 lines 0 comments Download
A mojo/application/public/cpp/lib/init_commandline.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +22 lines, -0 lines 0 comments Download
M mojo/mojo_base.gyp View 1 2 3 4 5 6 7 8 9 10 3 chunks +5 lines, -6 lines 0 comments Download
M mojo/mojo_services.gyp View 1 2 3 4 5 6 7 1 chunk +10 lines, -1 line 0 comments Download
M mojo/mojo_shell.gyp View 1 2 3 4 5 6 7 8 9 3 chunks +4 lines, -3 lines 0 comments Download
M mojo/shell/BUILD.gn View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
A mojo/shell/static_application_loader.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +69 lines, -0 lines 0 comments Download
A mojo/shell/static_application_loader.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +95 lines, -0 lines 0 comments Download

Messages

Total messages: 31 (5 generated)
Ken Rockot(use gerrit already)
Please take a look. Aside from all the build file noise, the basic gist of ...
5 years, 7 months ago (2015-05-27 00:12:23 UTC) #2
jam
(just looked at browser for now) https://codereview.chromium.org/1149833007/diff/1/content/browser/mojo_shell_browsertest.cc File content/browser/mojo_shell_browsertest.cc (right): https://codereview.chromium.org/1149833007/diff/1/content/browser/mojo_shell_browsertest.cc#newcode151 content/browser/mojo_shell_browsertest.cc:151: IN_PROC_BROWSER_TEST_F(MojoShellTest, TestUtilityConnection) { ...
5 years, 7 months ago (2015-05-27 16:05:36 UTC) #3
Ken Rockot(use gerrit already)
Thanks. I think I've addressed all the comments so far. I moved the test app ...
5 years, 7 months ago (2015-05-27 19:36:17 UTC) #4
jam
https://codereview.chromium.org/1149833007/diff/190001/content/browser/mojo_app_connection_impl.h File content/browser/mojo_app_connection_impl.h (right): https://codereview.chromium.org/1149833007/diff/190001/content/browser/mojo_app_connection_impl.h#newcode1 content/browser/mojo_app_connection_impl.h:1: // Copyright 2015 The Chromium Authors. All rights reserved. ...
5 years, 6 months ago (2015-05-29 01:48:54 UTC) #5
Ken Rockot(use gerrit already)
https://codereview.chromium.org/1149833007/diff/190001/content/browser/mojo_app_connection_impl.h File content/browser/mojo_app_connection_impl.h (right): https://codereview.chromium.org/1149833007/diff/190001/content/browser/mojo_app_connection_impl.h#newcode1 content/browser/mojo_app_connection_impl.h:1: // Copyright 2015 The Chromium Authors. All rights reserved. ...
5 years, 6 months ago (2015-05-29 03:20:41 UTC) #6
jam
https://codereview.chromium.org/1149833007/diff/190001/content/public/browser/content_browser_client.h File content/public/browser/content_browser_client.h (right): https://codereview.chromium.org/1149833007/diff/190001/content/public/browser/content_browser_client.h#newcode584 content/public/browser/content_browser_client.h:584: virtual void RegisterMojoApplications(ApplicationRegistry* registry) {} On 2015/05/29 03:20:40, Ken ...
5 years, 6 months ago (2015-05-29 15:11:50 UTC) #7
Ken Rockot(use gerrit already)
On 2015/05/29 15:11:50, jam wrote: > https://codereview.chromium.org/1149833007/diff/190001/content/public/browser/content_browser_client.h > File content/public/browser/content_browser_client.h (right): > > https://codereview.chromium.org/1149833007/diff/190001/content/public/browser/content_browser_client.h#newcode584 > ...
5 years, 6 months ago (2015-05-29 15:34:55 UTC) #8
Ken Rockot(use gerrit already)
Alright, ApplicationRegistry is gone. It's not so bad. I'm not crazy about having redundant type ...
5 years, 6 months ago (2015-05-29 17:12:45 UTC) #9
Ken Rockot(use gerrit already)
Oh, I think ApplicationRunner works for Mandoline because you're loading DSOs, and they have their ...
5 years, 6 months ago (2015-05-29 17:54:24 UTC) #10
Ken Rockot(use gerrit already)
light ping
5 years, 6 months ago (2015-06-02 21:10:45 UTC) #11
jam
sorry for delay, I missed the update. in the future please IM me if I'm ...
5 years, 6 months ago (2015-06-03 14:34:21 UTC) #12
jam
On 2015/05/29 17:54:24, Ken Rockot wrote: > Oh, I think ApplicationRunner works for Mandoline because ...
5 years, 6 months ago (2015-06-03 14:35:36 UTC) #13
jam
so to be clear i think this patch is almost done, other than the one ...
5 years, 6 months ago (2015-06-03 14:50:21 UTC) #14
Ken Rockot(use gerrit already)
On 2015/06/03 14:35:36, jam wrote: > On 2015/05/29 17:54:24, Ken Rockot wrote: > > Oh, ...
5 years, 6 months ago (2015-06-03 17:02:38 UTC) #15
jam
On 2015/06/03 17:02:38, Ken Rockot wrote: > On 2015/06/03 14:35:36, jam wrote: > > On ...
5 years, 6 months ago (2015-06-04 03:47:02 UTC) #16
jam
lgtm
5 years, 6 months ago (2015-06-04 19:15:23 UTC) #17
Ken Rockot(use gerrit already)
tsepez, please take a look a look at content/common/process_control.mojom
5 years, 6 months ago (2015-06-04 19:56:12 UTC) #18
Ken Rockot(use gerrit already)
(and now +tsepez for real) tsepez, please take a look a look at content/common/process_control.mojom
5 years, 6 months ago (2015-06-04 19:56:54 UTC) #20
Tom Sepez
https://codereview.chromium.org/1149833007/diff/250001/content/common/process_control.mojom File content/common/process_control.mojom (right): https://codereview.chromium.org/1149833007/diff/250001/content/common/process_control.mojom#newcode10 content/common/process_control.mojom:10: LoadApplication(string url, mojo.Application& request) => (bool success); This is ...
5 years, 6 months ago (2015-06-04 20:43:55 UTC) #21
Ken Rockot(use gerrit already)
Actually it's a request from browser to child On Thu, Jun 4, 2015 at 1:43 ...
5 years, 6 months ago (2015-06-04 20:46:21 UTC) #22
Tom Sepez
LGTM then.
5 years, 6 months ago (2015-06-04 20:56:02 UTC) #23
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1149833007/310001
5 years, 6 months ago (2015-06-04 22:54:37 UTC) #26
commit-bot: I haz the power
Committed patchset #18 (id:310001)
5 years, 6 months ago (2015-06-05 00:31:02 UTC) #27
commit-bot: I haz the power
Patchset 18 (id:??) landed as https://crrev.com/b814a5850da5aa473ad526eef4b41a82b05037a0 Cr-Commit-Position: refs/heads/master@{#332974}
5 years, 6 months ago (2015-06-05 00:32:55 UTC) #28
Lei Zhang
(random late drive-by) https://codereview.chromium.org/1149833007/diff/310001/content/browser/mojo/mojo_shell_context.cc File content/browser/mojo/mojo_shell_context.cc (right): https://codereview.chromium.org/1149833007/diff/310001/content/browser/mojo/mojo_shell_context.cc#newcode36 content/browser/mojo/mojo_shell_context.cc:36: const MojoShellContext::StaticApplicationMap* g_applications_for_test; Should this be ...
5 years, 4 months ago (2015-08-25 03:16:04 UTC) #30
Ken Rockot(use gerrit already)
5 years, 4 months ago (2015-08-25 03:54:52 UTC) #31
Message was sent while issue was closed.
https://codereview.chromium.org/1149833007/diff/310001/content/browser/mojo/m...
File content/browser/mojo/mojo_shell_context.cc (right):

https://codereview.chromium.org/1149833007/diff/310001/content/browser/mojo/m...
content/browser/mojo/mojo_shell_context.cc:36: const
MojoShellContext::StaticApplicationMap* g_applications_for_test;
On 2015/08/25 03:16:03, Lei Zhang wrote:
> Should this be explicitly initialized to nullptr?

There's no need to do this as C++ guarantees zero-initialization for static
storage:

http://en.cppreference.com/w/cpp/language/zero_initialization

https://codereview.chromium.org/1149833007/diff/310001/content/browser/mojo/m...
content/browser/mojo/mojo_shell_context.cc:43:
process_host->SetName(base::UTF8ToUTF16("Mojo Application"));
On 2015/08/25 03:16:04, Lei Zhang wrote:
> I'm assuming because this is in mojo_shell, it doesn't matter that this isn't
> translated, since we are not shipping it to users?

This is not in Mojo shell. This code is shipping to users but there are no
production code paths which trigger it in practice yet. We do need to fix it.

https://codereview.chromium.org/1149833007/diff/310001/content/browser/mojo/m...
content/browser/mojo/mojo_shell_context.cc:83: Proxy(MojoShellContext*
shell_context)
On 2015/08/25 03:16:04, Lei Zhang wrote:
> nit: explicit

Acknowledged.

https://codereview.chromium.org/1149833007/diff/310001/content/browser/mojo/m...
content/browser/mojo/mojo_shell_context.cc:93: if (shell_context_)
On 2015/08/25 03:16:04, Lei Zhang wrote:
> Here you are checking for |shell_context_|, but in the else block, you pass it
> as the object. Couldn't that crash if |shell_context_| is NULL?

This is a pretty subtle thing, but I believe it's safe. shell_context_ lives on
task_runner_'s thread. If we're currently on that thread in this method, we can
test shell_context_ and call ConnectToApplicationOnOwnThread.

If we're not on task_runner_'s thread we post a task there to run the same
function. Because shell_context_'s lifetime is bound to that of task_runner_'s
MessageLoop, we know that if the task runs at all, the ShellContext is still
valid. Conversely if the ShellContext is no longer valid it means the
MessageLoop was destroyed and the task posted here will never run.

In fact I think the null test here could be replaced with a DCHECK.

Powered by Google App Engine
This is Rietveld 408576698