Commit 1a4bbd1c authored by msw's avatar msw Committed by Commit bot

Make Android Mojo Runner respect command line apps.

Make Mandoline always run the mojo:window_manager.
(afaik we don't want to specify other command line apps)
Make Mojo Runner run the command line app (fallback on WM).
(The Android impl wasn't respecting the command line app)
Consolidate on Context::RunCommandLineApplication helper.

BUG=486220
TEST=Android mojo shell and apptest runner can run non-WM apps (eg. apptests).
R=sky@chromium.org

Review URL: https://codereview.chromium.org/1134713003

Cr-Commit-Position: refs/heads/master@{#329970}
parent 56de5c36
......@@ -76,23 +76,6 @@ void StopTracingAndFlushToDisk() {
flush_complete_event.Wait();
}
void StartApp(mojo::runner::Context* context) {
// If a mojo app isn't specified (i.e. for an apptest), run the mojo shell's
// window manager.
GURL app_url(GURL("mojo:window_manager"));
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
base::CommandLine::StringVector args = command_line->GetArgs();
for (size_t i = 0; i < args.size(); ++i) {
GURL possible_app(args[i]);
if (possible_app.SchemeIs("mojo")) {
app_url = possible_app;
break;
}
}
context->Run(app_url);
}
} // namespace
int LauncherProcessMain(int argc, char** argv) {
......@@ -122,7 +105,10 @@ int LauncherProcessMain(int argc, char** argv) {
base::TimeDelta::FromSeconds(5));
}
message_loop.PostTask(FROM_HERE, base::Bind(&StartApp, &shell_context));
message_loop.PostTask(FROM_HERE,
base::Bind(&mojo::runner::Context::Run,
base::Unretained(&shell_context),
GURL("mojo:window_manager")));
message_loop.Run();
// Must be called before |message_loop| is destroyed.
......
......@@ -99,8 +99,7 @@ void MojoShellRunner::Run() {
Context* context = g_context.Pointer()->get();
ConfigureAndroidServices(context);
context->Init();
context->Run(GURL("mojo:window_manager"));
context->RunCommandLineApplication();
loop.Run();
g_java_message_loop.Pointer()->get()->PostTask(FROM_HERE,
......
......@@ -318,6 +318,21 @@ void Context::Run(const GURL& url) {
base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url));
}
void Context::RunCommandLineApplication() {
// If an app isn't specified (i.e. for an apptest), run the window manager.
GURL app_url("mojo:window_manager");
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
base::CommandLine::StringVector args = command_line->GetArgs();
for (size_t i = 0; i < args.size(); ++i) {
GURL possible_app(args[i]);
if (possible_app.SchemeIs("mojo")) {
app_url = possible_app;
break;
}
}
Run(app_url);
}
void Context::OnApplicationEnd(const GURL& url) {
if (app_urls_.find(url) != app_urls_.end()) {
app_urls_.erase(url);
......
......@@ -55,6 +55,9 @@ class Context : public shell::ApplicationManager::Delegate,
void Run(const GURL& url);
// Run the application specified on the commandline.
void RunCommandLineApplication();
TaskRunners* task_runners() { return task_runners_.get(); }
shell::ApplicationManager* application_manager() {
return &application_manager_;
......
......@@ -75,23 +75,6 @@ void StopTracingAndFlushToDisk() {
flush_complete_event.Wait();
}
void StartApp(mojo::runner::Context* context) {
// If a mojo app isn't specified (i.e. for an apptest), run the mojo shell's
// window manager.
GURL app_url(GURL("mojo:window_manager"));
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
base::CommandLine::StringVector args = command_line->GetArgs();
for (size_t i = 0; i < args.size(); ++i) {
GURL possible_app(args[i]);
if (possible_app.SchemeIs("mojo")) {
app_url = possible_app;
break;
}
}
context->Run(app_url);
}
} // namespace
int LauncherProcessMain(int argc, char** argv) {
......@@ -120,7 +103,9 @@ int LauncherProcessMain(int argc, char** argv) {
base::TimeDelta::FromSeconds(5));
}
message_loop.PostTask(FROM_HERE, base::Bind(&StartApp, &shell_context));
message_loop.PostTask(FROM_HERE,
base::Bind(&Context::RunCommandLineApplication,
base::Unretained(&shell_context)));
message_loop.Run();
// Must be called before |message_loop| is destroyed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment