Line data Source code
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 : /**
8 : * This wraps nsSimpleURI so that all calls to it are done on the main thread.
9 : */
10 :
11 : #ifndef __NullPrincipalURI_h__
12 : #define __NullPrincipalURI_h__
13 :
14 : #include "nsIURI.h"
15 : #include "nsISizeOf.h"
16 : #include "nsString.h"
17 : #include "mozilla/Attributes.h"
18 : #include "nsIIPCSerializableURI.h"
19 : #include "mozilla/MemoryReporting.h"
20 : #include "NullPrincipal.h"
21 : #include "nsID.h"
22 :
23 : // {51fcd543-3b52-41f7-b91b-6b54102236e6}
24 : #define NS_NULLPRINCIPALURI_IMPLEMENTATION_CID \
25 : {0x51fcd543, 0x3b52, 0x41f7, \
26 : {0xb9, 0x1b, 0x6b, 0x54, 0x10, 0x22, 0x36, 0xe6} }
27 :
28 : class NullPrincipalURI final : public nsIURI
29 : , public nsISizeOf
30 : , public nsIIPCSerializableURI
31 : {
32 : public:
33 : NS_DECL_THREADSAFE_ISUPPORTS
34 : NS_DECL_NSIURI
35 : NS_DECL_NSIIPCSERIALIZABLEURI
36 :
37 : // nsISizeOf
38 : virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
39 : virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
40 :
41 : // NB: This constructor exists only for deserialization. Everyone
42 : // else should call Create.
43 : NullPrincipalURI();
44 :
45 : // Returns null on failure.
46 : static already_AddRefed<NullPrincipalURI> Create();
47 :
48 : private:
49 : NullPrincipalURI(const NullPrincipalURI& aOther);
50 :
51 96 : ~NullPrincipalURI() {}
52 :
53 : nsresult Init();
54 :
55 : char mPathBytes[NSID_LENGTH];
56 : nsFixedCString mPath;
57 : };
58 :
59 : #endif // __NullPrincipalURI_h__
|