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

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

Issue 1407233017: Define a Java-side global application context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // needed. 44 // needed.
45 // 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()!
46 base::NativeLibrary app_library = LoadNativeApplication(app_path); 46 base::NativeLibrary app_library = LoadNativeApplication(app_path);
47 if (!app_library) 47 if (!app_library)
48 return; 48 return;
49 49
50 // Set the application context if needed. Most applications will need to 50 // Set the application context if needed. Most applications will need to
51 // access the Android ApplicationContext in which they are run. If the 51 // access the Android ApplicationContext in which they are run. If the
52 // application library exports the InitApplicationContext function, we will 52 // application library exports the InitApplicationContext function, we will
53 // set it there. 53 // set it there.
54 // TODO: what to do about this?
Torne 2015/11/06 16:43:19 Mojo folks: is it reasonable to remove this mechan
qsr 2015/11/13 14:36:06 Unfortunately, I don't think you can do this.
54 const char* init_application_context_name = "InitApplicationContext"; 55 const char* init_application_context_name = "InitApplicationContext";
55 typedef void (*InitApplicationContextFn)( 56 typedef void (*InitApplicationContextFn)(
56 const base::android::JavaRef<jobject>&); 57 const base::android::JavaRef<jobject>&);
57 InitApplicationContextFn init_application_context = 58 InitApplicationContextFn init_application_context =
58 reinterpret_cast<InitApplicationContextFn>( 59 reinterpret_cast<InitApplicationContextFn>(
59 base::GetFunctionPointerFromNativeLibrary( 60 base::GetFunctionPointerFromNativeLibrary(
60 app_library, init_application_context_name)); 61 app_library, init_application_context_name));
61 if (init_application_context) { 62 if (init_application_context) {
62 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, j_context); 63 base::android::ScopedJavaLocalRef<jobject> scoped_context(env, j_context);
63 init_application_context(scoped_context); 64 init_application_context(scoped_context);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 connection->AddService(&content_handler_factory_); 172 connection->AddService(&content_handler_factory_);
172 return true; 173 return true;
173 } 174 }
174 175
175 bool RegisterAndroidHandlerJni(JNIEnv* env) { 176 bool RegisterAndroidHandlerJni(JNIEnv* env) {
176 return RegisterNativesImpl(env); 177 return RegisterNativesImpl(env);
177 } 178 }
178 179
179 } // namespace runner 180 } // namespace runner
180 } // namespace mojo 181 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698