1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et 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 SerializedLoadContext_h
8 #define SerializedLoadContext_h
10 #include "base/basictypes.h"
11 #include "ipc/IPCMessageUtils.h"
12 #include "nsILoadContext.h"
15 * This file contains the IPC::SerializedLoadContext class, which is used to
16 * copy data across IPDL from Child process contexts so it is available in the
21 class nsIWebSocketChannel
;
25 class SerializedLoadContext
28 SerializedLoadContext()
33 SerializedLoadContext(nsILoadContext
* aLoadContext
);
34 SerializedLoadContext(nsIChannel
* aChannel
);
35 SerializedLoadContext(nsIWebSocketChannel
* aChannel
);
37 void Init(nsILoadContext
* aLoadContext
);
39 bool IsNotNull() const
44 bool IsPrivateBitValid() const
46 return mIsPrivateBitValid
;
49 // used to indicate if child-side LoadContext * was null.
51 // used to indicate if child-side mUsePrivateBrowsing flag is valid, even if
52 // mIsNotNull is false, i.e., child LoadContext was null.
53 bool mIsPrivateBitValid
;
55 bool mUsePrivateBrowsing
;
56 bool mIsInBrowserElement
;
60 // Function to serialize over IPDL
62 struct ParamTraits
<SerializedLoadContext
>
64 typedef SerializedLoadContext paramType
;
66 static void Write(Message
* aMsg
, const paramType
& aParam
)
68 WriteParam(aMsg
, aParam
.mIsNotNull
);
69 WriteParam(aMsg
, aParam
.mIsContent
);
70 WriteParam(aMsg
, aParam
.mIsPrivateBitValid
);
71 WriteParam(aMsg
, aParam
.mUsePrivateBrowsing
);
72 WriteParam(aMsg
, aParam
.mAppId
);
73 WriteParam(aMsg
, aParam
.mIsInBrowserElement
);
76 static bool Read(const Message
* aMsg
, void** aIter
, paramType
* aResult
)
78 if (!ReadParam(aMsg
, aIter
, &aResult
->mIsNotNull
) ||
79 !ReadParam(aMsg
, aIter
, &aResult
->mIsContent
) ||
80 !ReadParam(aMsg
, aIter
, &aResult
->mIsPrivateBitValid
) ||
81 !ReadParam(aMsg
, aIter
, &aResult
->mUsePrivateBrowsing
) ||
82 !ReadParam(aMsg
, aIter
, &aResult
->mAppId
) ||
83 !ReadParam(aMsg
, aIter
, &aResult
->mIsInBrowserElement
)) {
93 #endif // SerializedLoadContext_h