nsSimpleNestedURI.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. * URI class to be used for cases when a simple URI actually resolves to some
  7. * other sort of URI, with the latter being what's loaded when the load
  8. * happens. All objects of this class should always be immutable, so that the
  9. * inner URI and this URI don't get out of sync. The Clone() implementation
  10. * will guarantee this for the clone, but it's up to the protocol handlers
  11. * creating these URIs to ensure that in the first place. The innerURI passed
  12. * to this URI will be set immutable if possible.
  13. */
  14. #ifndef nsSimpleNestedURI_h__
  15. #define nsSimpleNestedURI_h__
  16. #include "nsCOMPtr.h"
  17. #include "nsSimpleURI.h"
  18. #include "nsINestedURI.h"
  19. #include "nsIIPCSerializableURI.h"
  20. namespace mozilla {
  21. namespace net {
  22. class nsSimpleNestedURI : public nsSimpleURI,
  23. public nsINestedURI
  24. {
  25. protected:
  26. ~nsSimpleNestedURI() {}
  27. public:
  28. // To be used by deserialization only. Leaves this object in an
  29. // uninitialized state that will throw on most accesses.
  30. nsSimpleNestedURI()
  31. {
  32. }
  33. // Constructor that should generally be used when constructing an object of
  34. // this class with |operator new|.
  35. explicit nsSimpleNestedURI(nsIURI* innerURI);
  36. NS_DECL_ISUPPORTS_INHERITED
  37. NS_DECL_NSINESTEDURI
  38. // Overrides for various methods nsSimpleURI implements follow.
  39. // nsSimpleURI overrides
  40. virtual nsresult EqualsInternal(nsIURI* other,
  41. RefHandlingEnum refHandlingMode,
  42. bool* result) override;
  43. virtual nsSimpleURI* StartClone(RefHandlingEnum refHandlingMode,
  44. const nsACString& newRef) override;
  45. // nsISerializable overrides
  46. NS_IMETHOD Read(nsIObjectInputStream* aStream) override;
  47. NS_IMETHOD Write(nsIObjectOutputStream* aStream) override;
  48. // nsIIPCSerializableURI overrides
  49. NS_DECL_NSIIPCSERIALIZABLEURI
  50. // Override the nsIClassInfo method GetClassIDNoAlloc to make sure our
  51. // nsISerializable impl works right.
  52. NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) override;
  53. protected:
  54. nsCOMPtr<nsIURI> mInnerURI;
  55. };
  56. } // namespace net
  57. } // namespace mozilla
  58. #endif /* nsSimpleNestedURI_h__ */