OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/android_handler.h" | 5 #include "mojo/runner/android/android_handler.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 // This function loads the application library, sets the application context and | 32 // This function loads the application library, sets the application context and |
33 // thunks and calls into the application MojoMain. To ensure that the thunks are | 33 // thunks and calls into the application MojoMain. To ensure that the thunks are |
34 // set correctly we keep it in the Mojo shell .so and pass the function pointer | 34 // set correctly we keep it in the Mojo shell .so and pass the function pointer |
35 // to the helper libbootstrap.so. | 35 // to the helper libbootstrap.so. |
36 void RunAndroidApplication(JNIEnv* env, | 36 void RunAndroidApplication(JNIEnv* env, |
37 jobject j_context, | 37 jobject j_context, |
38 const base::FilePath& app_path, | 38 const base::FilePath& app_path, |
39 jint j_handle, | 39 jint j_handle) { |
40 bool is_cached_app) { | |
41 InterfaceRequest<Application> application_request = | 40 InterfaceRequest<Application> application_request = |
42 MakeRequest<Application>(MakeScopedHandle(MessagePipeHandle(j_handle))); | 41 MakeRequest<Application>(MakeScopedHandle(MessagePipeHandle(j_handle))); |
43 | 42 |
44 // Load the library, so that we can set the application context there if | 43 // Load the library, so that we can set the application context there if |
45 // needed. | 44 // needed. |
46 // TODO(vtl): We'd use a ScopedNativeLibrary, but it doesn't have .get()! | 45 // TODO(vtl): We'd use a ScopedNativeLibrary, but it doesn't have .get()! |
47 base::NativeLibrary app_library = LoadNativeApplication( | 46 base::NativeLibrary app_library = LoadNativeApplication(app_path); |
48 app_path, is_cached_app ? shell::NativeApplicationCleanup::DONT_DELETE | |
49 : shell::NativeApplicationCleanup::DELETE); | |
50 if (!app_library) | 47 if (!app_library) |
51 return; | 48 return; |
52 | 49 |
53 // Set the application context if needed. Most applications will need to | 50 // Set the application context if needed. Most applications will need to |
54 // access the Android ApplicationContext in which they are run. If the | 51 // access the Android ApplicationContext in which they are run. If the |
55 // application library exports the InitApplicationContext function, we will | 52 // application library exports the InitApplicationContext function, we will |
56 // set it there. | 53 // set it there. |
57 const char* init_application_context_name = "InitApplicationContext"; | 54 const char* init_application_context_name = "InitApplicationContext"; |
58 typedef void (*InitApplicationContextFn)( | 55 typedef void (*InitApplicationContextFn)( |
59 const base::android::JavaRef<jobject>&); | 56 const base::android::JavaRef<jobject>&); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 connection->AddService(&content_handler_factory_); | 171 connection->AddService(&content_handler_factory_); |
175 return true; | 172 return true; |
176 } | 173 } |
177 | 174 |
178 bool RegisterAndroidHandlerJni(JNIEnv* env) { | 175 bool RegisterAndroidHandlerJni(JNIEnv* env) { |
179 return RegisterNativesImpl(env); | 176 return RegisterNativesImpl(env); |
180 } | 177 } |
181 | 178 |
182 } // namespace runner | 179 } // namespace runner |
183 } // namespace mojo | 180 } // namespace mojo |
OLD | NEW |