diff options
Diffstat (limited to 'dom/security/nsHTTPSOnlyUtils.h')
-rw-r--r-- | dom/security/nsHTTPSOnlyUtils.h | 38 |
1 files changed, 38 insertions, 0 deletions
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<nsILoadInfo> const& aLoadInfo, + RefPtr<HTTPSFirstDowngradeData> 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<nsITimer> 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<HTTPSFirstDowngradeData> { + MOZ_DECLARE_REFCOUNTED_TYPENAME(HTTPSFirstDowngradeData) + mozilla::TimeDuration downgradeTime; + bool isOnTimer = false; + bool isSchemeless = false; +}; + #endif /* nsHTTPSOnlyUtils_h___ */ |