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

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

Issue 574993002: Revert of Second attempt to land change to remove NativeViewportService and (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « mojo/shell/context.cc ('k') | mojo/shell/in_process_dynamic_service_runner.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 "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mojo/shell/child_process.h" 10 #include "mojo/shell/child_process.h"
11 #include "mojo/shell/context.h" 11 #include "mojo/shell/context.h"
12 #include "mojo/shell/init.h" 12 #include "mojo/shell/init.h"
13 #include "mojo/shell/switches.h" 13 #include "mojo/shell/switches.h"
14 #include "ui/gfx/switches.h" 14 #include "ui/gfx/switches.h"
15
16 #if defined(COMPONENT_BUILD)
17 #include "ui/gl/gl_surface.h" 15 #include "ui/gl/gl_surface.h"
18 #endif
19 16
20 namespace { 17 namespace {
21 18
22 void RunApps(mojo::shell::Context* context) { 19 void RunApps(mojo::shell::Context* context, std::vector<GURL> app_urls) {
23 const base::CommandLine& command_line = 20 for (std::vector<GURL>::const_iterator it = app_urls.begin();
24 *base::CommandLine::ForCurrentProcess(); 21 it != app_urls.end(); ++it) {
25 base::CommandLine::StringVector args = command_line.GetArgs(); 22 context->Run(*it);
26 for (base::CommandLine::StringVector::const_iterator it = args.begin();
27 it != args.end();
28 ++it) {
29 context->Run(GURL(*it));
30 } 23 }
31 } 24 }
32 25
33 } // namespace 26 } // namespace
34 27
35 int main(int argc, char** argv) { 28 int main(int argc, char** argv) {
36 base::AtExitManager at_exit; 29 base::AtExitManager at_exit;
37 base::CommandLine::Init(argc, argv); 30 base::CommandLine::Init(argc, argv);
38 #if defined(OS_LINUX) 31 #if defined(OS_LINUX)
39 // We use gfx::RenderText from multiple threads concurrently and the pango 32 // We use gfx::RenderText from multiple threads concurrently and the pango
40 // backend (currently the default on linux) is not close to threadsafe. Force 33 // backend (currently the default on linux) is not close to threadsafe. Force
41 // use of the harfbuzz backend for now. 34 // use of the harfbuzz backend for now.
42 base::CommandLine::ForCurrentProcess()->AppendSwitch( 35 base::CommandLine::ForCurrentProcess()->AppendSwitch(
43 switches::kEnableHarfBuzzRenderText); 36 switches::kEnableHarfBuzzRenderText);
44 #endif 37 #endif
45 mojo::shell::InitializeLogging(); 38 mojo::shell::InitializeLogging();
46 39
47 // TODO(vtl): Unify parent and child process cases to the extent possible. 40 // TODO(vtl): Unify parent and child process cases to the extent possible.
48 if (scoped_ptr<mojo::shell::ChildProcess> child_process = 41 if (scoped_ptr<mojo::shell::ChildProcess> child_process =
49 mojo::shell::ChildProcess::Create( 42 mojo::shell::ChildProcess::Create(
50 *base::CommandLine::ForCurrentProcess())) { 43 *base::CommandLine::ForCurrentProcess())) {
51 child_process->Main(); 44 child_process->Main();
52 } else { 45 } else {
53 #if defined(COMPONENT_BUILD)
54 gfx::GLSurface::InitializeOneOff(); 46 gfx::GLSurface::InitializeOneOff();
55 #endif 47
56 // We want the shell::Context to outlive the MessageLoop so that pipes are 48 // We want the shell::Context to outlive the MessageLoop so that pipes are
57 // all gracefully closed / error-out before we try to shut the Context down. 49 // all gracefully closed / error-out before we try to shut the Context down.
58 mojo::shell::Context shell_context; 50 mojo::shell::Context shell_context;
59 { 51 {
60 base::MessageLoop message_loop; 52 base::MessageLoop message_loop;
61 shell_context.Init(); 53 shell_context.Init();
62 54
63 const base::CommandLine& command_line = 55 const base::CommandLine& command_line =
64 *base::CommandLine::ForCurrentProcess(); 56 *base::CommandLine::ForCurrentProcess();
65 if (command_line.HasSwitch(switches::kOrigin)) { 57 if (command_line.HasSwitch(switches::kOrigin)) {
66 shell_context.mojo_url_resolver()->SetBaseURL( 58 shell_context.mojo_url_resolver()->SetBaseURL(
67 GURL(command_line.GetSwitchValueASCII(switches::kOrigin))); 59 GURL(command_line.GetSwitchValueASCII(switches::kOrigin)));
68 } 60 }
69 61
70 message_loop.PostTask(FROM_HERE, base::Bind(RunApps, &shell_context)); 62 std::vector<GURL> app_urls;
63 base::CommandLine::StringVector args = command_line.GetArgs();
64 for (base::CommandLine::StringVector::const_iterator it = args.begin();
65 it != args.end();
66 ++it)
67 app_urls.push_back(GURL(*it));
68
69 message_loop.PostTask(FROM_HERE,
70 base::Bind(RunApps,
71 &shell_context,
72 app_urls));
71 message_loop.Run(); 73 message_loop.Run();
72 } 74 }
73 } 75 }
74 return 0; 76 return 0;
75 } 77 }
OLDNEW
« no previous file with comments | « mojo/shell/context.cc ('k') | mojo/shell/in_process_dynamic_service_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698