Index: base/android/base_jni_onload.cc |
diff --git a/base/android/base_jni_onload.cc b/base/android/base_jni_onload.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..86eef054576554ccbb28b24cbf0fa8e641838c46 |
--- /dev/null |
+++ b/base/android/base_jni_onload.cc |
@@ -0,0 +1,43 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/android/base_jni_onload.h" |
+ |
+#include "base/android/base_jni_onload_delegate.h" |
+#include "base/android/jni_android.h" |
+ |
+namespace base { |
+namespace android { |
+ |
+bool OnJNIOnLoad(JavaVM* vm, |
+ std::vector<JNIOnLoadDelegate*>* delegates) { |
+ base::android::InitVM(vm); |
+ JNIEnv* env = base::android::AttachCurrentThread(); |
+ |
+ BaseJNIOnLoadDelegate delegate; |
+ delegates->push_back(&delegate); |
+ bool ret = true; |
+ for (std::vector<JNIOnLoadDelegate*>::reverse_iterator i = |
+ delegates->rbegin(); i != delegates->rend(); ++i) { |
+ if (!(*i)->RegisterJNI(env)) { |
+ ret = false; |
+ break; |
+ } |
+ } |
+ |
+ if (ret) { |
+ for (std::vector<JNIOnLoadDelegate*>::reverse_iterator i = |
+ delegates->rbegin(); i != delegates->rend(); ++i) { |
+ if (!(*i)->Init()) { |
+ ret = false; |
+ break; |
+ } |
+ } |
+ } |
+ delegates->pop_back(); |
+ return ret; |
+} |
+ |
+} // namespace android |
+} // namespace base |