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/. */
7 #ifndef mozilla_dom_ChannelInfo_h
8 #define mozilla_dom_ChannelInfo_h
14 class nsIGlobalObject
;
26 // This class represents the information related to a Response that we
27 // retrieve from the corresponding channel that is used to perform the fetch.
29 // When adding new members to this object, the following code needs to be
32 // * InitFromChannel and InitFromIPCChannelInfo members
33 // * ResurrectInfoOnChannel member
34 // * AsIPCChannelInfo member
35 // * constructors and assignment operators for this class.
36 // * DOM Cache schema code (in dom/cache/DBSchema.cpp) to ensure that the newly
37 // added member is saved into the DB and loaded from it properly.
39 // Care must be taken when initializing this object, or when calling
40 // ResurrectInfoOnChannel(). This object cannot be initialized twice, and
41 // ResurrectInfoOnChannel() cannot be called on it before it has been
42 // initialized. There are assertions ensuring these invariants.
43 class ChannelInfo final
{
45 typedef mozilla::ipc::IPCChannelInfo IPCChannelInfo
;
47 ChannelInfo() : mInited(false) {}
49 ChannelInfo(const ChannelInfo
& aRHS
) = default;
51 ChannelInfo
& operator=(const ChannelInfo
& aRHS
) = default;
53 void InitFromDocument(Document
* aDoc
);
54 void InitFromChannel(nsIChannel
* aChannel
);
55 void InitFromChromeGlobal(nsIGlobalObject
* aGlobal
);
56 void InitFromIPCChannelInfo(const IPCChannelInfo
& aChannelInfo
);
58 // This restores every possible information stored from a previous channel
59 // object on a new one.
60 nsresult
ResurrectInfoOnChannel(nsIChannel
* aChannel
);
62 bool IsInitialized() const { return mInited
; }
64 IPCChannelInfo
AsIPCChannelInfo() const;
67 void SetSecurityInfo(nsISupports
* aSecurityInfo
);
70 nsCString mSecurityInfo
;
75 } // namespace mozilla
77 #endif // mozilla_dom_ChannelInfo_h