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

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

Issue 54923002: Android: Allow duplicate calls to InitApplicationContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « base/android/jni_android.h ('k') | content/app/android/content_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 void InitVM(JavaVM* vm) { 91 void InitVM(JavaVM* vm) {
92 DCHECK(!g_jvm); 92 DCHECK(!g_jvm);
93 g_jvm = vm; 93 g_jvm = vm;
94 } 94 }
95 95
96 bool IsVMInitialized() { 96 bool IsVMInitialized() {
97 return g_jvm != NULL; 97 return g_jvm != NULL;
98 } 98 }
99 99
100 void InitApplicationContext(const JavaRef<jobject>& context) { 100 void InitApplicationContext(JNIEnv* env, const JavaRef<jobject>& context) {
101 if (env->IsSameObject(g_application_context.Get().obj(), context.obj())) {
102 // It's safe to set the context more than once if it's the same context.
103 return;
104 }
101 DCHECK(g_application_context.Get().is_null()); 105 DCHECK(g_application_context.Get().is_null());
102 g_application_context.Get().Reset(context); 106 g_application_context.Get().Reset(context);
103 } 107 }
104 108
105 const jobject GetApplicationContext() { 109 const jobject GetApplicationContext() {
106 DCHECK(!g_application_context.Get().is_null()); 110 DCHECK(!g_application_context.Get().is_null());
107 return g_application_context.Get().obj(); 111 return g_application_context.Get().obj();
108 } 112 }
109 113
110 ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env, const char* class_name) { 114 ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env, const char* class_name) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // RVO should avoid any extra copies of the exception string. 199 // RVO should avoid any extra copies of the exception string.
196 base::android::BuildInfo::GetInstance()->set_java_exception_info( 200 base::android::BuildInfo::GetInstance()->set_java_exception_info(
197 GetJavaExceptionInfo(env, java_throwable)); 201 GetJavaExceptionInfo(env, java_throwable));
198 202
199 // Now, feel good about it and die. 203 // Now, feel good about it and die.
200 CHECK(false); 204 CHECK(false);
201 } 205 }
202 206
203 } // namespace android 207 } // namespace android
204 } // namespace base 208 } // namespace base
OLDNEW
« no previous file with comments | « base/android/jni_android.h ('k') | content/app/android/content_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698