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

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

Issue 10580038: Allow OpenSSLPrivateKeyStore and Android global app context leaking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
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"
11 #include "base/atomicops.h" 11 #include "base/atomicops.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/threading/platform_thread.h" 14 #include "base/threading/platform_thread.h"
15 15
16 namespace { 16 namespace {
17 using base::android::GetClass; 17 using base::android::GetClass;
18 using base::android::GetMethodID; 18 using base::android::GetMethodID;
19 using base::android::ScopedJavaLocalRef; 19 using base::android::ScopedJavaLocalRef;
20 20
21 JavaVM* g_jvm = NULL; 21 JavaVM* g_jvm = NULL;
22 22
23 base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject> > 23 // We allow the global app context to be leaked, because it is used from a
24 // non-joinable worker that is not stopped on shutdown and there is no harm
25 // to leak it.
Ryan Sleevi 2012/09/05 17:29:00 style nit: Don't use "We" in comments. Broader co
Ryan Sleevi 2012/09/05 17:29:00 nit: Within an unnamed namespace, try to preserve
Johnny(Jianning) Ding 2012/09/06 10:34:44 Done.
Johnny(Jianning) Ding 2012/09/06 10:34:44 Done.
26 base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject> >::Leaky
24 g_application_context = LAZY_INSTANCE_INITIALIZER; 27 g_application_context = LAZY_INSTANCE_INITIALIZER;
25 28
26 struct MethodIdentifier { 29 struct MethodIdentifier {
27 const char* class_name; 30 const char* class_name;
28 const char* method; 31 const char* method;
29 const char* jni_signature; 32 const char* jni_signature;
30 33
31 bool operator<(const MethodIdentifier& other) const { 34 bool operator<(const MethodIdentifier& other) const {
32 int r = strcmp(class_name, other.class_name); 35 int r = strcmp(class_name, other.class_name);
33 if (r < 0) { 36 if (r < 0) {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 297 }
295 298
296 bool ClearException(JNIEnv* env) { 299 bool ClearException(JNIEnv* env) {
297 if (!HasException(env)) 300 if (!HasException(env))
298 return false; 301 return false;
299 env->ExceptionDescribe(); 302 env->ExceptionDescribe();
300 env->ExceptionClear(); 303 env->ExceptionClear();
301 return true; 304 return true;
302 } 305 }
303 306
304 void CheckException(JNIEnv* env) { 307 void CheckException(JNIEnv* env) {
Ryan Sleevi 2012/09/05 17:29:00 Here's where the comments could be cleaned up.
Johnny(Jianning) Ding 2012/09/06 10:34:44 Done.
305 if (!HasException(env)) return; 308 if (!HasException(env)) return;
306 309
307 // Ugh, we are going to die, might as well tell breakpad about it. 310 // Ugh, we are going to die, might as well tell breakpad about it.
308 jthrowable java_throwable = env->ExceptionOccurred(); 311 jthrowable java_throwable = env->ExceptionOccurred();
309 if (!java_throwable) { 312 if (!java_throwable) {
310 // Nothing we can do. 313 // Nothing we can do.
311 CHECK(false); 314 CHECK(false);
312 } 315 }
313 316
314 // Clear the pending exception, we do have a reference to it. 317 // Clear the pending exception, we do have a reference to it.
315 env->ExceptionClear(); 318 env->ExceptionClear();
316 319
317 // Set the exception_string in BuildInfo so that breakpad can read it. 320 // Set the exception_string in BuildInfo so that breakpad can read it.
318 // RVO should avoid any extra copies of the exception string. 321 // RVO should avoid any extra copies of the exception string.
319 base::android::BuildInfo::GetInstance()->set_java_exception_info( 322 base::android::BuildInfo::GetInstance()->set_java_exception_info(
320 GetJavaExceptionInfo(env, java_throwable)); 323 GetJavaExceptionInfo(env, java_throwable));
321 324
322 // Now, feel good about it and die. 325 // Now, feel good about it and die.
323 CHECK(false); 326 CHECK(false);
324 } 327 }
325 328
326 } // namespace android 329 } // namespace android
327 } // namespace base 330 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | net/base/openssl_private_key_store_android.cc » ('j') | net/base/openssl_private_key_store_android.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698