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 "base/android/field_trial_list.h" | 5 #include "base/android/field_trial_list.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "jni/FieldTrialList_jni.h" | 11 #include "jni/FieldTrialList_jni.h" |
12 | 12 |
13 using base::android::ConvertJavaStringToUTF8; | 13 using base::android::ConvertJavaStringToUTF8; |
14 using base::android::ConvertUTF8ToJavaString; | 14 using base::android::ConvertUTF8ToJavaString; |
| 15 using base::android::JavaParamRef; |
| 16 using base::android::ScopedJavaLocalRef; |
15 | 17 |
16 static ScopedJavaLocalRef<jstring> FindFullName( | 18 static ScopedJavaLocalRef<jstring> FindFullName( |
17 JNIEnv* env, | 19 JNIEnv* env, |
18 const JavaParamRef<jclass>& clazz, | 20 const JavaParamRef<jclass>& clazz, |
19 const JavaParamRef<jstring>& jtrial_name) { | 21 const JavaParamRef<jstring>& jtrial_name) { |
20 std::string trial_name(ConvertJavaStringToUTF8(env, jtrial_name)); | 22 std::string trial_name(ConvertJavaStringToUTF8(env, jtrial_name)); |
21 return ConvertUTF8ToJavaString( | 23 return ConvertUTF8ToJavaString( |
22 env, base::FieldTrialList::FindFullName(trial_name)); | 24 env, base::FieldTrialList::FindFullName(trial_name)); |
23 } | 25 } |
24 | 26 |
25 static jboolean TrialExists(JNIEnv* env, | 27 static jboolean TrialExists(JNIEnv* env, |
26 const JavaParamRef<jclass>& clazz, | 28 const JavaParamRef<jclass>& clazz, |
27 const JavaParamRef<jstring>& jtrial_name) { | 29 const JavaParamRef<jstring>& jtrial_name) { |
28 std::string trial_name(ConvertJavaStringToUTF8(env, jtrial_name)); | 30 std::string trial_name(ConvertJavaStringToUTF8(env, jtrial_name)); |
29 return base::FieldTrialList::TrialExists(trial_name); | 31 return base::FieldTrialList::TrialExists(trial_name); |
30 } | 32 } |
31 | 33 |
32 namespace base { | 34 namespace base { |
33 namespace android { | 35 namespace android { |
34 | 36 |
35 bool RegisterFieldTrialList(JNIEnv* env) { | 37 bool RegisterFieldTrialList(JNIEnv* env) { |
36 return RegisterNativesImpl(env); | 38 return RegisterNativesImpl(env); |
37 } | 39 } |
38 | 40 |
39 } // namespace android | 41 } // namespace android |
40 } // namespace base | 42 } // namespace base |
OLD | NEW |