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

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

Issue 1312153003: jni_generator: Pass object parameters as JavaParamRef. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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/runner/android/bootstrap.cc ('k') | net/android/gurl_utils.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 "mojo/runner/android/main.h" 5 #include "mojo/runner/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"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 << "Unable to create fifo: " << fifo_path.value(); 92 << "Unable to create fifo: " << fifo_path.value();
93 CHECK(base::android::RedirectStream(stdout, fifo_path, "w")) 93 CHECK(base::android::RedirectStream(stdout, fifo_path, "w"))
94 << "Failed to redirect stdout to file: " << fifo_path.value(); 94 << "Failed to redirect stdout to file: " << fifo_path.value();
95 CHECK(dup2(STDOUT_FILENO, STDERR_FILENO) != -1) 95 CHECK(dup2(STDOUT_FILENO, STDERR_FILENO) != -1)
96 << "Unable to redirect stderr to stdout."; 96 << "Unable to redirect stderr to stdout.";
97 } 97 }
98 98
99 } // namespace 99 } // namespace
100 100
101 static void Init(JNIEnv* env, 101 static void Init(JNIEnv* env,
102 jclass clazz, 102 const JavaParamRef<jclass>& clazz,
103 jobject activity, 103 const JavaParamRef<jobject>& activity,
104 jstring mojo_shell_path, 104 const JavaParamRef<jstring>& mojo_shell_path,
105 jobjectArray jparameters, 105 const JavaParamRef<jobjectArray>& jparameters,
106 jstring j_local_apps_directory, 106 const JavaParamRef<jstring>& j_local_apps_directory,
107 jstring j_tmp_dir) { 107 const JavaParamRef<jstring>& j_tmp_dir) {
108 g_main_activiy.Get().Reset(env, activity); 108 g_main_activiy.Get().Reset(env, activity);
109 109
110 // Setting the TMPDIR environment variable so that applications can use it. 110 // Setting the TMPDIR environment variable so that applications can use it.
111 // TODO(qsr) We will need our subprocesses to inherit this. 111 // TODO(qsr) We will need our subprocesses to inherit this.
112 int return_value = 112 int return_value =
113 setenv("TMPDIR", 113 setenv("TMPDIR",
114 base::android::ConvertJavaStringToUTF8(env, j_tmp_dir).c_str(), 1); 114 base::android::ConvertJavaStringToUTF8(env, j_tmp_dir).c_str(), 1);
115 DCHECK_EQ(return_value, 0); 115 DCHECK_EQ(return_value, 0);
116 116
117 base::android::ScopedJavaLocalRef<jobject> scoped_activity(env, activity); 117 base::android::ScopedJavaLocalRef<jobject> scoped_activity(env, activity);
(...skipping 30 matching lines...) Expand all
148 // tasks. This is consistent with the ordering from the desktop version of 148 // tasks. This is consistent with the ordering from the desktop version of
149 // this file (../desktop/launcher_process.cc). 149 // this file (../desktop/launcher_process.cc).
150 InitContext(shell_context); 150 InitContext(shell_context);
151 151
152 // TODO(abarth): At which point should we switch to cross-platform 152 // TODO(abarth): At which point should we switch to cross-platform
153 // initialization? 153 // initialization?
154 154
155 gfx::GLSurface::InitializeOneOff(); 155 gfx::GLSurface::InitializeOneOff();
156 } 156 }
157 157
158 static void Start(JNIEnv* env, jclass clazz) { 158 static void Start(JNIEnv* env, const JavaParamRef<jclass>& clazz) {
159 #if defined(MOJO_SHELL_DEBUG_URL) 159 #if defined(MOJO_SHELL_DEBUG_URL)
160 base::CommandLine::ForCurrentProcess()->AppendArg(MOJO_SHELL_DEBUG_URL); 160 base::CommandLine::ForCurrentProcess()->AppendArg(MOJO_SHELL_DEBUG_URL);
161 // Sleep for 5 seconds to give the debugger a chance to attach. 161 // Sleep for 5 seconds to give the debugger a chance to attach.
162 sleep(5); 162 sleep(5);
163 #endif 163 #endif
164 164
165 Context* context = g_context.Pointer()->get(); 165 Context* context = g_context.Pointer()->get();
166 context->RunCommandLineApplication(base::Bind(ExitShell)); 166 context->RunCommandLineApplication(base::Bind(ExitShell));
167 } 167 }
168 168
169 static void AddApplicationURL(JNIEnv* env, jclass clazz, jstring jurl) { 169 static void AddApplicationURL(JNIEnv* env,
170 const JavaParamRef<jclass>& clazz,
171 const JavaParamRef<jstring>& jurl) {
170 base::CommandLine::ForCurrentProcess()->AppendArg( 172 base::CommandLine::ForCurrentProcess()->AppendArg(
171 base::android::ConvertJavaStringToUTF8(env, jurl)); 173 base::android::ConvertJavaStringToUTF8(env, jurl));
172 } 174 }
173 175
174 bool RegisterShellMain(JNIEnv* env) { 176 bool RegisterShellMain(JNIEnv* env) {
175 return RegisterNativesImpl(env); 177 return RegisterNativesImpl(env);
176 } 178 }
177 179
178 Context* GetContext() { 180 Context* GetContext() {
179 return g_context.Get().get(); 181 return g_context.Get().get();
180 } 182 }
181 183
182 } // namespace runner 184 } // namespace runner
183 } // namespace mojo 185 } // namespace mojo
184 186
185 int main(int argc, char** argv) { 187 int main(int argc, char** argv) {
186 base::AtExitManager at_exit; 188 base::AtExitManager at_exit;
187 base::CommandLine::Init(argc, argv); 189 base::CommandLine::Init(argc, argv);
188 190
189 #if !defined(OFFICIAL_BUILD) 191 #if !defined(OFFICIAL_BUILD)
190 base::debug::EnableInProcessStackDumping(); 192 base::debug::EnableInProcessStackDumping();
191 #endif 193 #endif
192 194
193 mojo::runner::InitializeLogging(); 195 mojo::runner::InitializeLogging();
194 return mojo::runner::ChildProcessMain(); 196 return mojo::runner::ChildProcessMain();
195 } 197 }
OLDNEW
« no previous file with comments | « mojo/runner/android/bootstrap.cc ('k') | net/android/gurl_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698