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

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

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

Powered by Google App Engine
This is Rietveld 408576698