OLD | NEW |
---|---|
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 #ifndef BASE_ANDROID_JNI_GENERATOR_JNI_GENERATOR_HELPER_H_ | 5 #ifndef BASE_ANDROID_JNI_GENERATOR_JNI_GENERATOR_HELPER_H_ |
6 #define BASE_ANDROID_JNI_GENERATOR_JNI_GENERATOR_HELPER_H_ | 6 #define BASE_ANDROID_JNI_GENERATOR_JNI_GENERATOR_HELPER_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
11 #include "base/android/library_loader/library_loader_hooks.h" | |
11 #include "base/android/scoped_java_ref.h" | 12 #include "base/android/scoped_java_ref.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
14 | 15 |
15 // Project-specific macros used by the header files generated by | 16 // Project-specific macros used by the header files generated by |
16 // jni_generator.py. Different projects can then specify their own | 17 // jni_generator.py. Different projects can then specify their own |
17 // implementation for this file. | 18 // implementation for this file. |
18 #define CHECK_NATIVE_PTR(env, jcaller, native_ptr, method_name, ...) \ | 19 #define CHECK_NATIVE_PTR(env, jcaller, native_ptr, method_name, ...) \ |
19 DCHECK(native_ptr) << method_name; | 20 DCHECK(native_ptr) << method_name; |
20 | 21 |
(...skipping 14 matching lines...) Expand all Loading... | |
35 inline void HandleRegistrationError(JNIEnv* env, | 36 inline void HandleRegistrationError(JNIEnv* env, |
36 jclass clazz, | 37 jclass clazz, |
37 const char* filename) { | 38 const char* filename) { |
38 LOG(ERROR) << "RegisterNatives failed in " << filename; | 39 LOG(ERROR) << "RegisterNatives failed in " << filename; |
39 } | 40 } |
40 | 41 |
41 inline void CheckException(JNIEnv* env) { | 42 inline void CheckException(JNIEnv* env) { |
42 base::android::CheckException(env); | 43 base::android::CheckException(env); |
43 } | 44 } |
44 | 45 |
46 inline bool ShouldSkipJniRegistration(bool is_maindex_class) { | |
47 base::android::JniRegistrationType jni_type = | |
48 base::android::GetJniRegistrationType(); | |
49 if (jni_type == base::android::NO_JNI_REGISTRATION) { | |
50 // TODO(estevenson): Change this to a DCHECK. | |
51 return true; | |
52 } else if (jni_type == base::android::ALL_JNI_REGISTRATION) { | |
53 return false; | |
54 } else if (jni_type == base::android::SELECTIVE_JNI_REGISTRATION) { | |
55 return !is_maindex_class; | |
56 } else { | |
57 // The registration type isn't always initialized in tests by this point. | |
estevenson
2017/01/09 13:20:00
Not sure about this. In instrumentation tests the
Torne
2017/01/09 16:43:32
I don't think it's okay that we ever see PROCESS_U
estevenson
2017/01/12 03:46:49
Added init code everywhere necessary for tests.
| |
58 return false; | |
59 } | |
60 } | |
61 | |
45 } // namespace jni_generator | 62 } // namespace jni_generator |
46 | 63 |
47 #endif // BASE_ANDROID_JNI_GENERATOR_JNI_GENERATOR_HELPER_H_ | 64 #endif // BASE_ANDROID_JNI_GENERATOR_JNI_GENERATOR_HELPER_H_ |
OLD | NEW |