tor-browser

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

WebrtcGlobalInformation.h (3365B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef _WEBRTC_GLOBAL_INFORMATION_H_
      6 #define _WEBRTC_GLOBAL_INFORMATION_H_
      7 
      8 #include "WebrtcGlobalStatsHistory.h"
      9 #include "mozilla/Attributes.h"
     10 #include "mozilla/dom/BindingDeclarations.h"  // for Optional
     11 #include "mozilla/dom/WebrtcGlobalInformationBinding.h"
     12 #include "nsDOMNavigationTiming.h"
     13 
     14 namespace mozilla {
     15 class PeerConnectionImpl;
     16 class ErrorResult;
     17 
     18 namespace dom {
     19 
     20 class GlobalObject;
     21 class WebrtcGlobalStatisticsCallback;
     22 class WebrtcGlobalStatisticsHistoryPcIdsCallback;
     23 class WebrtcGlobalLoggingCallback;
     24 struct RTCStatsReportInternal;
     25 
     26 class WebrtcGlobalInformation {
     27 public:
     28  MOZ_CAN_RUN_SCRIPT
     29  static void GetAllStats(const GlobalObject& aGlobal,
     30                          WebrtcGlobalStatisticsCallback& aStatsCallback,
     31                          const Optional<nsAString>& aPcIdFilter,
     32                          ErrorResult& aRv);
     33 
     34  MOZ_CAN_RUN_SCRIPT
     35  static void GetStatsHistoryPcIds(
     36      const GlobalObject& aGlobal,
     37      WebrtcGlobalStatisticsHistoryPcIdsCallback& aPcIdsCallback,
     38      ErrorResult& aRv);
     39 
     40  MOZ_CAN_RUN_SCRIPT
     41  static void GetStatsHistorySince(
     42      const GlobalObject& aGlobal,
     43      WebrtcGlobalStatisticsHistoryCallback& aStatsCallback,
     44      const nsAString& aPcIdFilter, const Optional<DOMHighResTimeStamp>& aAfter,
     45      const Optional<DOMHighResTimeStamp>& aSdpAfter, ErrorResult& aRv);
     46 
     47  static void GetMediaContext(const GlobalObject& aGlobal,
     48                              WebrtcGlobalMediaContext& aContext);
     49 
     50  static void GatherHistory();
     51 
     52  static void ClearAllStats(const GlobalObject& aGlobal);
     53 
     54  MOZ_CAN_RUN_SCRIPT
     55  static void GetLogging(const GlobalObject& aGlobal, const nsAString& aPattern,
     56                         WebrtcGlobalLoggingCallback& aLoggingCallback,
     57                         ErrorResult& aRv);
     58 
     59  static void ClearLogging(const GlobalObject& aGlobal);
     60 
     61  static void SetAecDebug(const GlobalObject& aGlobal, bool aEnable);
     62  static bool AecDebug(const GlobalObject& aGlobal);
     63  static void GetAecDebugLogDir(const GlobalObject& aGlobal, nsAString& aDir);
     64 
     65  static void StashStats(const RTCStatsReportInternal& aReport);
     66 
     67  WebrtcGlobalInformation() = delete;
     68  WebrtcGlobalInformation(const WebrtcGlobalInformation& aOrig) = delete;
     69  WebrtcGlobalInformation& operator=(const WebrtcGlobalInformation& aRhs) =
     70      delete;
     71 
     72  struct PcTrackingUpdate {
     73    static PcTrackingUpdate Add(const nsString& aPcid,
     74                                const bool& aLongTermStatsDisabled) {
     75      return PcTrackingUpdate{aPcid, Some(aLongTermStatsDisabled)};
     76    }
     77    static PcTrackingUpdate Remove(const nsString& aPcid) {
     78      return PcTrackingUpdate{aPcid, Nothing()};
     79    }
     80    nsString mPcid;
     81    Maybe<bool> mLongTermStatsDisabled;
     82    enum class Type {
     83      Add,
     84      Remove,
     85    };
     86    Type Type() const {
     87      return mLongTermStatsDisabled ? Type::Add : Type::Remove;
     88    }
     89  };
     90  static void PeerConnectionTracking(PcTrackingUpdate& aUpdate) {
     91    AdjustTimerReferences(std::move(aUpdate));
     92  }
     93 
     94 private:
     95  static void AdjustTimerReferences(PcTrackingUpdate&& aUpdate);
     96 };
     97 
     98 }  // namespace dom
     99 }  // namespace mozilla
    100 
    101 #endif  // _WEBRTC_GLOBAL_INFORMATION_H_