Bug 1857669 - Install libavcodec/libavutil for Selenium tests r=releng-reviewers...
[gecko.git] / docshell / base / SerializedLoadContext.h
blobd47ad080037b810b0216ac864c8d0f443f392575
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"
15 class nsILoadContext;
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
20 * Parent.
23 class nsIChannel;
24 class nsIWebSocketChannel;
26 namespace IPC {
28 class SerializedLoadContext {
29 public:
30 SerializedLoadContext()
31 : mIsNotNull(false),
32 mIsPrivateBitValid(false),
33 mIsContent(false),
34 mUseRemoteTabs(false),
35 mUseRemoteSubframes(false),
36 mUseTrackingProtection(false) {
37 Init(nullptr);
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.
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 mUseRemoteTabs;
56 bool mUseRemoteSubframes;
57 bool mUseTrackingProtection;
58 mozilla::OriginAttributes mOriginAttributes;
61 // Function to serialize over IPDL
62 template <>
63 struct ParamTraits<SerializedLoadContext> {
64 typedef SerializedLoadContext paramType;
66 static void Write(MessageWriter* aWriter, const paramType& aParam) {
67 nsAutoCString suffix;
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) {
80 nsAutoCString suffix;
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)) {
88 return false;
90 return aResult->mOriginAttributes.PopulateFromSuffix(suffix);
94 } // namespace IPC
96 #endif // SerializedLoadContext_h