docshell/base/SerializedLoadContext.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set sw=2 ts=8 et tw=80 : */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef SerializedLoadContext_h
michael@0 8 #define SerializedLoadContext_h
michael@0 9
michael@0 10 #include "base/basictypes.h"
michael@0 11 #include "ipc/IPCMessageUtils.h"
michael@0 12
michael@0 13 class nsILoadContext;
michael@0 14
michael@0 15 /*
michael@0 16 * This file contains the IPC::SerializedLoadContext class, which is used to
michael@0 17 * copy data across IPDL from Child process contexts so it is available in the
michael@0 18 * Parent.
michael@0 19 */
michael@0 20
michael@0 21 class nsIChannel;
michael@0 22 class nsIWebSocketChannel;
michael@0 23
michael@0 24 namespace IPC {
michael@0 25
michael@0 26 class SerializedLoadContext
michael@0 27 {
michael@0 28 public:
michael@0 29 SerializedLoadContext()
michael@0 30 {
michael@0 31 Init(nullptr);
michael@0 32 }
michael@0 33
michael@0 34 SerializedLoadContext(nsILoadContext* aLoadContext);
michael@0 35 SerializedLoadContext(nsIChannel* aChannel);
michael@0 36 SerializedLoadContext(nsIWebSocketChannel* aChannel);
michael@0 37
michael@0 38 void Init(nsILoadContext* aLoadContext);
michael@0 39
michael@0 40 bool IsNotNull() const
michael@0 41 {
michael@0 42 return mIsNotNull;
michael@0 43 }
michael@0 44
michael@0 45 bool IsPrivateBitValid() const
michael@0 46 {
michael@0 47 return mIsPrivateBitValid;
michael@0 48 }
michael@0 49
michael@0 50 // used to indicate if child-side LoadContext * was null.
michael@0 51 bool mIsNotNull;
michael@0 52 // used to indicate if child-side mUsePrivateBrowsing flag is valid, even if
michael@0 53 // mIsNotNull is false, i.e., child LoadContext was null.
michael@0 54 bool mIsPrivateBitValid;
michael@0 55 bool mIsContent;
michael@0 56 bool mUsePrivateBrowsing;
michael@0 57 bool mUseRemoteTabs;
michael@0 58 bool mIsInBrowserElement;
michael@0 59 uint32_t mAppId;
michael@0 60 };
michael@0 61
michael@0 62 // Function to serialize over IPDL
michael@0 63 template<>
michael@0 64 struct ParamTraits<SerializedLoadContext>
michael@0 65 {
michael@0 66 typedef SerializedLoadContext paramType;
michael@0 67
michael@0 68 static void Write(Message* aMsg, const paramType& aParam)
michael@0 69 {
michael@0 70 WriteParam(aMsg, aParam.mIsNotNull);
michael@0 71 WriteParam(aMsg, aParam.mIsContent);
michael@0 72 WriteParam(aMsg, aParam.mIsPrivateBitValid);
michael@0 73 WriteParam(aMsg, aParam.mUsePrivateBrowsing);
michael@0 74 WriteParam(aMsg, aParam.mUseRemoteTabs);
michael@0 75 WriteParam(aMsg, aParam.mAppId);
michael@0 76 WriteParam(aMsg, aParam.mIsInBrowserElement);
michael@0 77 }
michael@0 78
michael@0 79 static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
michael@0 80 {
michael@0 81 if (!ReadParam(aMsg, aIter, &aResult->mIsNotNull) ||
michael@0 82 !ReadParam(aMsg, aIter, &aResult->mIsContent) ||
michael@0 83 !ReadParam(aMsg, aIter, &aResult->mIsPrivateBitValid) ||
michael@0 84 !ReadParam(aMsg, aIter, &aResult->mUsePrivateBrowsing) ||
michael@0 85 !ReadParam(aMsg, aIter, &aResult->mUseRemoteTabs) ||
michael@0 86 !ReadParam(aMsg, aIter, &aResult->mAppId) ||
michael@0 87 !ReadParam(aMsg, aIter, &aResult->mIsInBrowserElement)) {
michael@0 88 return false;
michael@0 89 }
michael@0 90
michael@0 91 return true;
michael@0 92 }
michael@0 93 };
michael@0 94
michael@0 95 } // namespace IPC
michael@0 96
michael@0 97 #endif // SerializedLoadContext_h
michael@0 98

mercurial