Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: base/android/base_jni_onload.cc

Issue 2620303004: Remove JNI onload callback vector construction in favour of direct calls. (Closed)
Patch Set: rebase compile errors Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/android/base_jni_onload.h ('k') | chrome/app/android/chrome_jni_onload.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "base/android/base_jni_onload.h" 5 #include "base/android/base_jni_onload.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_utils.h" 8 #include "base/android/jni_utils.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 11
12 namespace base { 12 namespace base {
13 namespace android { 13 namespace android {
14 14
15 namespace { 15 bool OnJNIOnLoadRegisterJNI(JNIEnv* env) {
16
17 bool RegisterJNI(JNIEnv* env) {
18 return RegisterLibraryLoaderEntryHook(env); 16 return RegisterLibraryLoaderEntryHook(env);
19 } 17 }
20 18
21 bool Init() { 19 bool OnJNIOnLoadInit() {
22 InitAtExitManager(); 20 InitAtExitManager();
23 JNIEnv* env = base::android::AttachCurrentThread(); 21 JNIEnv* env = base::android::AttachCurrentThread();
24 base::android::InitReplacementClassLoader(env, 22 base::android::InitReplacementClassLoader(env,
25 base::android::GetClassLoader(env)); 23 base::android::GetClassLoader(env));
26 return true; 24 return true;
27 } 25 }
28 26
29 } // namespace
30
31
32 bool OnJNIOnLoadRegisterJNI(JavaVM* vm,
33 std::vector<RegisterCallback> callbacks) {
34 base::android::InitVM(vm);
35 JNIEnv* env = base::android::AttachCurrentThread();
36
37 callbacks.push_back(base::Bind(&RegisterJNI));
38 for (std::vector<RegisterCallback>::reverse_iterator i =
39 callbacks.rbegin(); i != callbacks.rend(); ++i) {
40 if (!i->Run(env))
41 return false;
42 }
43 return true;
44 }
45
46 bool OnJNIOnLoadInit(std::vector<InitCallback> callbacks) {
47 callbacks.push_back(base::Bind(&Init));
48 for (std::vector<InitCallback>::reverse_iterator i =
49 callbacks.rbegin(); i != callbacks.rend(); ++i) {
50 if (!i->Run())
51 return false;
52 }
53 return true;
54 }
55
56 } // namespace android 27 } // namespace android
57 } // namespace base 28 } // namespace base
OLDNEW
« no previous file with comments | « base/android/base_jni_onload.h ('k') | chrome/app/android/chrome_jni_onload.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698