tor-browser

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

MediaTransportHandlerIPC.h (4053B)


      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 _MTRANSPORTHANDLER_IPC_H__
      6 #define _MTRANSPORTHANDLER_IPC_H__
      7 
      8 #include "jsapi/MediaTransportHandler.h"
      9 #include "mozilla/dom/PMediaTransportChild.h"
     10 
     11 namespace mozilla {
     12 
     13 class MediaTransportChild;
     14 
     15 // Implementation of MediaTransportHandler that uses IPC (PMediaTransport) to
     16 // talk to mtransport on another process.
     17 class MediaTransportHandlerIPC final : public MediaTransportHandler {
     18 public:
     19  explicit MediaTransportHandlerIPC();
     20  void Initialize() override;
     21  RefPtr<IceLogPromise> GetIceLog(const nsCString& aPattern) override;
     22  void ClearIceLog() override;
     23  void EnterPrivateMode() override;
     24  void ExitPrivateMode() override;
     25 
     26  void CreateIceCtx(const std::string& aName) override;
     27 
     28  nsresult SetIceConfig(const nsTArray<dom::RTCIceServer>& aIceServers,
     29                        dom::RTCIceTransportPolicy aIcePolicy) override;
     30 
     31  // We will probably be able to move the proxy lookup stuff into
     32  // this class once we move mtransport to its own process.
     33  void SetProxyConfig(NrSocketProxyConfig&& aProxyConfig) override;
     34 
     35  void EnsureProvisionalTransport(const std::string& aTransportId,
     36                                  const std::string& aLocalUfrag,
     37                                  const std::string& aLocalPwd,
     38                                  int aComponentCount) override;
     39 
     40  void SetTargetForDefaultLocalAddressLookup(const std::string& aTargetIp,
     41                                             uint16_t aTargetPort) override;
     42 
     43  // We set default-route-only as late as possible because it depends on what
     44  // capture permissions have been granted on the window, which could easily
     45  // change between Init (ie; when the PC is created) and StartIceGathering
     46  // (ie; when we set the local description).
     47  void StartIceGathering(bool aDefaultRouteOnly, bool aObfuscateHostAddresses,
     48                         // TODO: It probably makes sense to look
     49                         // this up internally
     50                         const nsTArray<NrIceStunAddr>& aStunAddrs) override;
     51 
     52  void ActivateTransport(
     53      const std::string& aTransportId, const std::string& aLocalUfrag,
     54      const std::string& aLocalPwd, size_t aComponentCount,
     55      const std::string& aUfrag, const std::string& aPassword,
     56      const nsTArray<uint8_t>& aKeyDer, const nsTArray<uint8_t>& aCertDer,
     57      SSLKEAType aAuthType, bool aDtlsClient, const DtlsDigestList& aDigests,
     58      bool aPrivacyRequested) override;
     59 
     60  void RemoveTransportsExcept(
     61      const std::set<std::string>& aTransportIds) override;
     62 
     63  void StartIceChecks(bool aIsControlling,
     64                      const std::vector<std::string>& aIceOptions) override;
     65 
     66  void SendPacket(const std::string& aTransportId,
     67                  MediaPacket&& aPacket) override;
     68 
     69  void AddIceCandidate(const std::string& aTransportId,
     70                       const std::string& aCandidate, const std::string& aUfrag,
     71                       const std::string& aObfuscatedAddress) override;
     72 
     73  void UpdateNetworkState(bool aOnline) override;
     74 
     75  RefPtr<dom::RTCStatsPromise> GetIceStats(const std::string& aTransportId,
     76                                           DOMHighResTimeStamp aNow) override;
     77 
     78 private:
     79  friend class MediaTransportChild;
     80  void Destroy() override;
     81  virtual ~MediaTransportHandlerIPC();
     82 
     83  RefPtr<MediaTransportChild> mChild;
     84 
     85  // |mChild| can only be initted asynchronously, |mInitPromise| resolves
     86  // when that happens. The |Then| calls make it convenient to dispatch API
     87  // calls to main, which is a bonus.
     88  // Init promise is not exclusive; this lets us call |Then| on it for every
     89  // API call we get, instead of creating another promise each time.
     90  typedef MozPromise<bool, nsCString, false> InitPromise;
     91  RefPtr<InitPromise> mInitPromise;
     92  nsCOMPtr<nsISerialEventTarget> mThread;
     93 };
     94 
     95 }  // namespace mozilla
     96 
     97 #endif  //_MTRANSPORTHANDLER_IPC_H__