Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/ipc/BackgroundUtils.h
Line
Count
Source (jump to first uncovered line)
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
  static void Write(Message* aMsg, const paramType& aParam)
29
0
  {
30
0
    nsAutoCString suffix;
31
0
    aParam.CreateSuffix(suffix);
32
0
    WriteParam(aMsg, suffix);
33
0
  }
34
35
  static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
36
0
  {
37
0
    nsAutoCString suffix;
38
0
    return ReadParam(aMsg, aIter, &suffix) &&
39
0
           aResult->PopulateFromSuffix(suffix);
40
0
  }
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 ChildLoadInfoForwarderArgs;
53
class OptionalLoadInfoArgs;
54
class ParentLoadInfoForwarderArgs;
55
class RedirectHistoryEntryInfo;
56
} // namespace 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 mozilla::net::RedirectHistoryEntryInfo& aRHEntryInfo);
93
94
/**
95
 * Convert an nsIRedirectHistoryEntry to a RedirectHistoryEntryInfo.
96
 */
97
98
nsresult
99
RHEntryToRHEntryInfo(nsIRedirectHistoryEntry* aRHEntry,
100
                     mozilla::net::RedirectHistoryEntryInfo* aRHEntryInfo);
101
102
/**
103
 * Convert a LoadInfo to LoadInfoArgs struct.
104
 */
105
nsresult
106
LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
107
                       mozilla::net::OptionalLoadInfoArgs* outOptionalLoadInfoArgs);
108
109
/**
110
 * Convert LoadInfoArgs to a LoadInfo.
111
 */
112
nsresult
113
LoadInfoArgsToLoadInfo(const mozilla::net::OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
114
                       nsILoadInfo** outLoadInfo);
115
116
/**
117
 * Fills ParentLoadInfoForwarderArgs with properties we want to carry to child processes.
118
 */
119
void
120
LoadInfoToParentLoadInfoForwarder(nsILoadInfo *aLoadInfo,
121
                                  mozilla::net::ParentLoadInfoForwarderArgs* aForwarderArgsOut);
122
123
/**
124
 * Merges (replaces) properties of an existing LoadInfo on a child process
125
 * with properties carried down through ParentLoadInfoForwarderArgs.
126
 */
127
nsresult
128
MergeParentLoadInfoForwarder(mozilla::net::ParentLoadInfoForwarderArgs const& aForwarderArgs,
129
                             nsILoadInfo *aLoadInfo);
130
131
/**
132
 * Fills ChildLoadInfoForwarderArgs with properties we want to carry to the
133
 * parent process after the initial channel creation.
134
 */
135
void
136
LoadInfoToChildLoadInfoForwarder(nsILoadInfo* aLoadInfo,
137
                                 mozilla::net::ChildLoadInfoForwarderArgs* aForwarderArgsOut);
138
139
/**
140
 * Merges (replaces) properties of an existing LoadInfo on the parent process
141
 * with properties contained in a ChildLoadInfoForwarderArgs.
142
 */
143
nsresult
144
MergeChildLoadInfoForwarder(const mozilla::net::ChildLoadInfoForwarderArgs& aForwardArgs,
145
                            nsILoadInfo* aLoadInfo);
146
147
} // namespace ipc
148
} // namespace mozilla
149
150
#endif // mozilla_ipc_backgroundutils_h__