From 350be0cc3025f133a0a81533188c81ac26d624e8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 20 Jun 2024 06:01:56 +0200 Subject: Merging upstream version 127.0.1. Signed-off-by: Daniel Baumann --- dom/security/nsHTTPSOnlyUtils.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'dom/security/nsHTTPSOnlyUtils.h') diff --git a/dom/security/nsHTTPSOnlyUtils.h b/dom/security/nsHTTPSOnlyUtils.h index 775fbf39e0..d582e62f36 100644 --- a/dom/security/nsHTTPSOnlyUtils.h +++ b/dom/security/nsHTTPSOnlyUtils.h @@ -176,6 +176,31 @@ class nsHTTPSOnlyUtils { */ static uint32_t GetStatusForSubresourceLoad(uint32_t aHttpsOnlyStatus); + /** + * When a downgrade is happening because of HTTPS-First, this function will + * update the load state for the new load accordingly. This includes + * information about the downgrade for later telemetry use. + * @param aDocumentLoadListener The calling document load listener. + * @param aLoadState The load state to be updated + */ + static void UpdateLoadStateAfterHTTPSFirstDowngrade( + mozilla::net::DocumentLoadListener* aDocumentLoadListener, + nsDocShellLoadState* aLoadState); + + /** + * When a load is successful, this should be called by the document load + * listener. In two cases, telemetry is then recorded: + * a) If downgrade data has been passed, the passed load is a successful + * downgrade, which means telemetry based on the downgrade data will be + * submitted. + * b) If the passed load info indicates that this load has been upgraded by + * HTTPS-First, this means the upgrade was successful, which will be + * recorded to telemetry. + */ + static void SubmitHTTPSFirstTelemetry( + nsCOMPtr const& aLoadInfo, + RefPtr const& aHttpsFirstDowngradeData); + private: /** * Checks if it can be ruled out that the error has something @@ -257,4 +282,17 @@ class TestHTTPAnswerRunnable final : public mozilla::Runnable, RefPtr mTimer; }; +/** + * Data about a HTTPS-First downgrade used for Telemetry. We need to store this + * instead of directly submitting it when deciding to downgrade, because it is + * only interesting for us if the downgraded load is actually succesful. + */ +struct HTTPSFirstDowngradeData + : public mozilla::RefCounted { + MOZ_DECLARE_REFCOUNTED_TYPENAME(HTTPSFirstDowngradeData) + mozilla::TimeDuration downgradeTime; + bool isOnTimer = false; + bool isSchemeless = false; +}; + #endif /* nsHTTPSOnlyUtils_h___ */ -- cgit v1.2.3