nsSimpleURI.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* -*- Mode: C++; tab-width: 2; 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. #ifndef nsSimpleURI_h__
  6. #define nsSimpleURI_h__
  7. #include "mozilla/MemoryReporting.h"
  8. #include "nsIURI.h"
  9. #include "nsISerializable.h"
  10. #include "nsString.h"
  11. #include "nsIClassInfo.h"
  12. #include "nsIMutable.h"
  13. #include "nsISizeOf.h"
  14. #include "nsIIPCSerializableURI.h"
  15. namespace mozilla {
  16. namespace net {
  17. #define NS_THIS_SIMPLEURI_IMPLEMENTATION_CID \
  18. { /* 0b9bb0c2-fee6-470b-b9b9-9fd9462b5e19 */ \
  19. 0x0b9bb0c2, \
  20. 0xfee6, \
  21. 0x470b, \
  22. {0xb9, 0xb9, 0x9f, 0xd9, 0x46, 0x2b, 0x5e, 0x19} \
  23. }
  24. class nsSimpleURI
  25. : public nsIURI
  26. , public nsISerializable
  27. , public nsIClassInfo
  28. , public nsIMutable
  29. , public nsISizeOf
  30. , public nsIIPCSerializableURI
  31. {
  32. protected:
  33. virtual ~nsSimpleURI();
  34. public:
  35. NS_DECL_ISUPPORTS
  36. NS_DECL_NSIURI
  37. NS_DECL_NSISERIALIZABLE
  38. NS_DECL_NSICLASSINFO
  39. NS_DECL_NSIMUTABLE
  40. NS_DECL_NSIIPCSERIALIZABLEURI
  41. // nsSimpleURI methods:
  42. nsSimpleURI();
  43. // nsISizeOf
  44. // Among the sub-classes that inherit (directly or indirectly) from
  45. // nsSimpleURI, measurement of the following members may be added later if
  46. // DMD finds it is worthwhile:
  47. // - nsJSURI: mBaseURI
  48. // - nsSimpleNestedURI: mInnerURI
  49. // - nsBlobURI: mPrincipal
  50. virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
  51. virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
  52. protected:
  53. // enum used in a few places to specify how .ref attribute should be handled
  54. enum RefHandlingEnum {
  55. eIgnoreRef,
  56. eHonorRef,
  57. eReplaceRef
  58. };
  59. // Helper to share code between Equals methods.
  60. virtual nsresult EqualsInternal(nsIURI* other,
  61. RefHandlingEnum refHandlingMode,
  62. bool* result);
  63. // Helper to be used by inherited classes who want to test
  64. // equality given an assumed nsSimpleURI. This must NOT check
  65. // the passed-in other for QI to our CID.
  66. bool EqualsInternal(nsSimpleURI* otherUri, RefHandlingEnum refHandlingMode);
  67. // Used by StartClone (and versions of StartClone in subclasses) to
  68. // handle the ref in the right way for clones.
  69. void SetRefOnClone(nsSimpleURI* url, RefHandlingEnum refHandlingMode,
  70. const nsACString& newRef);
  71. // NOTE: This takes the refHandlingMode as an argument because
  72. // nsSimpleNestedURI's specialized version needs to know how to clone
  73. // its inner URI.
  74. virtual nsSimpleURI* StartClone(RefHandlingEnum refHandlingMode,
  75. const nsACString& newRef);
  76. // Helper to share code between Clone methods.
  77. virtual nsresult CloneInternal(RefHandlingEnum refHandlingMode,
  78. const nsACString &newRef,
  79. nsIURI** clone);
  80. nsCString mScheme;
  81. nsCString mPath; // NOTE: mPath does not include ref, as an optimization
  82. nsCString mRef; // so that URIs with different refs can share string data.
  83. nsCString mQuery; // so that URLs with different querys can share string data.
  84. bool mMutable;
  85. bool mIsRefValid; // To distinguish between empty-ref and no-ref.
  86. bool mIsQueryValid; // To distinguish between empty-query and no-query.
  87. };
  88. } // namespace net
  89. } // namespace mozilla
  90. #endif // nsSimpleURI_h__