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 SerializedLoadContext_h
8 #define SerializedLoadContext_h
10 #include "base/basictypes.h"
11 #include "ipc/IPCMessageUtils.h"
12 #include "ipc/IPCMessageUtilsSpecializations.h"
13 #include "mozilla/BasePrincipal.h"
18 * This file contains the IPC::SerializedLoadContext class, which is used to
19 * copy data across IPDL from Child process contexts so it is available in the
24 class nsIWebSocketChannel
;
28 class SerializedLoadContext
{
30 SerializedLoadContext()
32 mIsPrivateBitValid(false),
34 mUseRemoteTabs(false),
35 mUseRemoteSubframes(false),
36 mUseTrackingProtection(false) {
40 explicit SerializedLoadContext(nsILoadContext
* aLoadContext
);
41 explicit SerializedLoadContext(nsIChannel
* aChannel
);
42 explicit SerializedLoadContext(nsIWebSocketChannel
* aChannel
);
44 void Init(nsILoadContext
* aLoadContext
);
46 bool IsNotNull() const { return mIsNotNull
; }
47 bool IsPrivateBitValid() const { 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
;
56 bool mUseRemoteSubframes
;
57 bool mUseTrackingProtection
;
58 mozilla::OriginAttributes mOriginAttributes
;
61 // Function to serialize over IPDL
63 struct ParamTraits
<SerializedLoadContext
> {
64 typedef SerializedLoadContext paramType
;
66 static void Write(MessageWriter
* aWriter
, const paramType
& aParam
) {
68 aParam
.mOriginAttributes
.CreateSuffix(suffix
);
70 WriteParam(aWriter
, aParam
.mIsNotNull
);
71 WriteParam(aWriter
, aParam
.mIsContent
);
72 WriteParam(aWriter
, aParam
.mIsPrivateBitValid
);
73 WriteParam(aWriter
, aParam
.mUseRemoteTabs
);
74 WriteParam(aWriter
, aParam
.mUseRemoteSubframes
);
75 WriteParam(aWriter
, aParam
.mUseTrackingProtection
);
76 WriteParam(aWriter
, suffix
);
79 static bool Read(MessageReader
* aReader
, paramType
* aResult
) {
81 if (!ReadParam(aReader
, &aResult
->mIsNotNull
) ||
82 !ReadParam(aReader
, &aResult
->mIsContent
) ||
83 !ReadParam(aReader
, &aResult
->mIsPrivateBitValid
) ||
84 !ReadParam(aReader
, &aResult
->mUseRemoteTabs
) ||
85 !ReadParam(aReader
, &aResult
->mUseRemoteSubframes
) ||
86 !ReadParam(aReader
, &aResult
->mUseTrackingProtection
) ||
87 !ReadParam(aReader
, &suffix
)) {
90 return aResult
->mOriginAttributes
.PopulateFromSuffix(suffix
);
96 #endif // SerializedLoadContext_h