tor-browser

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

OnionAliasService.h (1190B)


      1 #ifndef OnionAliasService_h_
      2 #define OnionAliasService_h_
      3 
      4 #include "IOnionAliasService.h"
      5 
      6 #include "mozilla/RWLock.h"
      7 #include "nsClassHashtable.h"
      8 #include "nsHashKeys.h"
      9 #include "ScopedNSSTypes.h"
     10 
     11 namespace torproject {
     12 
     13 class OnionAliasService final : public IOnionAliasService {
     14 public:
     15  NS_DECL_THREADSAFE_ISUPPORTS
     16  NS_DECL_IONIONALIASSERVICE
     17 
     18  static already_AddRefed<IOnionAliasService> GetSingleton();
     19 
     20 private:
     21  OnionAliasService() = default;
     22  OnionAliasService(const OnionAliasService&) = delete;
     23  OnionAliasService(OnionAliasService&&) = delete;
     24  OnionAliasService& operator=(const OnionAliasService&) = delete;
     25  OnionAliasService& operator=(OnionAliasService&&) = delete;
     26  virtual ~OnionAliasService() = default;
     27 
     28  // mLock protects access to mOnionAliases
     29  mozilla::RWLock mLock{"OnionAliasService.mLock"};
     30 
     31  // AutoCStrings have a 64 byte buffer, so it is advised not to use them for
     32  // long storage. However, it is enough to contain onion addresses, so we use
     33  // them instead, and avoid allocating on heap for each alias
     34  nsClassHashtable<nsCStringHashKey, nsAutoCString> mOnionAliases;
     35 };
     36 
     37 }  // namespace torproject
     38 
     39 #endif  // OnionAliasService_h_