Backed out changesets aed22a2d8353 and c61fe8e1f887 (bug 908006) for OSX reftest...
[gecko.git] / docshell / base / SerializedLoadContext.h
blob86d9f7995fdba6b66463bb0c555dcbfdcbe0177c
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
17 * Parent.
20 class nsIChannel;
21 class nsIWebSocketChannel;
23 namespace IPC {
25 class SerializedLoadContext
27 public:
28 SerializedLoadContext()
30 Init(nullptr);
33 SerializedLoadContext(nsILoadContext* aLoadContext);
34 SerializedLoadContext(nsIChannel* aChannel);
35 SerializedLoadContext(nsIWebSocketChannel* aChannel);
37 void Init(nsILoadContext* aLoadContext);
39 bool IsNotNull() const
41 return mIsNotNull;
44 bool IsPrivateBitValid() const
46 return mIsPrivateBitValid;
49 // used to indicate if child-side LoadContext * was null.
50 bool mIsNotNull;
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;
54 bool mIsContent;
55 bool mUsePrivateBrowsing;
56 bool mIsInBrowserElement;
57 uint32_t mAppId;
60 // Function to serialize over IPDL
61 template<>
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)) {
84 return false;
87 return true;
91 } // namespace IPC
93 #endif // SerializedLoadContext_h