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

Side by Side Diff: mojo/shell/android/main.cc

Issue 1082513002: Revert of Simplify mojo_shell since it's now only used for Mandoline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. 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 | « mojo/shell/BUILD.gn ('k') | mojo/shell/application_manager/application_manager.h » ('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 "mojo/shell/android/main.h" 5 #include "mojo/shell/android/main.h"
6 6
7 #include "base/android/fifo_utils.h" 7 #include "base/android/fifo_utils.h"
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/android/jni_array.h" 9 #include "base/android/jni_array.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
20 #include "base/run_loop.h" 20 #include "base/run_loop.h"
21 #include "base/threading/simple_thread.h" 21 #include "base/threading/simple_thread.h"
22 #include "jni/ShellMain_jni.h" 22 #include "jni/ShellMain_jni.h"
23 #include "mojo/common/message_pump_mojo.h" 23 #include "mojo/common/message_pump_mojo.h"
24 #include "mojo/shell/android/android_handler_loader.h" 24 #include "mojo/shell/android/android_handler_loader.h"
25 #include "mojo/shell/android/background_application_loader.h" 25 #include "mojo/shell/android/background_application_loader.h"
26 #include "mojo/shell/android/native_viewport_application_loader.h" 26 #include "mojo/shell/android/native_viewport_application_loader.h"
27 #include "mojo/shell/android/ui_application_loader_android.h" 27 #include "mojo/shell/android/ui_application_loader_android.h"
28 #include "mojo/shell/application_manager/application_loader.h" 28 #include "mojo/shell/application_manager/application_loader.h"
29 #include "mojo/shell/command_line_util.h"
29 #include "mojo/shell/context.h" 30 #include "mojo/shell/context.h"
30 #include "mojo/shell/init.h" 31 #include "mojo/shell/init.h"
31 #include "ui/gl/gl_surface_egl.h" 32 #include "ui/gl/gl_surface_egl.h"
32 33
33 using base::LazyInstance; 34 using base::LazyInstance;
34 35
35 namespace mojo { 36 namespace mojo {
36 namespace shell { 37 namespace shell {
37 38
38 namespace { 39 namespace {
39 40
40 // Tag for logging. 41 // Tag for logging.
41 const char kLogTag[] = "chromium"; 42 const char kLogTag[] = "chromium";
42 43
43 // Command line argument for the communication fifo. 44 // Command line argument for the communication fifo.
44 const char kFifoPath[] = "fifo-path"; 45 const char kFifoPath[] = "fifo-path";
45 46
46 class MojoShellRunner : public base::DelegateSimpleThread::Delegate { 47 class MojoShellRunner : public base::DelegateSimpleThread::Delegate {
47 public: 48 public:
48 MojoShellRunner(const std::vector<std::string>& parameters) {} 49 MojoShellRunner(const std::vector<std::string>& parameters)
50 : parameters_(parameters) {}
49 ~MojoShellRunner() override {} 51 ~MojoShellRunner() override {}
50 52
51 private: 53 private:
52 void Run() override; 54 void Run() override;
53 55
56 std::vector<std::string> parameters_;
57
54 DISALLOW_COPY_AND_ASSIGN(MojoShellRunner); 58 DISALLOW_COPY_AND_ASSIGN(MojoShellRunner);
55 }; 59 };
56 60
57 LazyInstance<scoped_ptr<base::MessageLoop>> g_java_message_loop = 61 LazyInstance<scoped_ptr<base::MessageLoop>> g_java_message_loop =
58 LAZY_INSTANCE_INITIALIZER; 62 LAZY_INSTANCE_INITIALIZER;
59 63
60 LazyInstance<scoped_ptr<Context>> g_context = LAZY_INSTANCE_INITIALIZER; 64 LazyInstance<scoped_ptr<Context>> g_context = LAZY_INSTANCE_INITIALIZER;
61 65
62 LazyInstance<scoped_ptr<MojoShellRunner>> g_shell_runner = 66 LazyInstance<scoped_ptr<MojoShellRunner>> g_shell_runner =
63 LAZY_INSTANCE_INITIALIZER; 67 LAZY_INSTANCE_INITIALIZER;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 g_main_activiy.Get().obj()); 100 g_main_activiy.Get().obj());
97 exit(0); 101 exit(0);
98 } 102 }
99 103
100 void MojoShellRunner::Run() { 104 void MojoShellRunner::Run() {
101 base::MessageLoop loop(common::MessagePumpMojo::Create()); 105 base::MessageLoop loop(common::MessagePumpMojo::Create());
102 Context* context = g_context.Pointer()->get(); 106 Context* context = g_context.Pointer()->get();
103 ConfigureAndroidServices(context); 107 ConfigureAndroidServices(context);
104 context->Init(); 108 context->Init();
105 109
106 context->Run(GURL("mojo:window_manager")); 110 for (auto& args : parameters_)
111 ApplyApplicationArgs(context, args);
112
113 RunCommandLineApps(context);
107 loop.Run(); 114 loop.Run();
108 115
109 g_java_message_loop.Pointer()->get()->PostTask(FROM_HERE, 116 g_java_message_loop.Pointer()->get()->PostTask(FROM_HERE,
110 base::Bind(&QuitShellThread)); 117 base::Bind(&QuitShellThread));
111 } 118 }
112 119
113 // Initialize stdout redirection if the command line switch is present. 120 // Initialize stdout redirection if the command line switch is present.
114 void InitializeRedirection() { 121 void InitializeRedirection() {
115 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(kFifoPath)) 122 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(kFifoPath))
116 return; 123 return;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 213 }
207 214
208 } // namespace shell 215 } // namespace shell
209 } // namespace mojo 216 } // namespace mojo
210 217
211 // TODO(vtl): Even though main() should never be called, mojo_shell fails to 218 // TODO(vtl): Even though main() should never be called, mojo_shell fails to
212 // link without it. Figure out if we can avoid this. 219 // link without it. Figure out if we can avoid this.
213 int main(int argc, char** argv) { 220 int main(int argc, char** argv) {
214 NOTREACHED(); 221 NOTREACHED();
215 } 222 }
OLDNEW
« no previous file with comments | « mojo/shell/BUILD.gn ('k') | mojo/shell/application_manager/application_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698