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

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

Issue 1630823002: Move mojo/runner to mojo/shell/standalone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 11 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 "mojo/runner/android/main.h" 5 #include "mojo/shell/standalone/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/debug/stack_trace.h" 14 #include "base/debug/stack_trace.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
17 #include "base/lazy_instance.h" 17 #include "base/lazy_instance.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/message_loop/message_loop.h" 20 #include "base/message_loop/message_loop.h"
21 #include "base/run_loop.h" 21 #include "base/run_loop.h"
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 #include "components/mus/android_loader.h" 23 #include "components/mus/android_loader.h"
24 #include "jni/ShellMain_jni.h" 24 #include "jni/ShellMain_jni.h"
25 #include "mojo/message_pump/message_pump_mojo.h" 25 #include "mojo/message_pump/message_pump_mojo.h"
26 #include "mojo/runner/android/android_handler_loader.h"
27 #include "mojo/runner/android/background_application_loader.h"
28 #include "mojo/runner/android/context_init.h"
29 #include "mojo/runner/android/ui_application_loader_android.h"
30 #include "mojo/runner/context.h"
31 #include "mojo/shell/application_loader.h" 26 #include "mojo/shell/application_loader.h"
32 #include "mojo/shell/runner/host/child_process.h" 27 #include "mojo/shell/runner/host/child_process.h"
33 #include "mojo/shell/runner/init.h" 28 #include "mojo/shell/runner/init.h"
29 #include "mojo/shell/standalone/android/android_handler_loader.h"
30 #include "mojo/shell/standalone/android/background_application_loader.h"
31 #include "mojo/shell/standalone/android/context_init.h"
32 #include "mojo/shell/standalone/android/ui_application_loader_android.h"
33 #include "mojo/shell/standalone/context.h"
34 #include "ui/gl/gl_surface_egl.h" 34 #include "ui/gl/gl_surface_egl.h"
35 35
36 using base::LazyInstance; 36 using base::LazyInstance;
37 37
38 namespace mojo { 38 namespace mojo {
39 namespace runner { 39 namespace shell {
40 40
41 namespace { 41 namespace {
42 42
43 // Command line argument for the communication fifo. 43 // Command line argument for the communication fifo.
44 const char kFifoPath[] = "fifo-path"; 44 const char kFifoPath[] = "fifo-path";
45 45
46 LazyInstance<scoped_ptr<base::MessageLoop>> g_java_message_loop = 46 LazyInstance<scoped_ptr<base::MessageLoop>> g_java_message_loop =
47 LAZY_INSTANCE_INITIALIZER; 47 LAZY_INSTANCE_INITIALIZER;
48 48
49 LazyInstance<scoped_ptr<Context>> g_context = LAZY_INSTANCE_INITIALIZER; 49 LazyInstance<scoped_ptr<Context>> g_context = LAZY_INSTANCE_INITIALIZER;
(...skipping 29 matching lines...) Expand all
79 void InitializeRedirection() { 79 void InitializeRedirection() {
80 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(kFifoPath)) 80 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(kFifoPath))
81 return; 81 return;
82 82
83 base::FilePath fifo_path = 83 base::FilePath fifo_path =
84 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(kFifoPath); 84 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(kFifoPath);
85 base::FilePath directory = fifo_path.DirName(); 85 base::FilePath directory = fifo_path.DirName();
86 CHECK(base::CreateDirectoryAndGetError(directory, nullptr)) 86 CHECK(base::CreateDirectoryAndGetError(directory, nullptr))
87 << "Unable to create directory: " << directory.value(); 87 << "Unable to create directory: " << directory.value();
88 unlink(fifo_path.value().c_str()); 88 unlink(fifo_path.value().c_str());
89 CHECK(base::android::CreateFIFO(fifo_path, 0666)) 89 CHECK(base::android::CreateFIFO(fifo_path, 0666)) << "Unable to create fifo: "
90 << "Unable to create fifo: " << fifo_path.value(); 90 << fifo_path.value();
91 CHECK(base::android::RedirectStream(stdout, fifo_path, "w")) 91 CHECK(base::android::RedirectStream(stdout, fifo_path, "w"))
92 << "Failed to redirect stdout to file: " << fifo_path.value(); 92 << "Failed to redirect stdout to file: " << fifo_path.value();
93 CHECK(dup2(STDOUT_FILENO, STDERR_FILENO) != -1) 93 CHECK(dup2(STDOUT_FILENO, STDERR_FILENO) != -1)
94 << "Unable to redirect stderr to stdout."; 94 << "Unable to redirect stderr to stdout.";
95 } 95 }
96 96
97 } // namespace 97 } // namespace
98 98
99 static void Init(JNIEnv* env, 99 static void Init(JNIEnv* env,
100 const JavaParamRef<jclass>& clazz, 100 const JavaParamRef<jclass>& clazz,
(...skipping 12 matching lines...) Expand all
113 DCHECK_EQ(return_value, 0); 113 DCHECK_EQ(return_value, 0);
114 114
115 std::vector<std::string> parameters; 115 std::vector<std::string> parameters;
116 parameters.push_back( 116 parameters.push_back(
117 base::android::ConvertJavaStringToUTF8(env, mojo_shell_path)); 117 base::android::ConvertJavaStringToUTF8(env, mojo_shell_path));
118 base::android::AppendJavaStringArrayToStringVector(env, jparameters, 118 base::android::AppendJavaStringArrayToStringVector(env, jparameters,
119 &parameters); 119 &parameters);
120 base::CommandLine::Init(0, nullptr); 120 base::CommandLine::Init(0, nullptr);
121 base::CommandLine::ForCurrentProcess()->InitFromArgv(parameters); 121 base::CommandLine::ForCurrentProcess()->InitFromArgv(parameters);
122 122
123 mojo::shell::InitializeLogging(); 123 InitializeLogging();
124 mojo::shell::WaitForDebuggerIfNecessary(); 124 WaitForDebuggerIfNecessary();
125 125
126 InitializeRedirection(); 126 InitializeRedirection();
127 127
128 // We want ~MessageLoop to happen prior to ~Context. Initializing 128 // We want ~MessageLoop to happen prior to ~Context. Initializing
129 // LazyInstances is akin to stack-allocating objects; their destructors 129 // LazyInstances is akin to stack-allocating objects; their destructors
130 // will be invoked first-in-last-out. 130 // will be invoked first-in-last-out.
131 base::FilePath shell_file_root( 131 base::FilePath shell_file_root(
132 base::android::ConvertJavaStringToUTF8(env, j_local_apps_directory)); 132 base::android::ConvertJavaStringToUTF8(env, j_local_apps_directory));
133 Context* shell_context = new Context; 133 Context* shell_context = new Context;
134 g_context.Get().reset(shell_context); 134 g_context.Get().reset(shell_context);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 169 }
170 170
171 bool RegisterShellMain(JNIEnv* env) { 171 bool RegisterShellMain(JNIEnv* env) {
172 return RegisterNativesImpl(env); 172 return RegisterNativesImpl(env);
173 } 173 }
174 174
175 Context* GetContext() { 175 Context* GetContext() {
176 return g_context.Get().get(); 176 return g_context.Get().get();
177 } 177 }
178 178
179 } // namespace runner 179 } // namespace shell
180 } // namespace mojo 180 } // namespace mojo
181 181
182 int main(int argc, char** argv) { 182 int main(int argc, char** argv) {
183 base::AtExitManager at_exit; 183 base::AtExitManager at_exit;
184 base::CommandLine::Init(argc, argv); 184 base::CommandLine::Init(argc, argv);
185 185
186 mojo::shell::InitializeLogging(); 186 mojo::shell::InitializeLogging();
187 return mojo::shell::ChildProcessMain(); 187 return mojo::shell::ChildProcessMain();
188 } 188 }
OLDNEW
« no previous file with comments | « mojo/shell/standalone/android/main.h ('k') | mojo/shell/standalone/android/run_android_application_function.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698