Add webrtc field trials API.

From now on it is expected that code linking system_wrappers.gyp:system_wrappers
provides an implementation for field_trial API or links with the default one in
system_wrappers.gyp:field_trial_default.

Note: Since there is no use of webrtc::field_trial API inside webrtc this CL on
itself does not forces the clients to actually define it. It however lays the
API and updates the gyp rules to link with so that it is ready to use.

Tested: Introduced a use of field trial in system wrappers and make sure all
bots were building successfully.

BUG=crbug/367114
R=tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/14489004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6147 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andresp@webrtc.org 2014-05-14 12:24:04 +00:00
parent 9f277350f8
commit a36ad6929d
14 changed files with 131 additions and 2 deletions

View File

@ -124,6 +124,7 @@
'<(DEPTH)/testing/gtest.gyp:gtest',
'<(webrtc_root)/test/test.gyp:test_support',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
],
'sources': [
@ -141,6 +142,7 @@
'<(DEPTH)/testing/gtest.gyp:gtest',
'<(webrtc_root)/test/test.gyp:test_support',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
],
'sources': [

View File

@ -88,6 +88,7 @@
'neteq_unittest_tools',
'<(DEPTH)/testing/gtest.gyp:gtest',
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
],
'sources': [
'tools/rtp_analyze.cc',

View File

@ -45,6 +45,7 @@
],
'dependencies': [
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
'bwe_tools_util',
'rtp_rtcp',
],
@ -67,6 +68,7 @@
],
'dependencies': [
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
'bwe_tools_util',
'rtp_rtcp',
],

View File

@ -17,6 +17,7 @@
'video_codecs_test_framework',
'webrtc_video_coding',
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
'<(webrtc_root)/test/metrics.gyp:metrics',
'<(webrtc_vp8_dir)/vp8.gyp:webrtc_vp8',
],

View File

@ -20,6 +20,7 @@
'<(webrtc_root)/test/test.gyp:test_support',
'<(webrtc_root)/test/metrics.gyp:metrics',
'<(webrtc_root)/common_video/common_video.gyp:common_video',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
],
'sources': [
# headers

View File

@ -0,0 +1,71 @@
//
// Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
//
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FIELD_TRIAL_H_
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FIELD_TRIAL_H_
#include <string>
#include "webrtc/common_types.h"
// Field trials allow webrtc clients (such as Chrome) to turn on feature code
// in binaries out in the field and gather information with that.
//
// WebRTC clients MUST provide an implementation of:
//
// std::string webrtc::field_trial::FindFullName(const std::string& trial).
//
// Or link with a default one provided in:
//
// system_wrappers/source/system_wrappers.gyp:field_trial_default
//
//
// They are designed to wire up directly to chrome field trials and to speed up
// developers by reducing the need to wire APIs to control whether a feature is
// on/off. E.g. to experiment with a new method that could lead to a different
// trade-off between CPU/bandwidth:
//
// 1 - Develop the feature with default behaviour off:
//
// if (FieldTrial::FindFullName("WebRTCExperimenMethod2") == "Enabled")
// method2();
// else
// method1();
//
// 2 - Once the changes are rolled to chrome, the new code path can be
// controlled as normal chrome field trials.
//
// 3 - Evaluate the new feature and clean the code paths.
//
// Notes:
// - NOT every feature is a candidate to be controlled by this mechanism as
// it may require negotation between involved parties (e.g. SDP).
//
// TODO(andresp): since chrome --force-fieldtrials does not marks the trial
// as active it does not gets propaged to renderer process. For now one
// needs to push a config with start_active:true or run a local finch
// server.
//
// TODO(andresp): support --force_fieldtirals from webrtc tests.
// TODO(andresp): find out how to get bots to run tests with trials enabled.
namespace webrtc {
namespace field_trial {
// Returns the group name chosen for the named trial, or the empty string
// if the trial does not exists.
//
// Note: To keep things tidy append all the trial names with WebRTC.
std::string FindFullName(const std::string& name);
} // namespace field_trial
} // namespace webrtc
#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_FIELD_TRIAL_H_

View File

@ -0,0 +1,22 @@
// Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
//
#include "webrtc/system_wrappers/interface/field_trial.h"
// Clients of webrtc that do not want to configure field trials can link with
// this instead of providing their own implementation.
namespace webrtc {
namespace field_trial {
std::string FindFullName(const std::string& name) {
return std::string();
}
} // namespace field_trial
} // namespace webrtc

View File

@ -38,6 +38,7 @@
'../interface/data_log_impl.h',
'../interface/event_tracer.h',
'../interface/event_wrapper.h',
'../interface/field_trial.h',
'../interface/file_wrapper.h',
'../interface/fix_interlocked_exchange_pointer_win.h',
'../interface/logcat_trace_context.h',
@ -194,6 +195,15 @@
4267, # size_t to int truncation.
4334, # Ignore warning on shift operator promotion.
],
}, {
'target_name': 'field_trial_default',
'type': 'static_library',
'sources': [
'field_trial_default.cc',
],
'dependencies': [
'system_wrappers',
]
},
], # targets
'conditions': [

View File

@ -63,6 +63,17 @@
'<(webrtc_root)/modules/modules.gyp:rtp_rtcp',
],
},
{
'target_name': 'test_main',
'type': 'static_library',
'sources': [
'test_main.cc',
],
'dependencies': [
'<(DEPTH)/testing/gtest.gyp:gtest',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
],
},
{
'target_name': 'test_support',
'type': 'static_library',
@ -118,6 +129,7 @@
'type': 'static_library',
'dependencies': [
'test_support',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
],
'sources': [
'run_all_unittests.cc',

View File

@ -91,6 +91,7 @@
'type': 'executable',
'dependencies': [
'<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
],
'sources': [
'force_mic_volume_max/force_mic_volume_max.cc',
@ -106,6 +107,7 @@
'dependencies': [
'<(webrtc_root)/test/test.gyp:channel_transport',
'<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
'<(DEPTH)/testing/gtest.gyp:gtest',
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
],

View File

@ -13,6 +13,7 @@
'type': 'executable',
'dependencies': [
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
'<(webrtc_root)/modules/modules.gyp:video_render_module',
'<(webrtc_root)/modules/modules.gyp:video_capture_module',
'<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine',

View File

@ -146,6 +146,7 @@
'<(DEPTH)/testing/gtest.gyp:gtest',
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
'<(webrtc_root)/test/test.gyp:channel_transport',
'<(webrtc_root)/test/test.gyp:test_support',
],
@ -211,6 +212,7 @@
'<(DEPTH)/testing/gtest.gyp:gtest',
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
'<(webrtc_root)/test/test.gyp:channel_transport',
'<(webrtc_root)/test/test.gyp:test_support',
],

View File

@ -16,6 +16,7 @@
'dependencies': [
'<(DEPTH)/third_party/icu/icu.gyp:icuuc',
'<(webrtc_root)/modules/modules.gyp:*',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
'<(webrtc_root)/test/test.gyp:channel_transport',
'<(webrtc_root)/video_engine/video_engine.gyp:video_engine_core',
'<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine',

View File

@ -26,6 +26,7 @@
'<(DEPTH)/testing/gtest.gyp:gtest',
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
'test/webrtc_test_common.gyp:webrtc_test_common',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:field_trial_default',
'webrtc',
],
},
@ -39,13 +40,13 @@
'video/video_send_stream_tests.cc',
'test/common_unittest.cc',
'test/testsupport/metrics/video_metrics_unittest.cc',
'test/test_main.cc',
],
'dependencies': [
'<(DEPTH)/testing/gtest.gyp:gtest',
'modules/modules.gyp:rtp_rtcp',
'test/metrics.gyp:metrics',
'test/webrtc_test_common.gyp:webrtc_test_common',
'test/test.gyp:test_main',
'webrtc',
],
},
@ -54,7 +55,6 @@
'type': '<(gtest_target_type)',
'sources': [
'modules/audio_coding/neteq4/test/neteq_performance_unittest.cc',
'test/test_main.cc',
'video/call_perf_tests.cc',
'video/full_stack.cc',
'video/rampup_tests.cc',
@ -64,6 +64,7 @@
'modules/modules.gyp:neteq_test_support', # Needed by neteq_performance_unittest.
'modules/modules.gyp:rtp_rtcp',
'test/webrtc_test_common.gyp:webrtc_test_common',
'test/test.gyp:test_main',
'webrtc',
],
},