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 /**
7  * URI class to be used for cases when a simple URI actually resolves to some
8  * other sort of URI, with the latter being what's loaded when the load
9  * happens.  All objects of this class should always be immutable, so that the
10  * inner URI and this URI don't get out of sync.  The Clone() implementation
11  * will guarantee this for the clone, but it's up to the protocol handlers
12  * creating these URIs to ensure that in the first place.  The innerURI passed
13  * to this URI will be set immutable if possible.
14  */
15 
16 #ifndef nsSimpleNestedURI_h__
17 #define nsSimpleNestedURI_h__
18 
19 #include "nsCOMPtr.h"
20 #include "nsSimpleURI.h"
21 #include "nsINestedURI.h"
22 
23 #include "nsIIPCSerializableURI.h"
24 
25 namespace mozilla {
26 namespace net {
27 
28 class nsSimpleNestedURI : public nsSimpleURI,
29                           public nsINestedURI
30 {
31 protected:
~nsSimpleNestedURI()32     ~nsSimpleNestedURI() {}
33 
34 public:
35     // To be used by deserialization only.  Leaves this object in an
36     // uninitialized state that will throw on most accesses.
nsSimpleNestedURI()37     nsSimpleNestedURI()
38     {
39     }
40 
41     // Constructor that should generally be used when constructing an object of
42     // this class with |operator new|.
43     explicit nsSimpleNestedURI(nsIURI* innerURI);
44 
45     NS_DECL_ISUPPORTS_INHERITED
46     NS_DECL_NSINESTEDURI
47 
48     // Overrides for various methods nsSimpleURI implements follow.
49 
50     // nsSimpleURI overrides
51     virtual nsresult EqualsInternal(nsIURI* other,
52                                     RefHandlingEnum refHandlingMode,
53                                     bool* result) override;
54     virtual nsSimpleURI* StartClone(RefHandlingEnum refHandlingMode,
55                                     const nsACString& newRef) override;
56 
57     // nsISerializable overrides
58     NS_IMETHOD Read(nsIObjectInputStream* aStream) override;
59     NS_IMETHOD Write(nsIObjectOutputStream* aStream) override;
60 
61     // nsIIPCSerializableURI overrides
62     NS_DECL_NSIIPCSERIALIZABLEURI
63 
64     // Override the nsIClassInfo method GetClassIDNoAlloc to make sure our
65     // nsISerializable impl works right.
66     NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) override;
67 
68 protected:
69     nsCOMPtr<nsIURI> mInnerURI;
70 };
71 
72 } // namespace net
73 } // namespace mozilla
74 
75 #endif /* nsSimpleNestedURI_h__ */
76