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 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/android/base_jni_onload.h" | 7 #include "base/android/base_jni_onload.h" |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/library_loader/library_loader_hooks.h" | 9 #include "base/android/library_loader/library_loader_hooks.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "components/resource_provider/jni/Main_jni.h" | |
11 #include "net/android/net_jni_registrar.h" | 12 #include "net/android/net_jni_registrar.h" |
12 | 13 |
13 namespace { | 14 namespace { |
14 bool RegisterJNI(JNIEnv* env) { | 15 bool RegisterJNI(JNIEnv* env) { |
15 return net::android::RegisterJni(env); | 16 return net::android::RegisterJni(env); |
16 } | 17 } |
17 | 18 |
18 bool Init() { | 19 bool Init() { |
19 return true; | 20 return true; |
20 } | 21 } |
21 } // namespace | 22 } // namespace |
22 | 23 |
23 | 24 |
24 // This is called by the VM when the shared library is first loaded. | 25 // This is called by the VM when the shared library is first loaded. |
25 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { | 26 JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
26 std::vector<base::android::RegisterCallback> register_callbacks; | 27 std::vector<base::android::RegisterCallback> register_callbacks; |
27 register_callbacks.push_back(base::Bind(&RegisterJNI)); | 28 register_callbacks.push_back(base::Bind(&RegisterJNI)); |
29 register_callbacks.push_back(base::Bind(&RegisterNativesImpl)); | |
28 | 30 |
29 std::vector<base::android::InitCallback> init_callbacks; | 31 std::vector<base::android::InitCallback> init_callbacks; |
30 init_callbacks.push_back(base::Bind(&Init)); | 32 init_callbacks.push_back(base::Bind(&Init)); |
31 | 33 |
32 if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) || | 34 if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) || |
33 !base::android::OnJNIOnLoadInit(init_callbacks)) { | 35 !base::android::OnJNIOnLoadInit(init_callbacks)) { |
34 return -1; | 36 return -1; |
35 } | 37 } |
36 | 38 |
37 // There cannot be two AtExitManagers at the same time. Remove the one from | 39 // There cannot be two AtExitManagers at the same time. Remove the one from |
38 // LibraryLoader as ApplicationRunnerChromium also uses one. | 40 // LibraryLoader as ApplicationRunnerChromium also uses one. |
39 base::android::LibraryLoaderExitHook(); | 41 base::android::LibraryLoaderExitHook(); |
40 | 42 |
41 return JNI_VERSION_1_4; | 43 return JNI_VERSION_1_4; |
42 } | 44 } |
43 | 45 |
44 extern "C" JNI_EXPORT void InitApplicationContext( | 46 extern "C" JNI_EXPORT void InitApplicationContext( |
45 const base::android::JavaRef<jobject>& context) { | 47 const base::android::JavaRef<jobject>& context) { |
46 JNIEnv* env = base::android::AttachCurrentThread(); | 48 JNIEnv* env = base::android::AttachCurrentThread(); |
47 base::android::InitApplicationContext(env, context); | 49 base::android::InitApplicationContext(env, context); |
50 Java_Main_init(env, base::android::GetApplicationContext()); | |
sky
2015/05/13 15:09:04
Main was ok in the context of resource provider, b
| |
48 } | 51 } |
OLD | NEW |