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_LIBRARY_LOADER_HOOKS_H_ | 5 #ifndef BASE_ANDROID_LIBRARY_LOADER_HOOKS_H_ |
6 #define BASE_ANDROID_LIBRARY_LOADER_HOOKS_H_ | 6 #define BASE_ANDROID_LIBRARY_LOADER_HOOKS_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 namespace android { | 13 namespace android { |
14 | 14 |
15 // Registers the callbacks that allows the entry point of the library to be | 15 // Registers the callbacks that allows the entry point of the library to be |
16 // exposed to the calling java code. This handles only registering the | 16 // exposed to the calling java code. This handles only registering the |
17 // the callbacks needed by the loader. Any application specific JNI bindings | 17 // the callbacks needed by the loader. Any application specific JNI bindings |
18 // should happen once the native library has fully loaded, either in the library | 18 // should happen once the native library has fully loaded, either in the library |
19 // loaded hook function or later. | 19 // loaded hook function or later. |
20 BASE_EXPORT bool RegisterLibraryLoaderEntryHook(JNIEnv* env); | 20 BASE_EXPORT bool RegisterLibraryLoaderEntryHook(JNIEnv* env); |
21 | 21 |
22 // Typedef for hook function to be called (indirectly from Java) once the | 22 // Typedef for hook function to be called (indirectly from Java) once the |
23 // libraries are loaded. The hook function should register the JNI bindings | 23 // libraries are loaded. The hook function should register the JNI bindings |
24 // required to start the application. It should return true for success and | 24 // required to start the application. It should return true for success and |
25 // false for failure. | 25 // false for failure. |
26 // Note: this can't use base::Callback because there is no way of initializing | 26 // Note: this can't use base::Callback because there is no way of initializing |
27 // the default callback without using static objects, which we forbid. | 27 // the default callback without using static objects, which we forbid. |
28 typedef bool LibraryLoadedHook(JNIEnv* env, | 28 typedef bool LibraryLoadedHook(JNIEnv* env, jclass clazz); |
29 jclass clazz, | |
30 jobjectArray init_command_line); | |
31 | 29 |
32 // Set the hook function to be called (from Java) once the libraries are loaded. | 30 // Set the hook function to be called (from Java) once the libraries are loaded. |
33 // SetLibraryLoadedHook may only be called from JNI_OnLoad. The hook function | 31 // SetLibraryLoadedHook may only be called from JNI_OnLoad. The hook function |
34 // should register the JNI bindings required to start the application. | 32 // should register the JNI bindings required to start the application. |
35 | 33 |
36 BASE_EXPORT void SetLibraryLoadedHook(LibraryLoadedHook* func); | 34 BASE_EXPORT void SetLibraryLoadedHook(LibraryLoadedHook* func); |
37 | 35 |
38 // Pass the version name to the loader. This used to check that the library | 36 // Pass the version name to the loader. This used to check that the library |
39 // version matches the version expected by Java before completing JNI | 37 // version matches the version expected by Java before completing JNI |
40 // registration. | 38 // registration. |
41 // Note: argument must remain valid at least until library loading is complete. | 39 // Note: argument must remain valid at least until library loading is complete. |
42 BASE_EXPORT void SetVersionNumber(const char* version_number); | 40 BASE_EXPORT void SetVersionNumber(const char* version_number); |
43 | 41 |
44 // Call on exit to delete the AtExitManager which OnLibraryLoadedOnUIThread | 42 // Call on exit to delete the AtExitManager which OnLibraryLoadedOnUIThread |
45 // created. | 43 // created. |
46 BASE_EXPORT void LibraryLoaderExitHook(); | 44 BASE_EXPORT void LibraryLoaderExitHook(); |
47 | 45 |
48 } // namespace android | 46 } // namespace android |
49 } // namespace base | 47 } // namespace base |
50 | 48 |
51 #endif // BASE_ANDROID_LIBRARY_LOADER_HOOKS_H_ | 49 #endif // BASE_ANDROID_LIBRARY_LOADER_HOOKS_H_ |
OLD | NEW |