summaryrefslogtreecommitdiffstats
path: root/dom/security/nsHTTPSOnlyUtils.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
commit59203c63bb777a3bacec32fb8830fba33540e809 (patch)
tree58298e711c0ff0575818c30485b44a2f21bf28a0 /dom/security/nsHTTPSOnlyUtils.cpp
parentAdding upstream version 126.0.1. (diff)
downloadfirefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz
firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/security/nsHTTPSOnlyUtils.cpp')
-rw-r--r--dom/security/nsHTTPSOnlyUtils.cpp35
1 files changed, 14 insertions, 21 deletions
diff --git a/dom/security/nsHTTPSOnlyUtils.cpp b/dom/security/nsHTTPSOnlyUtils.cpp
index 31c7408a37..0bc99179dc 100644
--- a/dom/security/nsHTTPSOnlyUtils.cpp
+++ b/dom/security/nsHTTPSOnlyUtils.cpp
@@ -601,35 +601,28 @@ nsHTTPSOnlyUtils::PotentiallyDowngradeHttpsFirstRequest(
if (navigationStart) {
mozilla::TimeDuration duration =
mozilla::TimeStamp::Now() - navigationStart;
+
bool isPrivateWin =
loadInfo->GetOriginAttributes().mPrivateBrowsingId > 0;
+ bool isSchemeless =
+ loadInfo->GetWasSchemelessInput() &&
+ !nsHTTPSOnlyUtils::IsHttpsFirstModeEnabled(isPrivateWin);
- if (loadInfo->GetWasSchemelessInput() &&
- !IsHttpsFirstModeEnabled(isPrivateWin)) {
- mozilla::glean::httpsfirst::downgraded_schemeless.Add();
- if (timing) {
- mozilla::glean::httpsfirst::downgrade_time_schemeless
- .AccumulateRawDuration(duration);
- }
- } else {
- mozilla::glean::httpsfirst::downgraded.Add();
- if (timing) {
- mozilla::glean::httpsfirst::downgrade_time.AccumulateRawDuration(
- duration);
- }
- }
+ using namespace mozilla::glean::httpsfirst;
+ auto downgradedMetric = isSchemeless ? downgraded_schemeless : downgraded;
+ auto downgradedOnTimerMetric =
+ isSchemeless ? downgraded_on_timer_schemeless : downgraded_on_timer;
+ auto downgradeTimeMetric =
+ isSchemeless ? downgrade_time_schemeless : downgrade_time;
nsresult channelStatus;
channel->GetStatus(&channelStatus);
if (channelStatus == NS_ERROR_NET_TIMEOUT_EXTERNAL) {
- if (loadInfo->GetWasSchemelessInput() &&
- !nsHTTPSOnlyUtils::IsHttpsFirstModeEnabled(isPrivateWin)) {
- mozilla::glean::httpsfirst::downgraded_on_timer_schemeless
- .AddToNumerator();
- } else {
- mozilla::glean::httpsfirst::downgraded_on_timer.AddToNumerator();
- }
+ downgradedOnTimerMetric.AddToNumerator();
+ } else {
+ downgradeTimeMetric.AccumulateRawDuration(duration);
}
+ downgradedMetric.Add();
}
}