tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 199fafdc1ba275f1f794f3e61521d2f37ddc7fca
parent 8ce7123d2dba56fddc03936b522cebc197cb27d6
Author: Michael Froman <mfroman@mozilla.com>
Date:   Wed,  8 Oct 2025 17:31:48 -0500

Bug 1993083 - Vendor libwebrtc from 4690e0b758

Upstream commit: https://webrtc.googlesource.com/src/+/4690e0b758acf196e0ed810b6cde77c3ca74e437
    Delete ScopedKeyValueConfig and ScopedFieldTrials as unused

    These two classes were created with support for global field trials that
    is no longer used.

    All tests were migrated to use FieldTrials/CreateTestFieldTrials

    Bug: webrtc:419453427
    Change-Id: I67cc259818b935fd66d2b6ae0afcb43c38762857
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/398481
    Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
    Reviewed-by: Jeremy Leconte <jleconte@google.com>
    Cr-Commit-Position: refs/heads/main@{#45047}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/api/video/BUILD.gn | 1-
Mthird_party/libwebrtc/api/video_codecs/test/BUILD.gn | 1-
Mthird_party/libwebrtc/audio/BUILD.gn | 1-
Mthird_party/libwebrtc/call/BUILD.gn | 1-
Mthird_party/libwebrtc/modules/audio_coding/BUILD.gn | 1-
Mthird_party/libwebrtc/modules/audio_processing/BUILD.gn | 1-
Mthird_party/libwebrtc/modules/audio_processing/aec3/BUILD.gn | 1-
Mthird_party/libwebrtc/modules/audio_processing/agc2/BUILD.gn | 1-
Mthird_party/libwebrtc/modules/video_coding/codecs/av1/BUILD.gn | 1-
Mthird_party/libwebrtc/modules/video_coding/deprecated/BUILD.gn | 1-
Mthird_party/libwebrtc/modules/video_coding/timing/BUILD.gn | 1-
Mthird_party/libwebrtc/moz-patch-stack/s0001.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0027.patch | 20++++++++++----------
Mthird_party/libwebrtc/moz-patch-stack/s0034.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0099.patch | 6+++---
Mthird_party/libwebrtc/moz-patch-stack/s0103.patch | 12++++++------
Mthird_party/libwebrtc/test/BUILD.gn | 36------------------------------------
Dthird_party/libwebrtc/test/field_trial.cc | 38--------------------------------------
Dthird_party/libwebrtc/test/field_trial.h | 38--------------------------------------
Mthird_party/libwebrtc/test/pc/e2e/BUILD.gn | 1-
Mthird_party/libwebrtc/test/peer_scenario/BUILD.gn | 1-
Mthird_party/libwebrtc/test/scenario/BUILD.gn | 1-
Dthird_party/libwebrtc/test/scoped_key_value_config.cc | 128-------------------------------------------------------------------------------
Dthird_party/libwebrtc/test/scoped_key_value_config.h | 54------------------------------------------------------
25 files changed, 23 insertions(+), 331 deletions(-)

diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T22:30:30.922279+00:00. +libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T22:31:34.932748+00:00. # base of lastest vendoring -5b4745fbea +4690e0b758 diff --git a/third_party/libwebrtc/api/video/BUILD.gn b/third_party/libwebrtc/api/video/BUILD.gn @@ -419,7 +419,6 @@ rtc_library("frame_buffer_unittest") { "../../api/video:encoded_frame", "../../test:create_test_field_trials", "../../test:fake_encoded_frame", - "../../test:field_trial", "../../test:test_support", ] } diff --git a/third_party/libwebrtc/api/video_codecs/test/BUILD.gn b/third_party/libwebrtc/api/video_codecs/test/BUILD.gn @@ -41,7 +41,6 @@ if (rtc_include_tests) { "../../../rtc_base:rtc_base_tests_utils", "../../../test:explicit_key_value_config", "../../../test:fake_video_codecs", - "../../../test:field_trial", "../../../test:test_support", "../../../test:video_test_common", "../../environment", diff --git a/third_party/libwebrtc/audio/BUILD.gn b/third_party/libwebrtc/audio/BUILD.gn @@ -239,7 +239,6 @@ if (rtc_include_tests) { "../system_wrappers", "../test:audio_codec_mocks", "../test:create_test_field_trials", - "../test:field_trial", "../test:mock_transport", "../test:rtp_test_utils", "../test:run_loop", diff --git a/third_party/libwebrtc/call/BUILD.gn b/third_party/libwebrtc/call/BUILD.gn @@ -648,7 +648,6 @@ if (rtc_include_tests) { "../system_wrappers:metrics", "../test:encoder_settings", "../test:fake_video_codecs", - "../test:field_trial", "../test:fileutils", "../test:frame_generator_capturer", "../test:test_common", diff --git a/third_party/libwebrtc/modules/audio_coding/BUILD.gn b/third_party/libwebrtc/modules/audio_coding/BUILD.gn @@ -1060,7 +1060,6 @@ if (rtc_include_tests) { "../../rtc_base:checks", "../../rtc_base:refcount", "../../test:audio_test_common", - "../../test:field_trial", "../../test:fileutils", "../../test:test_support", "../rtp_rtcp:rtp_rtcp_format", diff --git a/third_party/libwebrtc/modules/audio_processing/BUILD.gn b/third_party/libwebrtc/modules/audio_processing/BUILD.gn @@ -400,7 +400,6 @@ if (rtc_include_tests) { "../../rtc_base/synchronization:mutex", "../../rtc_base/system:arch", "../../rtc_base/system:file_wrapper", - "../../test:field_trial", "../../test:fileutils", "../../test:rtc_expect_death", "../../test:test_support", diff --git a/third_party/libwebrtc/modules/audio_processing/aec3/BUILD.gn b/third_party/libwebrtc/modules/audio_processing/aec3/BUILD.gn @@ -326,7 +326,6 @@ if (rtc_include_tests) { "../../../rtc_base/system:arch", "../../../system_wrappers:metrics", "../../../test:explicit_key_value_config", - "../../../test:field_trial", "../../../test:test_support", "../utility:cascaded_biquad_filter", ] diff --git a/third_party/libwebrtc/modules/audio_processing/agc2/BUILD.gn b/third_party/libwebrtc/modules/audio_processing/agc2/BUILD.gn @@ -425,7 +425,6 @@ rtc_library("input_volume_controller_unittests") { "../../../rtc_base:safe_minmax", "../../../rtc_base:stringutils", "../../../system_wrappers:metrics", - "../../../test:field_trial", "../../../test:fileutils", "../../../test:test_support", "//testing/gtest", diff --git a/third_party/libwebrtc/modules/video_coding/codecs/av1/BUILD.gn b/third_party/libwebrtc/modules/video_coding/codecs/av1/BUILD.gn @@ -133,7 +133,6 @@ if (rtc_include_tests) { "../../../../api/units:time_delta", "../../../../modules/rtp_rtcp:rtp_rtcp_format", "../../../../test:fileutils", - "../../../../test:scoped_key_value_config", "../../../../test:video_test_support", "../../svc:scalability_mode_util", "../../svc:scalability_structures", diff --git a/third_party/libwebrtc/modules/video_coding/deprecated/BUILD.gn b/third_party/libwebrtc/modules/video_coding/deprecated/BUILD.gn @@ -204,7 +204,6 @@ rtc_library("deprecated_unittests") { "../../../rtc_base:checks", "../../../system_wrappers", "../../../test:create_test_field_trials", - "../../../test:scoped_key_value_config", "../../../test:test_support", "//third_party/abseil-cpp/absl/memory", ] diff --git a/third_party/libwebrtc/modules/video_coding/timing/BUILD.gn b/third_party/libwebrtc/modules/video_coding/timing/BUILD.gn @@ -153,7 +153,6 @@ rtc_library("timing_unittests") { "../../../system_wrappers:metrics", "../../../system_wrappers:system_wrappers", "../../../test:create_test_field_trials", - "../../../test:scoped_key_value_config", "../../../test:test_support", ] } diff --git a/third_party/libwebrtc/moz-patch-stack/s0001.patch b/third_party/libwebrtc/moz-patch-stack/s0001.patch @@ -413,7 +413,7 @@ index 06c581157a..8a5bbd8631 100644 bool RtpExtension::IsSupportedForVideo(absl::string_view uri) { diff --git a/call/BUILD.gn b/call/BUILD.gn -index 7334d82cf1..cfa6c85e6b 100644 +index 06a92df849..e8d2d469cb 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -20,6 +20,7 @@ rtc_library("call_interfaces") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0027.patch b/third_party/libwebrtc/moz-patch-stack/s0027.patch @@ -473,7 +473,7 @@ index 11b03496be..3cc8835a5e 100644 if (rtc_include_tests) { rtc_source_set("test_feedback_generator_interface") { diff --git a/call/BUILD.gn b/call/BUILD.gn -index cfa6c85e6b..e09cf9ef3b 100644 +index e8d2d469cb..c9f5a37bed 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -48,7 +48,7 @@ rtc_library("call_interfaces") { @@ -718,7 +718,7 @@ index 6d4d4a2363..316408a9b3 100644 : content_hint(VideoTrackInterface::ContentHint::kNone) {} VideoOptions::~VideoOptions() = default; diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn -index 77b22dc5bd..3d11071e89 100644 +index a24282bee8..f09ff0301a 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -362,7 +362,7 @@ rtc_library("webrtc_opus_wrapper") { @@ -816,7 +816,7 @@ index a920be33f7..8d53cdfa0a 100644 testonly = true diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn -index e643570330..8605e38a1e 100644 +index c7d983bcfa..6cc9d4c334 100644 --- a/modules/audio_processing/aec3/BUILD.gn +++ b/modules/audio_processing/aec3/BUILD.gn @@ -263,14 +263,11 @@ if (current_cpu == "x86" || current_cpu == "x64") { @@ -1194,10 +1194,10 @@ index c1181618e9..4a772795ed 100644 deps += [ "..:logging", diff --git a/test/BUILD.gn b/test/BUILD.gn -index 739678aa84..9ac30f1b79 100644 +index c90d42d6e1..e0bb8bc2da 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn -@@ -259,6 +259,7 @@ rtc_library("audio_test_common") { +@@ -258,6 +258,7 @@ rtc_library("audio_test_common") { ] } @@ -1205,7 +1205,7 @@ index 739678aa84..9ac30f1b79 100644 if (!build_with_chromium) { if (is_mac || is_ios) { rtc_library("video_test_mac") { -@@ -315,8 +316,12 @@ if (!build_with_chromium) { +@@ -313,8 +314,12 @@ if (!build_with_chromium) { } } } @@ -1218,7 +1218,7 @@ index 739678aa84..9ac30f1b79 100644 testonly = true sources = [ "rtcp_packet_parser.cc", -@@ -326,6 +331,7 @@ rtc_library("rtp_test_utils") { +@@ -324,6 +329,7 @@ rtc_library("rtp_test_utils") { "rtp_file_writer.cc", "rtp_file_writer.h", ] @@ -1226,7 +1226,7 @@ index 739678aa84..9ac30f1b79 100644 deps = [ "../api:array_view", -@@ -543,7 +549,9 @@ rtc_library("video_frame_writer") { +@@ -509,7 +515,9 @@ rtc_library("video_frame_writer") { ] if (!is_ios) { @@ -1236,7 +1236,7 @@ index 739678aa84..9ac30f1b79 100644 sources += [ "testsupport/jpeg_frame_writer.cc" ] } else { sources += [ "testsupport/jpeg_frame_writer_ios.cc" ] -@@ -1386,6 +1394,7 @@ if (!build_with_chromium) { +@@ -1350,6 +1358,7 @@ if (!build_with_chromium) { } } @@ -1244,7 +1244,7 @@ index 739678aa84..9ac30f1b79 100644 if (!build_with_chromium && is_android) { rtc_android_library("native_test_java") { testonly = true -@@ -1428,6 +1437,7 @@ if (!build_with_chromium && is_android) { +@@ -1392,6 +1401,7 @@ if (!build_with_chromium && is_android) { sources = [ "android/org/webrtc/native_test/NativeTestWebrtc.java" ] } } diff --git a/third_party/libwebrtc/moz-patch-stack/s0034.patch b/third_party/libwebrtc/moz-patch-stack/s0034.patch @@ -172,7 +172,7 @@ index ac862c65a8..e66ed2796e 100644 } else { sources += [ "spl_sqrt_floor.c" ] diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn -index 8605e38a1e..6d942b7883 100644 +index 6cc9d4c334..5102f92945 100644 --- a/modules/audio_processing/aec3/BUILD.gn +++ b/modules/audio_processing/aec3/BUILD.gn @@ -123,7 +123,7 @@ rtc_library("aec3") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0099.patch b/third_party/libwebrtc/moz-patch-stack/s0099.patch @@ -16,7 +16,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/bbec1b95ddb5e0096 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn -index 3d11071e89..3701a56caf 100644 +index f09ff0301a..6499340c5f 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -362,7 +362,7 @@ rtc_library("webrtc_opus_wrapper") { @@ -86,10 +86,10 @@ index 06da79a112..a18d353a0e 100644 if (!build_with_mozilla) { diff --git a/test/BUILD.gn b/test/BUILD.gn -index 9ac30f1b79..1dda47bb61 100644 +index e0bb8bc2da..4038297072 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn -@@ -510,6 +510,12 @@ rtc_source_set("test_support") { +@@ -476,6 +476,12 @@ rtc_source_set("test_support") { "//testing/gmock", "//testing/gtest", ] diff --git a/third_party/libwebrtc/moz-patch-stack/s0103.patch b/third_party/libwebrtc/moz-patch-stack/s0103.patch @@ -246,7 +246,7 @@ index 40714b196e..2c6b39f59e 100644 if (rtc_include_tests) { diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn -index 7ff6932db1..aadc46a5c8 100644 +index 4b6f18729b..c21d5fc2e8 100644 --- a/api/video/BUILD.gn +++ b/api/video/BUILD.gn @@ -8,8 +8,8 @@ @@ -276,7 +276,7 @@ index 802f8cc436..eb4fbcad65 100644 rtc_library("scalability_mode") { diff --git a/audio/BUILD.gn b/audio/BUILD.gn -index 9b287604dc..8f169039f3 100644 +index eda3161da8..612028625a 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -8,8 +8,8 @@ @@ -455,7 +455,7 @@ index 8d53cdfa0a..181623546d 100644 config("audio_device_warnings_config") { diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn -index 6d942b7883..b414b7c538 100644 +index 5102f92945..2e95f823fa 100644 --- a/modules/audio_processing/aec3/BUILD.gn +++ b/modules/audio_processing/aec3/BUILD.gn @@ -124,7 +124,7 @@ rtc_library("aec3") { @@ -494,7 +494,7 @@ index 45d08ad066..2d6f3ca0b4 100644 } } diff --git a/modules/audio_processing/agc2/BUILD.gn b/modules/audio_processing/agc2/BUILD.gn -index 36d7f983f1..ee39b667b1 100644 +index 1581e49dae..23e68636bf 100644 --- a/modules/audio_processing/agc2/BUILD.gn +++ b/modules/audio_processing/agc2/BUILD.gn @@ -258,7 +258,7 @@ rtc_library("vad_wrapper") { @@ -756,7 +756,7 @@ index 8222263e1f..913382709e 100644 import("../webrtc.gni") diff --git a/test/BUILD.gn b/test/BUILD.gn -index 1dda47bb61..c1ae6bba46 100644 +index 4038297072..c36ca05c5c 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -6,10 +6,10 @@ @@ -772,7 +772,7 @@ index 1dda47bb61..c1ae6bba46 100644 import("//third_party/jni_zero/jni_zero.gni") } -@@ -455,7 +455,7 @@ if (is_ios) { +@@ -421,7 +421,7 @@ if (is_ios) { testonly = true visibility = [ "*" ] sources = [ "ios/google_test_runner.mm" ] diff --git a/third_party/libwebrtc/test/BUILD.gn b/third_party/libwebrtc/test/BUILD.gn @@ -212,7 +212,6 @@ rtc_library("video_test_common") { ":create_frame_generator_capturer", ":fileutils", ":frame_utils", - ":scoped_key_value_config", ":test_video_capturer", "../api:array_view", "../api:create_frame_generator", @@ -307,7 +306,6 @@ if (!build_with_chromium) { "vcm_capturer.h", ] deps += [ - ":scoped_key_value_config", "../api:scoped_refptr", "../modules/video_capture:video_capture_module", "../rtc_base:checks", @@ -349,44 +347,12 @@ rtc_library("rtp_test_utils") { ] } -rtc_library("field_trial") { - testonly = true - visibility = [ "*" ] - sources = [ - "field_trial.cc", - "field_trial.h", - ] - - deps = [ - "../rtc_base:checks", - "../system_wrappers:field_trial", - "//third_party/abseil-cpp/absl/strings:string_view", - ] -} - rtc_library("explicit_key_value_config") { sources = [ "explicit_key_value_config.h" ] deps = [ "../api:field_trials" ] } -rtc_library("scoped_key_value_config") { - testonly = true - visibility = [ "*" ] - sources = [ - "scoped_key_value_config.cc", - "scoped_key_value_config.h", - ] - - deps = [ - ":field_trial", - "../api:field_trials_registry", - "../rtc_base:checks", - "../system_wrappers:field_trial", - "//third_party/abseil-cpp/absl/strings:string_view", - ] -} - rtc_library("perf_test") { visibility = [ "*" ] testonly = true @@ -633,7 +599,6 @@ if (rtc_include_tests) { ] deps = [ - ":field_trial", ":fileutils", ":perf_test", ":resources_dir_flag", @@ -750,7 +715,6 @@ if (rtc_include_tests) { ":rtc_expect_death", ":rtp_test_utils", ":run_loop", - ":scoped_key_value_config", ":test_main", ":test_support", ":test_support_test_artifacts", diff --git a/third_party/libwebrtc/test/field_trial.cc b/third_party/libwebrtc/test/field_trial.cc @@ -1,38 +0,0 @@ -/* - * 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 "test/field_trial.h" - -#include <string> - -#include "absl/strings/string_view.h" -#include "rtc_base/checks.h" -#include "system_wrappers/include/field_trial.h" - -namespace webrtc { -namespace test { - -ScopedFieldTrials::ScopedFieldTrials(absl::string_view config) - : current_field_trials_(config), - previous_field_trials_(field_trial::GetFieldTrialString()) { - RTC_CHECK( - field_trial::FieldTrialsStringIsValid(current_field_trials_.c_str())) - << "Invalid field trials string: " << current_field_trials_; - field_trial::InitFieldTrialsFromString(current_field_trials_.c_str()); -} - -ScopedFieldTrials::~ScopedFieldTrials() { - RTC_CHECK(field_trial::FieldTrialsStringIsValid(previous_field_trials_)) - << "Invalid field trials string: " << previous_field_trials_; - field_trial::InitFieldTrialsFromString(previous_field_trials_); -} - -} // namespace test -} // namespace webrtc diff --git a/third_party/libwebrtc/test/field_trial.h b/third_party/libwebrtc/test/field_trial.h @@ -1,38 +0,0 @@ -/* - * 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 TEST_FIELD_TRIAL_H_ -#define TEST_FIELD_TRIAL_H_ - -#include <string> - -#include "absl/strings/string_view.h" - -namespace webrtc { -namespace test { - -// This class is used to override field-trial configs within specific tests. -// After this class goes out of scope previous field trials will be restored. -class ScopedFieldTrials { - public: - explicit ScopedFieldTrials(absl::string_view config); - ScopedFieldTrials(const ScopedFieldTrials&) = delete; - ScopedFieldTrials& operator=(const ScopedFieldTrials&) = delete; - ~ScopedFieldTrials(); - - private: - std::string current_field_trials_; - const char* previous_field_trials_; -}; - -} // namespace test -} // namespace webrtc - -#endif // TEST_FIELD_TRIAL_H_ diff --git a/third_party/libwebrtc/test/pc/e2e/BUILD.gn b/third_party/libwebrtc/test/pc/e2e/BUILD.gn @@ -345,7 +345,6 @@ if (!build_with_chromium) { "../../../rtc_base:logging", "../../../rtc_base:rtc_event", "../../../system_wrappers:field_trial", - "../../../test:field_trial", "../../../test:fileutils", "../../../test:test_support", "analyzer/video:default_video_quality_analyzer", diff --git a/third_party/libwebrtc/test/peer_scenario/BUILD.gn b/third_party/libwebrtc/test/peer_scenario/BUILD.gn @@ -27,7 +27,6 @@ if (rtc_include_tests) { "..:fake_video_codecs", "..:fileutils", "..:frame_generator_capturer", - "..:scoped_key_value_config", "..:test_support", "../../api:array_view", "../../api:audio_options_api", diff --git a/third_party/libwebrtc/test/scenario/BUILD.gn b/third_party/libwebrtc/test/scenario/BUILD.gn @@ -222,7 +222,6 @@ if (rtc_include_tests && !build_with_chromium) { "../../rtc_base:rtc_stats_counters", "../../system_wrappers", "../../system_wrappers:field_trial", - "../../test:field_trial", "../../test:test_support", "../../test:video_test_constants", "../logging:log_writer", diff --git a/third_party/libwebrtc/test/scoped_key_value_config.cc b/third_party/libwebrtc/test/scoped_key_value_config.cc @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2020 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 "test/scoped_key_value_config.h" - -#include <functional> -#include <map> -#include <memory> -#include <string> - -#include "absl/strings/string_view.h" -#include "rtc_base/checks.h" -#include "system_wrappers/include/field_trial.h" -#include "test/field_trial.h" - -namespace { - -// This part is copied from system_wrappers/field_trial.cc. -void InsertIntoMap( - std::map<std::string, std::string, std::less<>>& key_value_map, - absl::string_view s) { - std::string::size_type field_start = 0; - while (field_start < s.size()) { - std::string::size_type separator_pos = s.find('/', field_start); - RTC_CHECK_NE(separator_pos, std::string::npos) - << "Missing separator '/' after field trial key."; - RTC_CHECK_GT(separator_pos, field_start) - << "Field trial key cannot be empty."; - std::string key(s.substr(field_start, separator_pos - field_start)); - field_start = separator_pos + 1; - - RTC_CHECK_LT(field_start, s.size()) - << "Missing value after field trial key. String ended."; - separator_pos = s.find('/', field_start); - RTC_CHECK_NE(separator_pos, std::string::npos) - << "Missing terminating '/' in field trial string."; - RTC_CHECK_GT(separator_pos, field_start) - << "Field trial value cannot be empty."; - std::string value(s.substr(field_start, separator_pos - field_start)); - field_start = separator_pos + 1; - - key_value_map[key] = value; - } - // This check is technically redundant due to earlier checks. - // We nevertheless keep the check to make it clear that the entire - // string has been processed, and without indexing past the end. - RTC_CHECK_EQ(field_start, s.size()); -} - -} // namespace - -namespace webrtc { -namespace test { - -ScopedKeyValueConfig::ScopedKeyValueConfig() - : ScopedKeyValueConfig(nullptr, "") {} - -ScopedKeyValueConfig::ScopedKeyValueConfig(absl::string_view s) - : ScopedKeyValueConfig(nullptr, s) {} - -ScopedKeyValueConfig::ScopedKeyValueConfig(ScopedKeyValueConfig& parent, - absl::string_view s) - : ScopedKeyValueConfig(&parent, s) {} - -ScopedKeyValueConfig::ScopedKeyValueConfig(ScopedKeyValueConfig* parent, - absl::string_view s) - : parent_(parent), leaf_(nullptr) { - InsertIntoMap(key_value_map_, s); - - if (!s.empty()) { - // Also store field trials in global string (until we get rid of it). - scoped_field_trials_ = std::make_unique<ScopedFieldTrials>(s); - } - - if (parent == nullptr) { - // We are root, set leaf_. - leaf_ = this; - } else { - // Link root to new leaf. - GetRoot(parent)->leaf_ = this; - RTC_DCHECK(leaf_ == nullptr); - } -} - -ScopedKeyValueConfig::~ScopedKeyValueConfig() { - if (parent_) { - GetRoot(parent_)->leaf_ = parent_; - } -} - -ScopedKeyValueConfig* ScopedKeyValueConfig::GetRoot(ScopedKeyValueConfig* n) { - while (n->parent_ != nullptr) { - n = n->parent_; - } - return n; -} - -std::string ScopedKeyValueConfig::GetValue(absl::string_view key) const { - if (parent_ == nullptr) { - return leaf_->LookupRecurse(key); - } else { - return LookupRecurse(key); - } -} - -std::string ScopedKeyValueConfig::LookupRecurse(absl::string_view key) const { - auto it = key_value_map_.find(key); - if (it != key_value_map_.end()) - return it->second; - - if (parent_) { - return parent_->LookupRecurse(key); - } - - // When at the root, check the global string so that test programs using - // a mix between ScopedKeyValueConfig and the global string continue to work - return field_trial::FindFullName(std::string(key)); -} - -} // namespace test -} // namespace webrtc diff --git a/third_party/libwebrtc/test/scoped_key_value_config.h b/third_party/libwebrtc/test/scoped_key_value_config.h @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2020 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 TEST_SCOPED_KEY_VALUE_CONFIG_H_ -#define TEST_SCOPED_KEY_VALUE_CONFIG_H_ - -#include <functional> -#include <map> -#include <memory> -#include <string> - -#include "absl/strings/string_view.h" -#include "api/field_trials_registry.h" -#include "test/field_trial.h" - -namespace webrtc { -namespace test { - -class ScopedKeyValueConfig : public FieldTrialsRegistry { - public: - virtual ~ScopedKeyValueConfig(); - ScopedKeyValueConfig(); - explicit ScopedKeyValueConfig(absl::string_view s); - ScopedKeyValueConfig(ScopedKeyValueConfig& parent, absl::string_view s); - - private: - ScopedKeyValueConfig(ScopedKeyValueConfig* parent, absl::string_view s); - ScopedKeyValueConfig* GetRoot(ScopedKeyValueConfig* n); - std::string GetValue(absl::string_view key) const override; - std::string LookupRecurse(absl::string_view key) const; - - ScopedKeyValueConfig* const parent_; - - // The leaf in a list of stacked ScopedKeyValueConfig. - // Only set on root (e.g with parent_ == nullptr). - const ScopedKeyValueConfig* leaf_; - - // Unlike std::less<std::string>, std::less<> is transparent and allows - // heterogeneous lookup directly with absl::string_view. - std::map<std::string, std::string, std::less<>> key_value_map_; - std::unique_ptr<ScopedFieldTrials> scoped_field_trials_; -}; - -} // namespace test -} // namespace webrtc - -#endif // TEST_SCOPED_KEY_VALUE_CONFIG_H_