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

Side by Side Diff: mandoline/app/desktop/launcher_process.cc

Issue 1134713003: Make Android Mojo Runner respect command line apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | mojo/runner/android/main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <iostream> 9 #include <iostream>
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // TraceLog::Flush requires a message loop but we've already shut ours down. 69 // TraceLog::Flush requires a message loop but we've already shut ours down.
70 // Spin up a new thread to flush things out. 70 // Spin up a new thread to flush things out.
71 base::Thread flush_thread("mojo_shell_trace_event_flush"); 71 base::Thread flush_thread("mojo_shell_trace_event_flush");
72 flush_thread.Start(); 72 flush_thread.Start();
73 flush_thread.message_loop()->PostTask( 73 flush_thread.message_loop()->PostTask(
74 FROM_HERE, 74 FROM_HERE,
75 base::Bind(EndTraceAndFlush, base::Unretained(&flush_complete_event))); 75 base::Bind(EndTraceAndFlush, base::Unretained(&flush_complete_event)));
76 flush_complete_event.Wait(); 76 flush_complete_event.Wait();
77 } 77 }
78 78
79 void StartApp(mojo::runner::Context* context) {
80 // If a mojo app isn't specified (i.e. for an apptest), run the mojo shell's
81 // window manager.
82 GURL app_url(GURL("mojo:window_manager"));
83 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
84 base::CommandLine::StringVector args = command_line->GetArgs();
85 for (size_t i = 0; i < args.size(); ++i) {
86 GURL possible_app(args[i]);
87 if (possible_app.SchemeIs("mojo")) {
88 app_url = possible_app;
89 break;
90 }
91 }
92
93 context->Run(app_url);
94 }
95
96 } // namespace 79 } // namespace
97 80
98 int LauncherProcessMain(int argc, char** argv) { 81 int LauncherProcessMain(int argc, char** argv) {
99 const base::CommandLine& command_line = 82 const base::CommandLine& command_line =
100 *base::CommandLine::ForCurrentProcess(); 83 *base::CommandLine::ForCurrentProcess();
101 if (command_line.HasSwitch(switches::kTraceStartup)) { 84 if (command_line.HasSwitch(switches::kTraceStartup)) {
102 g_tracing = true; 85 g_tracing = true;
103 base::trace_event::CategoryFilter category_filter( 86 base::trace_event::CategoryFilter category_filter(
104 command_line.GetSwitchValueASCII(switches::kTraceStartup)); 87 command_line.GetSwitchValueASCII(switches::kTraceStartup));
105 base::trace_event::TraceLog::GetInstance()->SetEnabled( 88 base::trace_event::TraceLog::GetInstance()->SetEnabled(
106 category_filter, base::trace_event::TraceLog::RECORDING_MODE, 89 category_filter, base::trace_event::TraceLog::RECORDING_MODE,
107 base::trace_event::TraceOptions(base::trace_event::RECORD_UNTIL_FULL)); 90 base::trace_event::TraceOptions(base::trace_event::RECORD_UNTIL_FULL));
108 } 91 }
109 92
110 // We want the runner::Context to outlive the MessageLoop so that pipes are 93 // We want the runner::Context to outlive the MessageLoop so that pipes are
111 // all gracefully closed / error-out before we try to shut the Context down. 94 // all gracefully closed / error-out before we try to shut the Context down.
112 mojo::runner::Context shell_context; 95 mojo::runner::Context shell_context;
113 InitCoreServicesForContext(&shell_context); 96 InitCoreServicesForContext(&shell_context);
114 { 97 {
115 base::MessageLoop message_loop; 98 base::MessageLoop message_loop;
116 if (!shell_context.Init()) { 99 if (!shell_context.Init()) {
117 return 0; 100 return 0;
118 } 101 }
119 if (g_tracing) { 102 if (g_tracing) {
120 message_loop.PostDelayedTask(FROM_HERE, 103 message_loop.PostDelayedTask(FROM_HERE,
121 base::Bind(StopTracingAndFlushToDisk), 104 base::Bind(StopTracingAndFlushToDisk),
122 base::TimeDelta::FromSeconds(5)); 105 base::TimeDelta::FromSeconds(5));
123 } 106 }
124 107
125 message_loop.PostTask(FROM_HERE, base::Bind(&StartApp, &shell_context)); 108 message_loop.PostTask(FROM_HERE,
109 base::Bind(&mojo::runner::Context::Run,
110 base::Unretained(&shell_context),
111 GURL("mojo:window_manager")));
126 message_loop.Run(); 112 message_loop.Run();
127 113
128 // Must be called before |message_loop| is destroyed. 114 // Must be called before |message_loop| is destroyed.
129 shell_context.Shutdown(); 115 shell_context.Shutdown();
130 } 116 }
131 117
132 if (g_tracing) 118 if (g_tracing)
133 StopTracingAndFlushToDisk(); 119 StopTracingAndFlushToDisk();
134 return 0; 120 return 0;
135 } 121 }
136 122
137 } // namespace mandoline 123 } // namespace mandoline
OLDNEW
« no previous file with comments | « no previous file | mojo/runner/android/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698