diff options
author | maxbogue@chromium.org <maxbogue@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-21 13:23:26 +0000 |
---|---|---|
committer | maxbogue@chromium.org <maxbogue@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-21 13:23:26 +0000 |
commit | 31fd046884ae4bec8946a3a5e2007411763beb09 (patch) | |
tree | 593cf7df29bf7acd449b69de8d36a87c2fcd7864 | |
parent | a931dc2a984761efbd2b8d9fc6a768d246e0df4a (diff) | |
download | chromium_src-31fd046884ae4bec8946a3a5e2007411763beb09.zip chromium_src-31fd046884ae4bec8946a3a5e2007411763beb09.tar.gz chromium_src-31fd046884ae4bec8946a3a5e2007411763beb09.tar.bz2 |
Move FieldTrialHelper from chrome to base and call it FieldTrialList.
BUG=385213
Review URL: https://codereview.chromium.org/334953004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278957 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/android/base_jni_registrar.cc | 2 | ||||
-rw-r--r-- | base/android/field_trial_list.cc (renamed from chrome/browser/android/field_trial_helper.cc) | 18 | ||||
-rw-r--r-- | base/android/field_trial_list.h | 18 | ||||
-rw-r--r-- | base/android/java/src/org/chromium/base/FieldTrialList.java | 24 | ||||
-rw-r--r-- | base/base.gyp | 1 | ||||
-rw-r--r-- | base/base.gypi | 2 | ||||
-rw-r--r-- | chrome/android/java/src/org/chromium/chrome/browser/FieldTrialHelper.java | 11 | ||||
-rw-r--r-- | chrome/browser/android/chrome_jni_registrar.cc | 2 | ||||
-rw-r--r-- | chrome/browser/android/field_trial_helper.h | 18 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 3 |
10 files changed, 64 insertions, 35 deletions
diff --git a/base/android/base_jni_registrar.cc b/base/android/base_jni_registrar.cc index 97c8fcf..a7a5fd2 100644 --- a/base/android/base_jni_registrar.cc +++ b/base/android/base_jni_registrar.cc @@ -10,6 +10,7 @@ #include "base/android/content_uri_utils.h" #include "base/android/cpu_features.h" #include "base/android/event_log.h" +#include "base/android/field_trial_list.h" #include "base/android/important_file_writer_android.h" #include "base/android/java_handler_thread.h" #include "base/android/jni_android.h" @@ -36,6 +37,7 @@ static RegistrationMethod kBaseRegisteredMethods[] = { { "ContentUriUtils", base::RegisterContentUriUtils }, { "CpuFeatures", base::android::RegisterCpuFeatures }, { "EventLog", base::android::RegisterEventLog }, + { "FieldTrialList", base::android::RegisterFieldTrialList }, { "ImportantFileWriterAndroid", base::android::RegisterImportantFileWriterAndroid }, { "MemoryPressureListenerAndroid", diff --git a/chrome/browser/android/field_trial_helper.cc b/base/android/field_trial_list.cc index b3be6d2..13f3cc5 100644 --- a/chrome/browser/android/field_trial_helper.cc +++ b/base/android/field_trial_list.cc @@ -1,33 +1,33 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 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 "chrome/browser/android/field_trial_helper.h" +#include "base/android/field_trial_list.h" #include <jni.h> #include "base/android/jni_string.h" #include "base/metrics/field_trial.h" -#include "jni/FieldTrialHelper_jni.h" +#include "jni/FieldTrialList_jni.h" using base::android::ConvertJavaStringToUTF8; using base::android::ConvertUTF8ToJavaString; -static jstring GetFieldTrialFullName(JNIEnv* env, - jclass clazz, - jstring jtrial_name) { +static jstring FindFullName(JNIEnv* env, + jclass clazz, + jstring jtrial_name) { std::string trial_name(ConvertJavaStringToUTF8(env, jtrial_name)); return ConvertUTF8ToJavaString( env, base::FieldTrialList::FindFullName(trial_name)).Release(); } -namespace chrome { +namespace base { namespace android { -bool RegisterFieldTrialHelper(JNIEnv* env) { +bool RegisterFieldTrialList(JNIEnv* env) { return RegisterNativesImpl(env); } } // namespace android -} // namespace chrome +} // namespace base diff --git a/base/android/field_trial_list.h b/base/android/field_trial_list.h new file mode 100644 index 0000000..b4eaf91 --- /dev/null +++ b/base/android/field_trial_list.h @@ -0,0 +1,18 @@ +// Copyright 2014 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. + +#ifndef BASE_ANDROID_FIELD_TRIAL_LIST_H_ +#define BASE_ANDROID_FIELD_TRIAL_LIST_H_ + +#include <jni.h> + +namespace base { +namespace android { + +bool RegisterFieldTrialList(JNIEnv* env); + +} // namespace android +} // namespace base + +#endif // BASE_ANDROID_FIELD_TRIAL_LIST_H_ diff --git a/base/android/java/src/org/chromium/base/FieldTrialList.java b/base/android/java/src/org/chromium/base/FieldTrialList.java new file mode 100644 index 0000000..6c1f31c --- /dev/null +++ b/base/android/java/src/org/chromium/base/FieldTrialList.java @@ -0,0 +1,24 @@ +// Copyright 2014 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. + +package org.chromium.base; + +/** + * Helper to get field trial information. + */ +public class FieldTrialList { + + private FieldTrialList() {} + + /** + * @param trialName The name of the trial to get the group for. + * @return The group name chosen for the named trial, or the empty string if the trial does + * not exist. + */ + public static String findFullName(String trialName) { + return nativeFindFullName(trialName); + } + + private static native String nativeFindFullName(String trialName); +} diff --git a/base/base.gyp b/base/base.gyp index 5544a4b..587e999 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -1283,6 +1283,7 @@ 'android/java/src/org/chromium/base/ContentUriUtils.java', 'android/java/src/org/chromium/base/CpuFeatures.java', 'android/java/src/org/chromium/base/EventLog.java', + 'android/java/src/org/chromium/base/FieldTrialList.java', 'android/java/src/org/chromium/base/ImportantFileWriterAndroid.java', 'android/java/src/org/chromium/base/library_loader/LibraryLoader.java', 'android/java/src/org/chromium/base/MemoryPressureListener.java', diff --git a/base/base.gypi b/base/base.gypi index c033dcb..d876921 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -39,6 +39,8 @@ 'android/cpu_features.cc', 'android/event_log.cc', 'android/event_log.h', + 'android/field_trial_list.cc', + 'android/field_trial_list.h', 'android/fifo_utils.cc', 'android/fifo_utils.h', 'android/important_file_writer_android.cc', diff --git a/chrome/android/java/src/org/chromium/chrome/browser/FieldTrialHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/FieldTrialHelper.java index fbacd26..328ba53 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/FieldTrialHelper.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/FieldTrialHelper.java @@ -4,6 +4,8 @@ package org.chromium.chrome.browser; +import org.chromium.base.FieldTrialList; + /** * Helper to get field trial information. */ @@ -12,13 +14,16 @@ public class FieldTrialHelper { private FieldTrialHelper() {} /** + * This function has been moved to base so it can be used by //sync. + * Please use {@link FieldTrialList#findFullName()} instead. + * See http://crbug.com/378035 for context. + * * @param trialName The name of the trial to get the group for. * @return The group name chosen for the named trial, or the empty string if the trial does * not exist. */ + @Deprecated public static String getFieldTrialFullName(String trialName) { - return nativeGetFieldTrialFullName(trialName); + return FieldTrialList.findFullName(trialName); } - - private static native String nativeGetFieldTrialFullName(String trialName); } diff --git a/chrome/browser/android/chrome_jni_registrar.cc b/chrome/browser/android/chrome_jni_registrar.cc index 9462c07..52001d3 100644 --- a/chrome/browser/android/chrome_jni_registrar.cc +++ b/chrome/browser/android/chrome_jni_registrar.cc @@ -16,7 +16,6 @@ #include "chrome/browser/android/dev_tools_server.h" #include "chrome/browser/android/dom_distiller/feedback_reporter_android.h" #include "chrome/browser/android/favicon_helper.h" -#include "chrome/browser/android/field_trial_helper.h" #include "chrome/browser/android/foreign_session_helper.h" #include "chrome/browser/android/intent_helper.h" #include "chrome/browser/android/logo_bridge.h" @@ -133,7 +132,6 @@ static base::android::RegistrationMethod kChromeRegisteredMethods[] = { RegisterExternalPrerenderHandlerAndroid }, { "FaviconHelper", FaviconHelper::RegisterFaviconHelper }, { "FeedbackReporter", dom_distiller::android::RegisterFeedbackReporter }, - { "FieldTrialHelper", RegisterFieldTrialHelper }, { "ForeignSessionHelper", ForeignSessionHelper::RegisterForeignSessionHelper }, { "InfoBarContainer", RegisterInfoBarContainer }, diff --git a/chrome/browser/android/field_trial_helper.h b/chrome/browser/android/field_trial_helper.h deleted file mode 100644 index 6f92ac0..0000000 --- a/chrome/browser/android/field_trial_helper.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 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. - -#ifndef CHROME_BROWSER_ANDROID_FIELD_TRIAL_HELPER_H_ -#define CHROME_BROWSER_ANDROID_FIELD_TRIAL_HELPER_H_ - -#include <jni.h> - -namespace chrome { -namespace android { - -bool RegisterFieldTrialHelper(JNIEnv* env); - -} // namespace android -} // namespace chrome - -#endif // CHROME_BROWSER_ANDROID_FIELD_TRIAL_HELPER_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index f871ffb..3aea6e3 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -158,8 +158,6 @@ 'browser/android/dom_distiller/feedback_reporter_android.h', 'browser/android/favicon_helper.cc', 'browser/android/favicon_helper.h', - 'browser/android/field_trial_helper.cc', - 'browser/android/field_trial_helper.h', 'browser/android/foreign_session_helper.cc', 'browser/android/foreign_session_helper.h', 'browser/android/logo_bridge.cc', @@ -3700,7 +3698,6 @@ 'android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerFeedbackReporter.java', 'android/java/src/org/chromium/chrome/browser/dom_distiller/DomDistillerTabUtils.java', 'android/java/src/org/chromium/chrome/browser/favicon/FaviconHelper.java', - 'android/java/src/org/chromium/chrome/browser/FieldTrialHelper.java', 'android/java/src/org/chromium/chrome/browser/ForeignSessionHelper.java', 'android/java/src/org/chromium/chrome/browser/LogoBridge.java', 'android/java/src/org/chromium/chrome/browser/NewTabPagePrefs.java', |