Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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"
13 class nsILoadContext;
15 /*
16 * This file contains the IPC::SerializedLoadContext class, which is used to
17 * copy data across IPDL from Child process contexts so it is available in the
18 * Parent.
19 */
21 class nsIChannel;
22 class nsIWebSocketChannel;
24 namespace IPC {
26 class SerializedLoadContext
27 {
28 public:
29 SerializedLoadContext()
30 {
31 Init(nullptr);
32 }
34 SerializedLoadContext(nsILoadContext* aLoadContext);
35 SerializedLoadContext(nsIChannel* aChannel);
36 SerializedLoadContext(nsIWebSocketChannel* aChannel);
38 void Init(nsILoadContext* aLoadContext);
40 bool IsNotNull() const
41 {
42 return mIsNotNull;
43 }
45 bool IsPrivateBitValid() const
46 {
47 return mIsPrivateBitValid;
48 }
50 // used to indicate if child-side LoadContext * was null.
51 bool mIsNotNull;
52 // used to indicate if child-side mUsePrivateBrowsing flag is valid, even if
53 // mIsNotNull is false, i.e., child LoadContext was null.
54 bool mIsPrivateBitValid;
55 bool mIsContent;
56 bool mUsePrivateBrowsing;
57 bool mUseRemoteTabs;
58 bool mIsInBrowserElement;
59 uint32_t mAppId;
60 };
62 // Function to serialize over IPDL
63 template<>
64 struct ParamTraits<SerializedLoadContext>
65 {
66 typedef SerializedLoadContext paramType;
68 static void Write(Message* aMsg, const paramType& aParam)
69 {
70 WriteParam(aMsg, aParam.mIsNotNull);
71 WriteParam(aMsg, aParam.mIsContent);
72 WriteParam(aMsg, aParam.mIsPrivateBitValid);
73 WriteParam(aMsg, aParam.mUsePrivateBrowsing);
74 WriteParam(aMsg, aParam.mUseRemoteTabs);
75 WriteParam(aMsg, aParam.mAppId);
76 WriteParam(aMsg, aParam.mIsInBrowserElement);
77 }
79 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
80 {
81 if (!ReadParam(aMsg, aIter, &aResult->mIsNotNull) ||
82 !ReadParam(aMsg, aIter, &aResult->mIsContent) ||
83 !ReadParam(aMsg, aIter, &aResult->mIsPrivateBitValid) ||
84 !ReadParam(aMsg, aIter, &aResult->mUsePrivateBrowsing) ||
85 !ReadParam(aMsg, aIter, &aResult->mUseRemoteTabs) ||
86 !ReadParam(aMsg, aIter, &aResult->mAppId) ||
87 !ReadParam(aMsg, aIter, &aResult->mIsInBrowserElement)) {
88 return false;
89 }
91 return true;
92 }
93 };
95 } // namespace IPC
97 #endif // SerializedLoadContext_h