nsNullPrincipalURI.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. * vim: sw=2 ts=2 sts=2 expandtab
  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. * This wraps nsSimpleURI so that all calls to it are done on the main thread.
  8. */
  9. #ifndef __nsNullPrincipalURI_h__
  10. #define __nsNullPrincipalURI_h__
  11. #include "nsIURI.h"
  12. #include "nsISizeOf.h"
  13. #include "nsString.h"
  14. #include "mozilla/Attributes.h"
  15. #include "nsIIPCSerializableURI.h"
  16. #include "mozilla/MemoryReporting.h"
  17. #include "nsNullPrincipal.h"
  18. #include "nsID.h"
  19. // {51fcd543-3b52-41f7-b91b-6b54102236e6}
  20. #define NS_NULLPRINCIPALURI_IMPLEMENTATION_CID \
  21. {0x51fcd543, 0x3b52, 0x41f7, \
  22. {0xb9, 0x1b, 0x6b, 0x54, 0x10, 0x22, 0x36, 0xe6} }
  23. class nsNullPrincipalURI final : public nsIURI
  24. , public nsISizeOf
  25. , public nsIIPCSerializableURI
  26. {
  27. public:
  28. NS_DECL_THREADSAFE_ISUPPORTS
  29. NS_DECL_NSIURI
  30. NS_DECL_NSIIPCSERIALIZABLEURI
  31. // nsISizeOf
  32. virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
  33. virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
  34. // NB: This constructor exists only for deserialization. Everyone
  35. // else should call Create.
  36. nsNullPrincipalURI();
  37. // Returns null on failure.
  38. static already_AddRefed<nsNullPrincipalURI> Create();
  39. private:
  40. nsNullPrincipalURI(const nsNullPrincipalURI& aOther);
  41. ~nsNullPrincipalURI() {}
  42. nsresult Init();
  43. char mPathBytes[NSID_LENGTH];
  44. nsFixedCString mPath;
  45. };
  46. #endif // __nsNullPrincipalURI_h__