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

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

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
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_onload_delegate.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"
11 10
12 namespace base { 11 namespace base {
13 namespace android { 12 namespace android {
14 13
15 namespace { 14 namespace {
16 15
17 bool RegisterJNI(JNIEnv* env) { 16 // The JNIOnLoadDelegate implementation in base.
17 class BaseJNIOnLoadDelegate : public JNIOnLoadDelegate {
18 public:
19 bool RegisterJNI(JNIEnv* env) override;
20 bool Init() override;
21 };
22
23 bool BaseJNIOnLoadDelegate::RegisterJNI(JNIEnv* env) {
18 return RegisterLibraryLoaderEntryHook(env); 24 return RegisterLibraryLoaderEntryHook(env);
19 } 25 }
20 26
21 bool Init() { 27 bool BaseJNIOnLoadDelegate::Init() {
22 JNIEnv* env = base::android::AttachCurrentThread();
23 base::android::InitReplacementClassLoader(env,
24 base::android::GetClassLoader(env));
25 return true; 28 return true;
26 } 29 }
27 30
28 } // namespace 31 } // namespace
29 32
30 33
31 bool OnJNIOnLoadRegisterJNI(JavaVM* vm, 34 bool OnJNIOnLoad(JavaVM* vm,
32 std::vector<RegisterCallback> callbacks) { 35 std::vector<JNIOnLoadDelegate*>* delegates) {
33 base::android::InitVM(vm); 36 base::android::InitVM(vm);
34 JNIEnv* env = base::android::AttachCurrentThread(); 37 JNIEnv* env = base::android::AttachCurrentThread();
35 38
36 callbacks.push_back(base::Bind(&RegisterJNI)); 39 BaseJNIOnLoadDelegate delegate;
37 for (std::vector<RegisterCallback>::reverse_iterator i = 40 delegates->push_back(&delegate);
38 callbacks.rbegin(); i != callbacks.rend(); ++i) { 41 bool ret = true;
39 if (!i->Run(env)) 42 for (std::vector<JNIOnLoadDelegate*>::reverse_iterator i =
40 return false; 43 delegates->rbegin(); i != delegates->rend(); ++i) {
44 if (!(*i)->RegisterJNI(env)) {
45 ret = false;
46 break;
47 }
41 } 48 }
42 return true;
43 }
44 49
45 bool OnJNIOnLoadInit(std::vector<InitCallback> callbacks) { 50 if (ret) {
46 callbacks.push_back(base::Bind(&Init)); 51 for (std::vector<JNIOnLoadDelegate*>::reverse_iterator i =
47 for (std::vector<InitCallback>::reverse_iterator i = 52 delegates->rbegin(); i != delegates->rend(); ++i) {
48 callbacks.rbegin(); i != callbacks.rend(); ++i) { 53 if (!(*i)->Init()) {
49 if (!i->Run()) 54 ret = false;
50 return false; 55 break;
56 }
57 }
51 } 58 }
52 return true; 59 delegates->pop_back();
60 return ret;
53 } 61 }
54 62
55 } // namespace android 63 } // namespace android
56 } // namespace base 64 } // namespace base
OLDNEW
« no previous file with comments | « base/android/base_jni_onload.h ('k') | base/android/java/src/org/chromium/base/ResourceExtractor.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698