tor-browser

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

commit a657b0a7bc90fb21fba0d86a8b4d009e7852c41a
parent 48bc95ec84827fe1898653383aa3f5d844d1403d
Author: Dan Baker <dbaker@mozilla.com>
Date:   Mon,  1 Dec 2025 22:58:24 -0700

Bug 2000941 - Vendor libwebrtc from 3ff8b4e5f7

Upstream commit: https://webrtc.googlesource.com/src/+/3ff8b4e5f770f7cdf7c5bcb89331848cacda9c1f
    Use RTC_DCHECK_IS_ON rather than NDBUG for FieldTrials immutability DCHECK

    Bug: b/444370738
    Change-Id: Ifa9d2be808635ed2a2a767ef5efaab4014dd3ba1
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/411140
    Auto-Submit: Jonas Oreland <jonaso@webrtc.org>
    Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
    Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45703}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/api/field_trials.cc | 30+++++++++++++++++++++---------
Mthird_party/libwebrtc/api/field_trials.h | 24+++++++++++++++++-------
Mthird_party/libwebrtc/api/field_trials_unittest.cc | 2--
4 files changed, 40 insertions(+), 20 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 /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T05:55:45.975874+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T05:58:10.216528+00:00. # base of lastest vendoring -5f1552d8a3 +3ff8b4e5f7 diff --git a/third_party/libwebrtc/api/field_trials.cc b/third_party/libwebrtc/api/field_trials.cc @@ -74,21 +74,33 @@ FieldTrials::FieldTrials(const FieldTrials& other) key_value_map_ = other.key_value_map_; } +FieldTrials& FieldTrials::operator=(const FieldTrials& other) { + if (this != &other) { + AssertGetValueNotCalled(); + FieldTrialsRegistry::operator=(other); + key_value_map_ = other.key_value_map_; + } + return *this; +} + +FieldTrials& FieldTrials::operator=(FieldTrials&& other) { + if (this != &other) { + AssertGetValueNotCalled(); + FieldTrialsRegistry::operator=(other); + key_value_map_ = std::move(other.key_value_map_); + } + return *this; +} + void FieldTrials::Merge(const FieldTrials& other) { -#ifndef NDEBUG - RTC_DCHECK(get_value_called_ == false) - << "FieldTrials are immutable once first Lookup has been performed"; -#endif + AssertGetValueNotCalled(); for (const auto& [trial, group] : other.key_value_map_) { key_value_map_.insert_or_assign(trial, group); } } void FieldTrials::Set(absl::string_view trial, absl::string_view group) { -#ifndef NDEBUG - RTC_DCHECK(get_value_called_ == false) - << "FieldTrials are immutable once first Lookup has been performed"; -#endif + AssertGetValueNotCalled(); RTC_CHECK(!trial.empty()); RTC_CHECK_EQ(trial.find('/'), absl::string_view::npos); RTC_CHECK_EQ(group.find('/'), absl::string_view::npos); @@ -100,7 +112,7 @@ void FieldTrials::Set(absl::string_view trial, absl::string_view group) { } std::string FieldTrials::GetValue(absl::string_view key) const { -#ifndef NDEBUG +#if RTC_DCHECK_IS_ON get_value_called_ = true; #endif auto it = key_value_map_.find(key); diff --git a/third_party/libwebrtc/api/field_trials.h b/third_party/libwebrtc/api/field_trials.h @@ -19,6 +19,7 @@ #include "absl/strings/string_view.h" #include "api/field_trials_registry.h" #include "api/field_trials_view.h" +#include "rtc_base/checks.h" #include "rtc_base/containers/flat_map.h" namespace webrtc { @@ -52,8 +53,8 @@ class FieldTrials : public FieldTrialsRegistry { FieldTrials(const FieldTrials&); FieldTrials(FieldTrials&&) = default; - FieldTrials& operator=(const FieldTrials&) = default; - FieldTrials& operator=(FieldTrials&&) = default; + FieldTrials& operator=(const FieldTrials&); + FieldTrials& operator=(FieldTrials&&); ~FieldTrials() override = default; @@ -73,11 +74,16 @@ class FieldTrials : public FieldTrialsRegistry { // Create a copy of this view. std::unique_ptr<FieldTrialsView> CreateCopy() const override { - auto copy = std::make_unique<FieldTrials>(*this); -#ifndef NDEBUG - copy->get_value_called_ = false; + // We don't need to reset get_value_called_ on the returned copy + // since it is a FieldTrialsView that has no mutable methods. + return std::make_unique<FieldTrials>(*this); + } + + void AssertGetValueNotCalled() const { +#if RTC_DCHECK_IS_ON + RTC_DCHECK(!get_value_called_) + << "FieldTrials are immutable once first Lookup has been performed"; #endif - return copy; } private: @@ -86,7 +92,11 @@ class FieldTrials : public FieldTrialsRegistry { std::string GetValue(absl::string_view key) const override; -#ifndef NDEBUG +#if RTC_DCHECK_IS_ON + // Keep track of if GetValue() has been called. + // This is used to enforce immutability by DCHECK:ing + // that modification are performed once get_value_called_ + // is true. mutable bool get_value_called_ = false; #endif diff --git a/third_party/libwebrtc/api/field_trials_unittest.cc b/third_party/libwebrtc/api/field_trials_unittest.cc @@ -182,12 +182,10 @@ TEST(FieldTrials, Immutable) { c.Set("Audio", "Enabled"); #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) -#ifndef NDEBUG // But FieldTrials that have been read from, // must not be modified (as documented in FieldTrialsView). EXPECT_DEATH(f.Set("Audio", "Enabled"), ""); #endif -#endif } } // namespace