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

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

Issue 782013002: Android: decouple mojo shell from the network service. (Closed) Base URL: https://github.com/domokit/mojo.git@build-rule-for-the-network-service
Patch Set: Created 6 years 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/shell/android/mojo_main.h" 5 #include "mojo/shell/android/mojo_main.h"
6 6
7 #include "base/android/command_line_android.h" 7 #include "base/android/command_line_android.h"
8 #include "base/android/java_handler_thread.h" 8 #include "base/android/java_handler_thread.h"
9 #include "base/android/jni_android.h"
9 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
10 #include "base/at_exit.h" 11 #include "base/at_exit.h"
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/command_line.h" 13 #include "base/command_line.h"
13 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
17 #include "jni/MojoMain_jni.h" 18 #include "jni/MojoMain_jni.h"
18 #include "mojo/application_manager/application_loader.h" 19 #include "mojo/application_manager/application_loader.h"
(...skipping 25 matching lines...) Expand all
44 it != app_urls.end(); ++it) { 45 it != app_urls.end(); ++it) {
45 context->Run(*it); 46 context->Run(*it);
46 } 47 }
47 } 48 }
48 49
49 } // namespace 50 } // namespace
50 51
51 static void Init(JNIEnv* env, 52 static void Init(JNIEnv* env,
52 jclass clazz, 53 jclass clazz,
53 jobject context, 54 jobject context,
54 jobjectArray jparameters) { 55 jobjectArray jparameters,
56 jstring j_local_apps_directory) {
55 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context); 57 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context);
56
57 base::android::InitApplicationContext(env, scoped_context); 58 base::android::InitApplicationContext(env, scoped_context);
58 59
59 base::android::InitNativeCommandLineFromJavaArray(env, jparameters); 60 base::android::InitNativeCommandLineFromJavaArray(env, jparameters);
60 mojo::shell::InitializeLogging(); 61 mojo::shell::InitializeLogging();
61 62
62 // We want ~MessageLoop to happen prior to ~Context. Initializing 63 // We want ~MessageLoop to happen prior to ~Context. Initializing
63 // LazyInstances is akin to stack-allocating objects; their destructors 64 // LazyInstances is akin to stack-allocating objects; their destructors
64 // will be invoked first-in-last-out. 65 // will be invoked first-in-last-out.
65 shell::Context* shell_context = new shell::Context(); 66 shell::Context* shell_context = new shell::Context();
67 shell_context->mojo_url_resolver()->SetLocalAppsPath(base::FilePath(
68 base::android::ConvertJavaStringToUTF8(env, j_local_apps_directory)));
66 g_context.Get().reset(shell_context); 69 g_context.Get().reset(shell_context);
70
67 g_java_message_loop.Get().reset(new base::MessageLoopForUI); 71 g_java_message_loop.Get().reset(new base::MessageLoopForUI);
68 base::MessageLoopForUI::current()->Start(); 72 base::MessageLoopForUI::current()->Start();
69 73
70 // TODO(abarth): At which point should we switch to cross-platform 74 // TODO(abarth): At which point should we switch to cross-platform
71 // initialization? 75 // initialization?
72 76
73 gfx::GLSurface::InitializeOneOff(); 77 gfx::GLSurface::InitializeOneOff();
74 } 78 }
75 79
76 static void Start(JNIEnv* env, jclass clazz, jstring jurl) { 80 static void Start(JNIEnv* env, jclass clazz, jstring jurl) {
(...skipping 12 matching lines...) Expand all
89 g_shell_thread.Get()->Start(); 93 g_shell_thread.Get()->Start();
90 g_shell_thread.Get()->message_loop()->PostTask( 94 g_shell_thread.Get()->message_loop()->PostTask(
91 FROM_HERE, base::Bind(&RunShell, app_urls)); 95 FROM_HERE, base::Bind(&RunShell, app_urls));
92 } 96 }
93 97
94 bool RegisterMojoMain(JNIEnv* env) { 98 bool RegisterMojoMain(JNIEnv* env) {
95 return RegisterNativesImpl(env); 99 return RegisterNativesImpl(env);
96 } 100 }
97 101
98 } // namespace mojo 102 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698