Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/net/ChildDNSService.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 sw=2 ts=8 et 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_net_ChildDNSService_h
8
#define mozilla_net_ChildDNSService_h
9
10
11
#include "nsPIDNSService.h"
12
#include "nsIObserver.h"
13
#include "mozilla/Attributes.h"
14
#include "mozilla/Mutex.h"
15
#include "DNSRequestChild.h"
16
#include "nsHashKeys.h"
17
#include "nsClassHashtable.h"
18
19
namespace mozilla {
20
namespace net {
21
22
class ChildDNSService final
23
  : public nsPIDNSService
24
  , public nsIObserver
25
{
26
public:
27
  // AsyncResolve (and CancelAsyncResolve) can be called off-main
28
  NS_DECL_THREADSAFE_ISUPPORTS
29
  NS_DECL_NSPIDNSSERVICE
30
  NS_DECL_NSIDNSSERVICE
31
  NS_DECL_NSIOBSERVER
32
33
  ChildDNSService();
34
35
  static already_AddRefed<ChildDNSService> GetSingleton();
36
37
  void NotifyRequestDone(DNSRequestChild *aDnsRequest);
38
39
  bool GetOffline() const;
40
private:
41
0
  virtual ~ChildDNSService() = default;
42
43
  void MOZ_ALWAYS_INLINE GetDNSRecordHashKey(const nsACString &aHost,
44
                                             uint16_t aType,
45
                                             const OriginAttributes &aOriginAttributes,
46
                                             uint32_t aFlags,
47
                                             nsIDNSListener* aListener,
48
                                             nsACString &aHashKey);
49
  nsresult AsyncResolveInternal(const nsACString        &hostname,
50
                                uint16_t                 type,
51
                                uint32_t                 flags,
52
                                nsIDNSListener          *listener,
53
                                nsIEventTarget          *target_,
54
                                const OriginAttributes  &aOriginAttributes,
55
                                nsICancelable          **result);
56
  nsresult CancelAsyncResolveInternal(const nsACString       &aHostname,
57
                                      uint16_t                aType,
58
                                      uint32_t                aFlags,
59
                                      nsIDNSListener         *aListener,
60
                                      nsresult                aReason,
61
                                      const OriginAttributes &aOriginAttributes);
62
63
  bool mFirstTime;
64
  bool mDisablePrefetch;
65
66
  // We need to remember pending dns requests to be able to cancel them.
67
  nsClassHashtable<nsCStringHashKey, nsTArray<RefPtr<DNSRequestChild>>> mPendingRequests;
68
  Mutex mPendingRequestsLock;
69
};
70
71
} // namespace net
72
} // namespace mozilla
73
74
#endif // mozilla_net_ChildDNSService_h