Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/nsServiceManagerUtils.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 nsServiceManagerUtils_h__
8
#define nsServiceManagerUtils_h__
9
10
#include "nsIServiceManager.h"
11
#include "nsCOMPtr.h"
12
#include "nsString.h"
13
14
inline const nsGetServiceByCID
15
do_GetService(const nsCID& aCID)
16
6
{
17
6
  return nsGetServiceByCID(aCID);
18
6
}
19
20
inline const nsGetServiceByCIDWithError
21
do_GetService(const nsCID& aCID, nsresult* aError)
22
0
{
23
0
  return nsGetServiceByCIDWithError(aCID, aError);
24
0
}
25
26
inline const nsGetServiceByContractID
27
do_GetService(const char* aContractID)
28
9.59k
{
29
9.59k
  return nsGetServiceByContractID(aContractID);
30
9.59k
}
31
32
inline const nsGetServiceByContractIDWithError
33
do_GetService(const char* aContractID, nsresult* aError)
34
58
{
35
58
  return nsGetServiceByContractIDWithError(aContractID, aError);
36
58
}
37
38
class MOZ_STACK_CLASS nsGetServiceFromCategory final : public nsCOMPtr_helper
39
{
40
public:
41
  nsGetServiceFromCategory(const nsACString& aCategory, const nsACString& aEntry,
42
                           nsresult* aErrorPtr)
43
    : mCategory(aCategory)
44
    , mEntry(aEntry)
45
    , mErrorPtr(aErrorPtr)
46
  {
47
  }
48
49
  virtual nsresult NS_FASTCALL operator()(const nsIID&, void**) const
50
    override;
51
protected:
52
  const nsCString             mCategory;
53
  const nsCString             mEntry;
54
  nsresult*                   mErrorPtr;
55
};
56
57
inline const nsGetServiceFromCategory
58
do_GetServiceFromCategory(const nsACString& aCategory, const nsACString& aEntry,
59
                          nsresult* aError = 0)
60
{
61
  return nsGetServiceFromCategory(aCategory, aEntry, aError);
62
}
63
64
nsresult CallGetService(const nsCID& aClass, const nsIID& aIID, void** aResult);
65
66
nsresult CallGetService(const char* aContractID, const nsIID& aIID,
67
                        void** aResult);
68
69
// type-safe shortcuts for calling |GetService|
70
template<class DestinationType>
71
inline nsresult
72
CallGetService(const nsCID& aClass,
73
               DestinationType** aDestination)
74
3
{
75
3
  MOZ_ASSERT(aDestination, "null parameter");
76
3
77
3
  return CallGetService(aClass,
78
3
                        NS_GET_TEMPLATE_IID(DestinationType),
79
3
                        reinterpret_cast<void**>(aDestination));
80
3
}
nsresult CallGetService<nsIDNSService>(nsID const&, nsIDNSService**)
Line
Count
Source
74
3
{
75
3
  MOZ_ASSERT(aDestination, "null parameter");
76
3
77
3
  return CallGetService(aClass,
78
3
                        NS_GET_TEMPLATE_IID(DestinationType),
79
3
                        reinterpret_cast<void**>(aDestination));
80
3
}
Unexecuted instantiation: nsresult CallGetService<nsITestService>(nsID const&, nsITestService**)
81
82
template<class DestinationType>
83
inline nsresult
84
CallGetService(const char* aContractID,
85
               DestinationType** aDestination)
86
2.51M
{
87
2.51M
  MOZ_ASSERT(aContractID, "null parameter");
88
2.51M
  MOZ_ASSERT(aDestination, "null parameter");
89
2.51M
90
2.51M
  return CallGetService(aContractID,
91
2.51M
                        NS_GET_TEMPLATE_IID(DestinationType),
92
2.51M
                        reinterpret_cast<void**>(aDestination));
93
2.51M
}
nsresult CallGetService<nsIProtocolHandler>(char const*, nsIProtocolHandler**)
Line
Count
Source
86
2.50M
{
87
2.50M
  MOZ_ASSERT(aContractID, "null parameter");
88
2.50M
  MOZ_ASSERT(aDestination, "null parameter");
89
2.50M
90
2.50M
  return CallGetService(aContractID,
91
2.50M
                        NS_GET_TEMPLATE_IID(DestinationType),
92
2.50M
                        reinterpret_cast<void**>(aDestination));
93
2.50M
}
nsresult CallGetService<nsIPrefBranch>(char const*, nsIPrefBranch**)
Line
Count
Source
86
3
{
87
3
  MOZ_ASSERT(aContractID, "null parameter");
88
3
  MOZ_ASSERT(aDestination, "null parameter");
89
3
90
3
  return CallGetService(aContractID,
91
3
                        NS_GET_TEMPLATE_IID(DestinationType),
92
3
                        reinterpret_cast<void**>(aDestination));
93
3
}
Unexecuted instantiation: nsresult CallGetService<nsISocketProvider>(char const*, nsISocketProvider**)
Unexecuted instantiation: nsresult CallGetService<nsITextToSubURI>(char const*, nsITextToSubURI**)
nsresult CallGetService<nsIAboutModule>(char const*, nsIAboutModule**)
Line
Count
Source
86
4.09k
{
87
4.09k
  MOZ_ASSERT(aContractID, "null parameter");
88
4.09k
  MOZ_ASSERT(aDestination, "null parameter");
89
4.09k
90
4.09k
  return CallGetService(aContractID,
91
4.09k
                        NS_GET_TEMPLATE_IID(DestinationType),
92
4.09k
                        reinterpret_cast<void**>(aDestination));
93
4.09k
}
Unexecuted instantiation: nsresult CallGetService<nsIHttpAuthenticator>(char const*, nsIHttpAuthenticator**)
nsresult CallGetService<nsIIOService>(char const*, nsIIOService**)
Line
Count
Source
86
6
{
87
6
  MOZ_ASSERT(aContractID, "null parameter");
88
6
  MOZ_ASSERT(aDestination, "null parameter");
89
6
90
6
  return CallGetService(aContractID,
91
6
                        NS_GET_TEMPLATE_IID(DestinationType),
92
6
                        reinterpret_cast<void**>(aDestination));
93
6
}
Unexecuted instantiation: nsresult CallGetService<nsIStringBundleService>(char const*, nsIStringBundleService**)
Unexecuted instantiation: nsresult CallGetService<nsIConsoleService>(char const*, nsIConsoleService**)
nsresult CallGetService<nsIContentPolicy>(char const*, nsIContentPolicy**)
Line
Count
Source
86
1
{
87
1
  MOZ_ASSERT(aContractID, "null parameter");
88
1
  MOZ_ASSERT(aDestination, "null parameter");
89
1
90
1
  return CallGetService(aContractID,
91
1
                        NS_GET_TEMPLATE_IID(DestinationType),
92
1
                        reinterpret_cast<void**>(aDestination));
93
1
}
Unexecuted instantiation: nsresult CallGetService<nsIURIFixup>(char const*, nsIURIFixup**)
Unexecuted instantiation: nsresult CallGetService<nsIUrlClassifierHashCompleter>(char const*, nsIUrlClassifierHashCompleter**)
Unexecuted instantiation: nsresult CallGetService<nsITestService>(char const*, nsITestService**)
94
95
#endif