Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/PermissionMessageUtils.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
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef mozilla_dom_permission_message_utils_h__
8
#define mozilla_dom_permission_message_utils_h__
9
10
#include "ipc/IPCMessageUtils.h"
11
#include "nsCOMPtr.h"
12
#include "nsIPrincipal.h"
13
14
namespace IPC {
15
16
template<>
17
struct ParamTraits<nsIPrincipal>
18
{
19
  static void Write(Message* aMsg, nsIPrincipal* aParam);
20
  static bool Read(const Message* aMsg, PickleIterator* aIter, RefPtr<nsIPrincipal>* aResult);
21
};
22
23
/**
24
 * Legacy IPC::Principal type. Use nsIPrincipal directly in new IPDL code.
25
 */
26
class Principal
27
{
28
  friend struct ParamTraits<Principal>;
29
30
public:
31
  Principal()
32
    : mPrincipal(nullptr)
33
0
  {}
34
35
  explicit Principal(nsIPrincipal* aPrincipal)
36
    : mPrincipal(aPrincipal)
37
0
  {}
38
39
0
  operator nsIPrincipal*() const { return mPrincipal.get(); }
40
41
  Principal& operator=(const Principal& aOther)
42
0
  {
43
0
    mPrincipal = aOther.mPrincipal;
44
0
    return *this;
45
0
  }
46
47
private:
48
  RefPtr<nsIPrincipal> mPrincipal;
49
};
50
51
template <>
52
struct ParamTraits<Principal>
53
{
54
  typedef Principal paramType;
55
  static void Write(Message* aMsg, const paramType& aParam)
56
0
  {
57
0
    WriteParam(aMsg, aParam.mPrincipal);
58
0
  }
59
  static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
60
0
  {
61
0
    return ReadParam(aMsg, aIter, &aResult->mPrincipal);
62
0
  }
63
};
64
65
} // namespace IPC
66
67
#endif // mozilla_dom_permission_message_utils_h__
68