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

Side by Side Diff: base/android/jni_android.cc

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/android/jni_android.h" 5 #include "base/android/jni_android.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/android/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 152 }
153 153
154 const jobject GetApplicationContext() { 154 const jobject GetApplicationContext() {
155 DCHECK(!g_application_context.Get().is_null()); 155 DCHECK(!g_application_context.Get().is_null());
156 return g_application_context.Get().obj(); 156 return g_application_context.Get().obj();
157 } 157 }
158 158
159 ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env, const char* class_name) { 159 ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env, const char* class_name) {
160 jclass clazz; 160 jclass clazz;
161 if (!g_class_loader.Get().is_null()) { 161 if (!g_class_loader.Get().is_null()) {
162 // ClassLoader.loadClass expects a classname with components separated by
163 // dots instead of the slashes that JNIEnv::FindClass expects. The JNI
164 // generator generates names with slashes, so we have to replace them here.
165 // TODO(torne): move to an approach where we always use ClassLoader except
166 // for the special case of base::android::GetClassLoader(), and change the
167 // JNI generator to generate dot-separated names. http://crbug.com/461773
168 size_t bufsize = strlen(class_name) + 1;
169 char dotted_name[bufsize];
170 memmove(dotted_name, class_name, bufsize);
171 for (size_t i = 0; i < bufsize; ++i) {
172 if (dotted_name[i] == '/') {
173 dotted_name[i] = '.';
174 }
175 }
176
162 clazz = static_cast<jclass>( 177 clazz = static_cast<jclass>(
163 env->CallObjectMethod(g_class_loader.Get().obj(), 178 env->CallObjectMethod(g_class_loader.Get().obj(),
164 g_class_loader_load_class_method_id, 179 g_class_loader_load_class_method_id,
165 ConvertUTF8ToJavaString(env, class_name).obj())); 180 ConvertUTF8ToJavaString(env, dotted_name).obj()));
166 } else { 181 } else {
167 clazz = env->FindClass(class_name); 182 clazz = env->FindClass(class_name);
168 } 183 }
169 CHECK(!ClearException(env) && clazz) << "Failed to find class " << class_name; 184 CHECK(!ClearException(env) && clazz) << "Failed to find class " << class_name;
170 return ScopedJavaLocalRef<jclass>(env, clazz); 185 return ScopedJavaLocalRef<jclass>(env, clazz);
171 } 186 }
172 187
173 jclass LazyGetClass( 188 jclass LazyGetClass(
174 JNIEnv* env, 189 JNIEnv* env,
175 const char* class_name, 190 const char* class_name,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 base::android::BuildInfo::GetInstance()->set_java_exception_info( 290 base::android::BuildInfo::GetInstance()->set_java_exception_info(
276 GetJavaExceptionInfo(env, java_throwable)); 291 GetJavaExceptionInfo(env, java_throwable));
277 } 292 }
278 293
279 // Now, feel good about it and die. 294 // Now, feel good about it and die.
280 CHECK(false) << "Please include Java exception stack in crash report"; 295 CHECK(false) << "Please include Java exception stack in crash report";
281 } 296 }
282 297
283 } // namespace android 298 } // namespace android
284 } // namespace base 299 } // namespace base
OLDNEW
« no previous file with comments | « base/android/javatests/src/org/chromium/base/metrics/RecordHistogramTest.java ('k') | base/android/record_histogram.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698