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"
12 #include "nsIStreamListener.h"
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
{
22 // nsISupports methods
24 NS_DECL_NSIREQUESTOBSERVER
25 NS_DECL_NSISTREAMLISTENER
27 explicit nsHTTPSOnlyStreamListener(nsIStreamListener
* aListener
,
28 nsILoadInfo
* aLoadInfo
);
31 virtual ~nsHTTPSOnlyStreamListener() = default;
34 * Records telemetry about the upgraded request.
35 * @param aStatus Request object
37 void RecordUpgradeTelemetry(nsIRequest
* request
, nsresult aStatus
);
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___ */