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