OLD | NEW |
1 // Copyright (c) 2011 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/atomicops.h" | 9 #include "base/atomicops.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 jfieldID GetFieldID(JNIEnv* env, | 150 jfieldID GetFieldID(JNIEnv* env, |
151 jclass clazz, | 151 jclass clazz, |
152 const char* field, | 152 const char* field, |
153 const char* jni_signature) { | 153 const char* jni_signature) { |
154 jfieldID id = env->GetFieldID(clazz, field, jni_signature); | 154 jfieldID id = env->GetFieldID(clazz, field, jni_signature); |
155 DCHECK(id) << field; | 155 DCHECK(id) << field; |
156 CheckException(env); | 156 CheckException(env); |
157 return id; | 157 return id; |
158 } | 158 } |
159 | 159 |
160 bool CheckException(JNIEnv* env) { | 160 bool HasException(JNIEnv* env) { |
161 if (env->ExceptionCheck() == JNI_FALSE) | 161 return env->ExceptionCheck() != JNI_FALSE; |
| 162 } |
| 163 |
| 164 bool ClearException(JNIEnv* env) { |
| 165 if (!HasException(env)) |
162 return false; | 166 return false; |
163 env->ExceptionDescribe(); | |
164 env->ExceptionClear(); | 167 env->ExceptionClear(); |
165 return true; | 168 return true; |
166 } | 169 } |
167 | 170 |
| 171 void CheckException(JNIEnv* env) { |
| 172 if (HasException(env)) { |
| 173 env->ExceptionDescribe(); |
| 174 CHECK(false); |
| 175 } |
| 176 } |
| 177 |
168 } // namespace android | 178 } // namespace android |
169 } // namespace base | 179 } // namespace base |
OLD | NEW |