| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BASE_ANDROID_LIBRARY_LOADER_LIBRARY_LOADER_HOOKS_H_ | |
| 6 #define BASE_ANDROID_LIBRARY_LOADER_LIBRARY_LOADER_HOOKS_H_ | |
| 7 | |
| 8 #include <jni.h> | |
| 9 | |
| 10 #include "base/base_export.h" | |
| 11 | |
| 12 namespace base { | |
| 13 namespace android { | |
| 14 | |
| 15 // The process the shared library is loaded in. | |
| 16 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.base.library_loader | |
| 17 enum LibraryProcessType { | |
| 18 // The LibraryLoad has not been initialized. | |
| 19 PROCESS_UNINITIALIZED = 0, | |
| 20 // Shared library is running in browser process. | |
| 21 PROCESS_BROWSER = 1, | |
| 22 // Shared library is running in child process. | |
| 23 PROCESS_CHILD = 2, | |
| 24 // Shared library is running in webview process. | |
| 25 PROCESS_WEBVIEW = 3, | |
| 26 }; | |
| 27 | |
| 28 // Record any pending renderer histogram value as a histogram. Pending values | |
| 29 // are set by RegisterChromiumAndroidLinkerRendererHistogram. | |
| 30 BASE_EXPORT void RecordChromiumAndroidLinkerRendererHistogram(); | |
| 31 | |
| 32 // Registers the callbacks that allows the entry point of the library to be | |
| 33 // exposed to the calling java code. This handles only registering the | |
| 34 // the callbacks needed by the loader. Any application specific JNI bindings | |
| 35 // should happen once the native library has fully loaded, either in the library | |
| 36 // loaded hook function or later. | |
| 37 BASE_EXPORT bool RegisterLibraryLoaderEntryHook(JNIEnv* env); | |
| 38 | |
| 39 // Typedef for hook function to be called (indirectly from Java) once the | |
| 40 // libraries are loaded. The hook function should register the JNI bindings | |
| 41 // required to start the application. It should return true for success and | |
| 42 // false for failure. | |
| 43 // Note: this can't use base::Callback because there is no way of initializing | |
| 44 // the default callback without using static objects, which we forbid. | |
| 45 typedef bool LibraryLoadedHook(JNIEnv* env, | |
| 46 jclass clazz); | |
| 47 | |
| 48 // Set the hook function to be called (from Java) once the libraries are loaded. | |
| 49 // SetLibraryLoadedHook may only be called from JNI_OnLoad. The hook function | |
| 50 // should register the JNI bindings required to start the application. | |
| 51 | |
| 52 BASE_EXPORT void SetLibraryLoadedHook(LibraryLoadedHook* func); | |
| 53 | |
| 54 // Pass the version name to the loader. This used to check that the library | |
| 55 // version matches the version expected by Java before completing JNI | |
| 56 // registration. | |
| 57 // Note: argument must remain valid at least until library loading is complete. | |
| 58 BASE_EXPORT void SetVersionNumber(const char* version_number); | |
| 59 | |
| 60 // Call on exit to delete the AtExitManager which OnLibraryLoadedOnUIThread | |
| 61 // created. | |
| 62 BASE_EXPORT void LibraryLoaderExitHook(); | |
| 63 | |
| 64 // Return the process type the shared library is loaded in. | |
| 65 BASE_EXPORT LibraryProcessType GetLibraryProcessType(JNIEnv* env); | |
| 66 | |
| 67 // Initialize AtExitManager, this must be done at the begining of loading | |
| 68 // shared library. | |
| 69 void InitAtExitManager(); | |
| 70 | |
| 71 } // namespace android | |
| 72 } // namespace base | |
| 73 | |
| 74 #endif // BASE_ANDROID_LIBRARY_LOADER_LIBRARY_LOADER_HOOKS_H_ | |
| OLD | NEW |