OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_ANDROID_JNI_ONLOAD_DELEGATE_H_ | |
6 #define BASE_ANDROID_JNI_ONLOAD_DELEGATE_H_ | |
7 | |
8 #include <jni.h> | |
9 | |
10 #include "base/base_export.h" | |
11 | |
12 namespace base { | |
13 namespace android { | |
14 | |
15 // This delegate class is used to implement component specific JNI registration | |
16 // and initialization. All methods are called in JNI_OnLoad(). | |
17 // | |
18 // Both RegisterJNI() and Init() methods are called if the shared library | |
19 // is loaded by crazy linker that can't find JNI methods without JNI | |
20 // registration, otherwise, only Init() is invoked where dynamic lookup is | |
21 // used to find the JNI methods. | |
22 // | |
23 // It is important to make sure the JNI registration code is only in | |
24 // RegisterJNI(), so it could be stripped out when JNI registration isn't | |
25 // needed. | |
26 class BASE_EXPORT JNIOnLoadDelegate { | |
27 public: | |
28 virtual ~JNIOnLoadDelegate() {} | |
29 | |
30 // Returns whether the JNI registration succeeded. | |
31 virtual bool RegisterJNI(JNIEnv* env) = 0; | |
32 | |
33 // Returns whether the initialization succeeded. This method is called after | |
34 // RegisterJNI(), all JNI methods shall ready to be used. | |
35 virtual bool Init() = 0; | |
36 }; | |
37 | |
38 } // namespace android | |
39 } // namespace base | |
40 | |
41 #endif // BASE_ANDROID_JNI_ONLOAD_DELEGATE_H_ | |
OLD | NEW |