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

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

Issue 292743017: Cleanup: Use base::CommandLine in mojo/ (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « mojo/services/view_manager/main.cc ('k') | mojo/shell/child_process.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/shell/android/mojo_main.h" 5 #include "mojo/shell/android/mojo_main.h"
6 6
7 #include "base/android/jni_string.h" 7 #include "base/android/jni_string.h"
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 20 matching lines...) Expand all
31 LazyInstance<scoped_ptr<base::MessageLoop> > g_java_message_loop = 31 LazyInstance<scoped_ptr<base::MessageLoop> > g_java_message_loop =
32 LAZY_INSTANCE_INITIALIZER; 32 LAZY_INSTANCE_INITIALIZER;
33 33
34 LazyInstance<scoped_ptr<shell::Context> > g_context = 34 LazyInstance<scoped_ptr<shell::Context> > g_context =
35 LAZY_INSTANCE_INITIALIZER; 35 LAZY_INSTANCE_INITIALIZER;
36 36
37 37
38 LazyInstance<scoped_ptr<mojo::Environment> > g_env = 38 LazyInstance<scoped_ptr<mojo::Environment> > g_env =
39 LAZY_INSTANCE_INITIALIZER; 39 LAZY_INSTANCE_INITIALIZER;
40 40
41 } // namspace 41 } // namespace
42 42
43 static void Init(JNIEnv* env, jclass clazz, jobject context) { 43 static void Init(JNIEnv* env, jclass clazz, jobject context) {
44 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); 44 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context);
45 45
46 base::android::InitApplicationContext(env, scoped_context); 46 base::android::InitApplicationContext(env, scoped_context);
47 47
48 CommandLine::Init(0, 0); 48 base::CommandLine::Init(0, 0);
49 mojo::shell::InitializeLogging(); 49 mojo::shell::InitializeLogging();
50 50
51 g_java_message_loop.Get().reset(new base::MessageLoopForUI); 51 g_java_message_loop.Get().reset(new base::MessageLoopForUI);
52 base::MessageLoopForUI::current()->Start(); 52 base::MessageLoopForUI::current()->Start();
53 53
54 // TODO(abarth): At which point should we switch to cross-platform 54 // TODO(abarth): At which point should we switch to cross-platform
55 // initialization? 55 // initialization?
56 56
57 gfx::GLSurface::InitializeOneOff(); 57 gfx::GLSurface::InitializeOneOff();
58 } 58 }
59 59
60 static void Start(JNIEnv* env, jclass clazz, jobject context, jstring jurl) { 60 static void Start(JNIEnv* env, jclass clazz, jobject context, jstring jurl) {
61 std::string app_url; 61 std::string app_url;
62 #if defined(MOJO_SHELL_DEBUG_URL) 62 #if defined(MOJO_SHELL_DEBUG_URL)
63 app_url = MOJO_SHELL_DEBUG_URL; 63 app_url = MOJO_SHELL_DEBUG_URL;
64 // Sleep for 5 seconds to give the debugger a chance to attach. 64 // Sleep for 5 seconds to give the debugger a chance to attach.
65 sleep(5); 65 sleep(5);
66 #else 66 #else
67 if (jurl) 67 if (jurl)
68 app_url = base::android::ConvertJavaStringToUTF8(env, jurl); 68 app_url = base::android::ConvertJavaStringToUTF8(env, jurl);
69 #endif 69 #endif
70 if (!app_url.empty()) { 70 if (!app_url.empty()) {
71 std::vector<std::string> argv; 71 std::vector<std::string> argv;
72 argv.push_back("mojo_shell"); 72 argv.push_back("mojo_shell");
73 argv.push_back(app_url); 73 argv.push_back(app_url);
74 CommandLine::ForCurrentProcess()->InitFromArgv(argv); 74 base::CommandLine::ForCurrentProcess()->InitFromArgv(argv);
75 } 75 }
76 76
77 g_env.Get().reset(new Environment); 77 g_env.Get().reset(new Environment);
78 78
79 base::android::ScopedJavaGlobalRef<jobject> activity; 79 base::android::ScopedJavaGlobalRef<jobject> activity;
80 activity.Reset(env, context); 80 activity.Reset(env, context);
81 81
82 shell::Context* shell_context = new shell::Context(); 82 shell::Context* shell_context = new shell::Context();
83 shell_context->set_activity(activity.obj()); 83 shell_context->set_activity(activity.obj());
84 84
85 g_context.Get().reset(shell_context); 85 g_context.Get().reset(shell_context);
86 shell::Run(shell_context); 86 shell::Run(shell_context);
87 } 87 }
88 88
89 bool RegisterMojoMain(JNIEnv* env) { 89 bool RegisterMojoMain(JNIEnv* env) {
90 return RegisterNativesImpl(env); 90 return RegisterNativesImpl(env);
91 } 91 }
92 92
93 } // namespace mojo 93 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/main.cc ('k') | mojo/shell/child_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698