LCOV - code coverage report
Current view: top level - ipc/glue - BackgroundUtils.h (source / functions) Hit Total Coverage
Test: output.info Lines: 9 9 100.0 %
Date: 2017-07-14 16:53:18 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_ipc_backgroundutils_h__
       8             : #define mozilla_ipc_backgroundutils_h__
       9             : 
      10             : #include "ipc/IPCMessageUtils.h"
      11             : #include "mozilla/Attributes.h"
      12             : #include "mozilla/BasePrincipal.h"
      13             : #include "nsCOMPtr.h"
      14             : #include "nscore.h"
      15             : 
      16             : class nsILoadInfo;
      17             : class nsIPrincipal;
      18             : class nsIRedirectHistoryEntry;
      19             : 
      20             : namespace IPC {
      21             : 
      22             : namespace detail {
      23             : template<class ParamType>
      24             : struct OriginAttributesParamTraits
      25             : {
      26             :   typedef ParamType paramType;
      27             : 
      28          12 :   static void Write(Message* aMsg, const paramType& aParam)
      29             :   {
      30          24 :     nsAutoCString suffix;
      31          12 :     aParam.CreateSuffix(suffix);
      32          12 :     WriteParam(aMsg, suffix);
      33          12 :   }
      34             : 
      35          12 :   static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
      36             :   {
      37          24 :     nsAutoCString suffix;
      38          12 :     return ReadParam(aMsg, aIter, &suffix) &&
      39          24 :            aResult->PopulateFromSuffix(suffix);
      40             :   }
      41             : };
      42             : } // namespace detail
      43             : 
      44             : template<>
      45             : struct ParamTraits<mozilla::OriginAttributes>
      46             :   : public detail::OriginAttributesParamTraits<mozilla::OriginAttributes> {};
      47             : 
      48             : } // namespace IPC
      49             : 
      50             : namespace mozilla {
      51             : namespace net {
      52             : class OptionalLoadInfoArgs;
      53             : class RedirectHistoryEntryInfo;
      54             : } // namespace net
      55             : 
      56             : using namespace mozilla::net;
      57             : 
      58             : namespace ipc {
      59             : 
      60             : class PrincipalInfo;
      61             : 
      62             : /**
      63             :  * Convert a PrincipalInfo to an nsIPrincipal.
      64             :  *
      65             :  * MUST be called on the main thread only.
      66             :  */
      67             : already_AddRefed<nsIPrincipal>
      68             : PrincipalInfoToPrincipal(const PrincipalInfo& aPrincipalInfo,
      69             :                          nsresult* aOptionalResult = nullptr);
      70             : 
      71             : /**
      72             :  * Convert an nsIPrincipal to a PrincipalInfo.
      73             :  *
      74             :  * MUST be called on the main thread only.
      75             :  */
      76             : nsresult
      77             : PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
      78             :                          PrincipalInfo* aPrincipalInfo);
      79             : 
      80             : /**
      81             :  * Return true if this PrincipalInfo is a content principal and it has
      82             :  * a privateBrowsing id in its OriginAttributes
      83             :  */
      84             : bool
      85             : IsPincipalInfoPrivate(const PrincipalInfo& aPrincipalInfo);
      86             : 
      87             : /**
      88             :  * Convert an RedirectHistoryEntryInfo to a nsIRedirectHistoryEntry.
      89             :  */
      90             : 
      91             : already_AddRefed<nsIRedirectHistoryEntry>
      92             : RHEntryInfoToRHEntry(const RedirectHistoryEntryInfo& aRHEntryInfo);
      93             : 
      94             : /**
      95             :  * Convert an nsIRedirectHistoryEntry to a RedirectHistoryEntryInfo.
      96             :  */
      97             : 
      98             : nsresult
      99             : RHEntryToRHEntryInfo(nsIRedirectHistoryEntry* aRHEntry,
     100             :                      RedirectHistoryEntryInfo* aRHEntryInfo);
     101             : 
     102             : /**
     103             :  * Convert a LoadInfo to LoadInfoArgs struct.
     104             :  */
     105             : nsresult
     106             : LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
     107             :                        OptionalLoadInfoArgs* outOptionalLoadInfoArgs);
     108             : 
     109             : /**
     110             :  * Convert LoadInfoArgs to a LoadInfo.
     111             :  */
     112             : nsresult
     113             : LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
     114             :                        nsILoadInfo** outLoadInfo);
     115             : 
     116             : } // namespace ipc
     117             : } // namespace mozilla
     118             : 
     119             : #endif // mozilla_ipc_backgroundutils_h__

Generated by: LCOV version 1.13