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

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

Issue 978673002: Remove some unused ui/gfx code. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 | ui/gfx/BUILD.gn » ('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 <algorithm> 5 #include <algorithm>
6 #include <iostream> 6 #include <iostream>
7 7
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "shell/child_process.h" 13 #include "shell/child_process.h"
14 #include "shell/command_line_util.h" 14 #include "shell/command_line_util.h"
15 #include "shell/context.h" 15 #include "shell/context.h"
16 #include "shell/init.h" 16 #include "shell/init.h"
17 #include "shell/switches.h" 17 #include "shell/switches.h"
18 18
19 namespace { 19 namespace {
20 20
21 #if defined(OS_LINUX)
22 // Copied from ui/gfx/switches.cc to avoid a dependency on //ui/gfx
23 const char kEnableHarfBuzzRenderText[] = "enable-harfbuzz-rendertext";
24 #endif
25
26 void Usage() { 21 void Usage() {
27 std::cerr << "Launch Mojo applications.\n"; 22 std::cerr << "Launch Mojo applications.\n";
28 std::cerr 23 std::cerr
29 << "Usage: mojo_shell" 24 << "Usage: mojo_shell"
30 << " [--" << switches::kArgsFor << "=<mojo-app>]" 25 << " [--" << switches::kArgsFor << "=<mojo-app>]"
31 << " [--" << switches::kContentHandlers << "=<handlers>]" 26 << " [--" << switches::kContentHandlers << "=<handlers>]"
32 << " [--" << switches::kEnableExternalApplications << "]" 27 << " [--" << switches::kEnableExternalApplications << "]"
33 << " [--" << switches::kDisableCache << "]" 28 << " [--" << switches::kDisableCache << "]"
34 << " [--" << switches::kEnableMultiprocess << "]" 29 << " [--" << switches::kEnableMultiprocess << "]"
35 << " [--" << switches::kOrigin << "=<url-lib-path>]" 30 << " [--" << switches::kOrigin << "=<url-lib-path>]"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 69 }
75 70
76 if (found_unknown_switch || 71 if (found_unknown_switch ||
77 (!command_line.HasSwitch(switches::kEnableExternalApplications) && 72 (!command_line.HasSwitch(switches::kEnableExternalApplications) &&
78 (command_line.HasSwitch(switches::kHelp) || 73 (command_line.HasSwitch(switches::kHelp) ||
79 command_line.GetArgs().empty()))) { 74 command_line.GetArgs().empty()))) {
80 Usage(); 75 Usage();
81 return 0; 76 return 0;
82 } 77 }
83 78
84 #if defined(OS_LINUX)
85 // We use gfx::RenderText from multiple threads concurrently and the pango
86 // backend (currently the default on linux) is not close to threadsafe.
87 // Force use of the harfbuzz backend for now.
88 base::CommandLine::ForCurrentProcess()->AppendSwitch(
89 kEnableHarfBuzzRenderText);
90 #endif
91
92 // We want the shell::Context to outlive the MessageLoop so that pipes are 79 // We want the shell::Context to outlive the MessageLoop so that pipes are
93 // all gracefully closed / error-out before we try to shut the Context down. 80 // all gracefully closed / error-out before we try to shut the Context down.
94 mojo::shell::Context shell_context; 81 mojo::shell::Context shell_context;
95 { 82 {
96 base::MessageLoop message_loop; 83 base::MessageLoop message_loop;
97 if (!shell_context.Init()) { 84 if (!shell_context.Init()) {
98 Usage(); 85 Usage();
99 return 0; 86 return 0;
100 } 87 }
101 88
102 // The mojo_shell --args-for command-line switch is handled specially 89 // The mojo_shell --args-for command-line switch is handled specially
103 // because it can appear more than once. The base::CommandLine class 90 // because it can appear more than once. The base::CommandLine class
104 // collapses multiple occurrences of the same switch. 91 // collapses multiple occurrences of the same switch.
105 for (int i = 1; i < argc; i++) { 92 for (int i = 1; i < argc; i++) {
106 ApplyApplicationArgs(&shell_context, argv[i]); 93 ApplyApplicationArgs(&shell_context, argv[i]);
107 } 94 }
108 95
109 message_loop.PostTask( 96 message_loop.PostTask(
110 FROM_HERE, 97 FROM_HERE,
111 base::Bind(&mojo::shell::RunCommandLineApps, &shell_context)); 98 base::Bind(&mojo::shell::RunCommandLineApps, &shell_context));
112 message_loop.Run(); 99 message_loop.Run();
113 100
114 // Must be called before |message_loop| is destroyed. 101 // Must be called before |message_loop| is destroyed.
115 shell_context.Shutdown(); 102 shell_context.Shutdown();
116 } 103 }
117 } 104 }
118 return 0; 105 return 0;
119 } 106 }
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698