tor-browser

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

MockNetworkLayerController.h (1460B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
      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 MockNetworkLayerController_h__
      8 #define MockNetworkLayerController_h__
      9 
     10 #include "mozilla/net/DNS.h"
     11 #include "mozilla/RWLock.h"
     12 #include "nsIMockNetworkLayerController.h"
     13 #include "nsTHashMap.h"
     14 #include "nsTHashSet.h"
     15 
     16 namespace mozilla::net {
     17 
     18 bool FindNetAddrOverride(const NetAddr& aInput, NetAddr& aOutput);
     19 bool FindBlockedUDPAddr(const NetAddr& aInput);
     20 
     21 class MockNetworkLayerController : public nsIMockNetworkLayerController {
     22 public:
     23  NS_DECL_THREADSAFE_ISUPPORTS
     24  NS_DECL_NSIMOCKNETWORKLAYERCONTROLLER
     25 
     26  MockNetworkLayerController() = default;
     27 
     28  static already_AddRefed<nsIMockNetworkLayerController> GetSingleton();
     29 
     30 private:
     31  virtual ~MockNetworkLayerController() = default;
     32  mozilla::RWLock mLock{"MockNetworkLayerController::mLock"};
     33 
     34  nsTHashMap<nsCStringHashKey, NetAddr> mNetAddrOverrides MOZ_GUARDED_BY(mLock);
     35  nsTHashSet<nsCStringHashKey> mBlockedUDPAddresses MOZ_GUARDED_BY(mLock);
     36 
     37  friend bool FindNetAddrOverride(const NetAddr& aInput, NetAddr& aOutput);
     38  friend bool FindBlockedUDPAddr(const NetAddr& aInput);
     39 };
     40 
     41 }  // namespace mozilla::net
     42 
     43 #endif  // MockNetworkLayerController_h__