/work/obj-fuzz/dist/include/mozilla/dom/ChannelInfo.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
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 | | #ifndef mozilla_dom_ChannelInfo_h |
8 | | #define mozilla_dom_ChannelInfo_h |
9 | | |
10 | | #include "nsString.h" |
11 | | #include "nsCOMPtr.h" |
12 | | |
13 | | class nsIChannel; |
14 | | class nsIDocument; |
15 | | class nsIGlobalObject; |
16 | | class nsIURI; |
17 | | |
18 | | namespace mozilla { |
19 | | namespace ipc { |
20 | | class IPCChannelInfo; |
21 | | } // namespace ipc |
22 | | |
23 | | namespace dom { |
24 | | |
25 | | // This class represents the information related to a Response that we |
26 | | // retrieve from the corresponding channel that is used to perform the fetch. |
27 | | // |
28 | | // When adding new members to this object, the following code needs to be |
29 | | // updated: |
30 | | // * IPCChannelInfo |
31 | | // * InitFromChannel and InitFromIPCChannelInfo members |
32 | | // * ResurrectInfoOnChannel member |
33 | | // * AsIPCChannelInfo member |
34 | | // * constructors and assignment operators for this class. |
35 | | // * DOM Cache schema code (in dom/cache/DBSchema.cpp) to ensure that the newly |
36 | | // added member is saved into the DB and loaded from it properly. |
37 | | // |
38 | | // Care must be taken when initializing this object, or when calling |
39 | | // ResurrectInfoOnChannel(). This object cannot be initialized twice, and |
40 | | // ResurrectInfoOnChannel() cannot be called on it before it has been |
41 | | // initialized. There are assertions ensuring these invariants. |
42 | | class ChannelInfo final |
43 | | { |
44 | | public: |
45 | | typedef mozilla::ipc::IPCChannelInfo IPCChannelInfo; |
46 | | |
47 | | ChannelInfo() |
48 | | : mInited(false) |
49 | 0 | { |
50 | 0 | } |
51 | | |
52 | | ChannelInfo(const ChannelInfo& aRHS) |
53 | | : mSecurityInfo(aRHS.mSecurityInfo) |
54 | | , mInited(aRHS.mInited) |
55 | 0 | { |
56 | 0 | } |
57 | | |
58 | | ChannelInfo& |
59 | | operator=(const ChannelInfo& aRHS) |
60 | 0 | { |
61 | 0 | mSecurityInfo = aRHS.mSecurityInfo; |
62 | 0 | mInited = aRHS.mInited; |
63 | 0 | return *this; |
64 | 0 | } |
65 | | |
66 | | void InitFromDocument(nsIDocument* aDoc); |
67 | | void InitFromChannel(nsIChannel* aChannel); |
68 | | void InitFromChromeGlobal(nsIGlobalObject* aGlobal); |
69 | | void InitFromIPCChannelInfo(const IPCChannelInfo& aChannelInfo); |
70 | | |
71 | | // This restores every possible information stored from a previous channel |
72 | | // object on a new one. |
73 | | nsresult ResurrectInfoOnChannel(nsIChannel* aChannel); |
74 | | |
75 | | bool IsInitialized() const |
76 | 0 | { |
77 | 0 | return mInited; |
78 | 0 | } |
79 | | |
80 | | IPCChannelInfo AsIPCChannelInfo() const; |
81 | | |
82 | | private: |
83 | | void SetSecurityInfo(nsISupports* aSecurityInfo); |
84 | | |
85 | | private: |
86 | | nsCString mSecurityInfo; |
87 | | bool mInited; |
88 | | }; |
89 | | |
90 | | } // namespace dom |
91 | | } // namespace mozilla |
92 | | |
93 | | #endif // mozilla_dom_ChannelInfo_h |