tor-browser

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

HttpTrafficAnalyzer.h (1598B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef mozilla_netwerk_protocol_http_HttpTrafficAnalyzer_h
      7 #define mozilla_netwerk_protocol_http_HttpTrafficAnalyzer_h
      8 
      9 #include <stdint.h>
     10 #include "nsTArrayForwardDeclare.h"
     11 
     12 namespace mozilla {
     13 namespace net {
     14 
     15 #define DEFINE_CATEGORY(_name, _idx) e##_name = _idx##u,
     16 enum HttpTrafficCategory : uint8_t {
     17 #include "HttpTrafficAnalyzer.inc"
     18  eInvalid,
     19 };
     20 #undef DEFINE_CATEGORY
     21 
     22 class HttpTrafficAnalyzer final {
     23 public:
     24  enum ClassOfService : uint8_t {
     25    eLeader = 0,
     26    eBackground = 1,
     27    eOther = 255,
     28  };
     29 
     30  enum TrackingClassification : uint8_t {
     31    eNone = 0,
     32    eBasic = 1,
     33    eContent = 2,
     34    eFingerprinting = 3,
     35  };
     36 
     37  static HttpTrafficCategory CreateTrafficCategory(
     38      bool aIsPrivateMode, bool aIsSystemPrincipal, bool aIsThirdParty,
     39      ClassOfService aClassOfService, TrackingClassification aClassification);
     40 
     41  void IncrementHttpTransaction(HttpTrafficCategory aCategory);
     42  void IncrementHttpConnection(HttpTrafficCategory aCategory);
     43  void IncrementHttpConnection(nsTArray<HttpTrafficCategory>&& aCategories);
     44  void AccumulateHttpTransferredSize(HttpTrafficCategory aCategory,
     45                                     uint64_t aBytesRead, uint64_t aBytesSent);
     46 };
     47 
     48 }  // namespace net
     49 }  // namespace mozilla
     50 
     51 #endif  // mozilla_netwerk_protocol_http_HttpTrafficAnalyzer_h