tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsHTTPSOnlyStreamListener.h (1533B)


      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/. */
      6 
      7 #ifndef nsHTTPSOnlyStreamListener_h___
      8 #define nsHTTPSOnlyStreamListener_h___
      9 
     10 #include "mozilla/TimeStamp.h"
     11 #include "nsCOMPtr.h"
     12 #include "nsIStreamListener.h"
     13 
     14 class nsILoadInfo;
     15 
     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.
     19 */
     20 class nsHTTPSOnlyStreamListener : public nsIStreamListener {
     21 public:
     22  // nsISupports methods
     23  NS_DECL_ISUPPORTS
     24  NS_DECL_NSIREQUESTOBSERVER
     25  NS_DECL_NSISTREAMLISTENER
     26 
     27  explicit nsHTTPSOnlyStreamListener(nsIStreamListener* aListener,
     28                                     nsILoadInfo* aLoadInfo);
     29 
     30 private:
     31  virtual ~nsHTTPSOnlyStreamListener() = default;
     32 
     33  /**
     34   * Records telemetry about the upgraded request.
     35   * @param aStatus Request object
     36   */
     37  void RecordUpgradeTelemetry(nsIRequest* request, nsresult aStatus);
     38 
     39  /**
     40   * Logs information to the console if the request failed.
     41   * @param request Request object
     42   * @param aStatus Status of request
     43   */
     44  void LogUpgradeFailure(nsIRequest* request, nsresult aStatus);
     45 
     46  nsCOMPtr<nsIStreamListener> mListener;
     47  mozilla::TimeStamp mCreationStart;
     48 };
     49 
     50 #endif /* nsHTTPSOnlyStreamListener_h___ */