xref: /aosp_15_r20/external/cronet/base/android/jni_registrar.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1*6777b538SAndroid Build Coastguard Worker // Copyright 2012 The Chromium Authors
2*6777b538SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*6777b538SAndroid Build Coastguard Worker // found in the LICENSE file.
4*6777b538SAndroid Build Coastguard Worker 
5*6777b538SAndroid Build Coastguard Worker #include "base/android/jni_registrar.h"
6*6777b538SAndroid Build Coastguard Worker 
7*6777b538SAndroid Build Coastguard Worker #include "base/android/jni_android.h"
8*6777b538SAndroid Build Coastguard Worker #include "base/logging.h"
9*6777b538SAndroid Build Coastguard Worker #include "base/trace_event/base_tracing.h"
10*6777b538SAndroid Build Coastguard Worker 
11*6777b538SAndroid Build Coastguard Worker namespace base {
12*6777b538SAndroid Build Coastguard Worker namespace android {
13*6777b538SAndroid Build Coastguard Worker 
RegisterNativeMethods(JNIEnv * env,const RegistrationMethod * method,size_t count)14*6777b538SAndroid Build Coastguard Worker bool RegisterNativeMethods(JNIEnv* env,
15*6777b538SAndroid Build Coastguard Worker                            const RegistrationMethod* method,
16*6777b538SAndroid Build Coastguard Worker                            size_t count) {
17*6777b538SAndroid Build Coastguard Worker   TRACE_EVENT0("startup", "base_android::RegisterNativeMethods");
18*6777b538SAndroid Build Coastguard Worker   const RegistrationMethod* end = method + count;
19*6777b538SAndroid Build Coastguard Worker   while (method != end) {
20*6777b538SAndroid Build Coastguard Worker     if (!method->func(env)) {
21*6777b538SAndroid Build Coastguard Worker       DLOG(ERROR) << method->name << " failed registration!";
22*6777b538SAndroid Build Coastguard Worker       return false;
23*6777b538SAndroid Build Coastguard Worker     }
24*6777b538SAndroid Build Coastguard Worker     method++;
25*6777b538SAndroid Build Coastguard Worker   }
26*6777b538SAndroid Build Coastguard Worker   return true;
27*6777b538SAndroid Build Coastguard Worker }
28*6777b538SAndroid Build Coastguard Worker 
29*6777b538SAndroid Build Coastguard Worker }  // namespace android
30*6777b538SAndroid Build Coastguard Worker }  // namespace base
31