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

Side by Side Diff: shell/desktop/main.cc

Issue 1055463004: Replace ChildProcess/AppChildProcess with a simple ChildMain(). (Closed) Base URL: https://github.com/domokit/mojo.git@simplify_child_6-x-simplify_child_5
Patch Set: rebased Created 5 years, 8 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 | « shell/child_process_host_unittest.cc ('k') | shell/shell_test_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/base_switches.h" 12 #include "base/base_switches.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/synchronization/waitable_event.h" 17 #include "base/synchronization/waitable_event.h"
18 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
19 #include "shell/child_process.h" 19 #include "shell/child_main.h"
20 #include "shell/command_line_util.h" 20 #include "shell/command_line_util.h"
21 #include "shell/context.h" 21 #include "shell/context.h"
22 #include "shell/init.h" 22 #include "shell/init.h"
23 #include "shell/switches.h" 23 #include "shell/switches.h"
24 24
25 namespace { 25 namespace {
26 26
27 void Usage() { 27 void Usage() {
28 std::cerr << "Launch Mojo applications.\n"; 28 std::cerr << "Launch Mojo applications.\n";
29 std::cerr 29 std::cerr
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 103
104 } // namespace 104 } // namespace
105 105
106 int main(int argc, char** argv) { 106 int main(int argc, char** argv) {
107 base::AtExitManager at_exit; 107 base::AtExitManager at_exit;
108 base::CommandLine::Init(argc, argv); 108 base::CommandLine::Init(argc, argv);
109 109
110 mojo::shell::InitializeLogging(); 110 mojo::shell::InitializeLogging();
111 111
112 const base::CommandLine& command_line =
113 *base::CommandLine::ForCurrentProcess();
114
112 // TODO(vtl): Unify parent and child process cases to the extent possible. 115 // TODO(vtl): Unify parent and child process cases to the extent possible.
113 if (scoped_ptr<mojo::shell::ChildProcess> child_process = 116 int exit_code = 0;
114 mojo::shell::ChildProcess::Create( 117 if (command_line.HasSwitch(switches::kChildProcess)) {
115 *base::CommandLine::ForCurrentProcess())) { 118 exit_code = mojo::shell::ChildMain();
116 child_process->Main();
117 } else { 119 } else {
118 // Only check the command line for the main process. 120 // Only check the command line for the main process.
119 const base::CommandLine& command_line =
120 *base::CommandLine::ForCurrentProcess();
121
122 const std::set<std::string> all_switches = switches::GetAllSwitches(); 121 const std::set<std::string> all_switches = switches::GetAllSwitches();
123 const base::CommandLine::SwitchMap switches = command_line.GetSwitches(); 122 const base::CommandLine::SwitchMap switches = command_line.GetSwitches();
124 bool found_unknown_switch = false; 123 bool found_unknown_switch = false;
125 for (const auto& s : switches) { 124 for (const auto& s : switches) {
126 if (all_switches.find(s.first) == all_switches.end()) { 125 if (all_switches.find(s.first) == all_switches.end()) {
127 std::cerr << "unknown switch: " << s.first << std::endl; 126 std::cerr << "unknown switch: " << s.first << std::endl;
128 found_unknown_switch = true; 127 found_unknown_switch = true;
129 } 128 }
130 } 129 }
131 130
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 base::Bind(&mojo::shell::RunCommandLineApps, &shell_context)); 173 base::Bind(&mojo::shell::RunCommandLineApps, &shell_context));
175 message_loop.Run(); 174 message_loop.Run();
176 175
177 // Must be called before |message_loop| is destroyed. 176 // Must be called before |message_loop| is destroyed.
178 shell_context.Shutdown(); 177 shell_context.Shutdown();
179 } 178 }
180 } 179 }
181 180
182 if (g_tracing) 181 if (g_tracing)
183 StopTracingAndFlushToDisk(); 182 StopTracingAndFlushToDisk();
184 return 0; 183 return exit_code;
185 } 184 }
OLDNEW
« no previous file with comments | « shell/child_process_host_unittest.cc ('k') | shell/shell_test_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698