Bug 1892041 - Part 1: Update test262 features. r=spidermonkey-reviewers,dminor
[gecko.git] / dom / security / nsHTTPSOnlyStreamListener.h
bloba2ab4711e3b6d77b6fd74b375e4addce88378562
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsHTTPSOnlyStreamListener_h___
8 #define nsHTTPSOnlyStreamListener_h___
10 #include "mozilla/TimeStamp.h"
11 #include "nsCOMPtr.h"
12 #include "nsIStreamListener.h"
14 class nsILoadInfo;
16 /**
17 * This event listener gets registered for requests that have been upgraded
18 * using the HTTPS-only mode to log failed upgrades to the console.
20 class nsHTTPSOnlyStreamListener : public nsIStreamListener {
21 public:
22 // nsISupports methods
23 NS_DECL_ISUPPORTS
24 NS_DECL_NSIREQUESTOBSERVER
25 NS_DECL_NSISTREAMLISTENER
27 explicit nsHTTPSOnlyStreamListener(nsIStreamListener* aListener,
28 nsILoadInfo* aLoadInfo);
30 private:
31 virtual ~nsHTTPSOnlyStreamListener() = default;
33 /**
34 * Records telemetry about the upgraded request.
35 * @param aStatus Request object
37 void RecordUpgradeTelemetry(nsIRequest* request, nsresult aStatus);
39 /**
40 * Logs information to the console if the request failed.
41 * @param request Request object
42 * @param aStatus Status of request
44 void LogUpgradeFailure(nsIRequest* request, nsresult aStatus);
46 nsCOMPtr<nsIStreamListener> mListener;
47 mozilla::TimeStamp mCreationStart;
50 #endif /* nsHTTPSOnlyStreamListener_h___ */