Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/nsWeakReference.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 nsWeakReference_h__
8
#define nsWeakReference_h__
9
10
// nsWeakReference.h
11
12
// See mfbt/WeakPtr.h for a more typesafe C++ implementation of weak references
13
14
#include "nsIWeakReferenceUtils.h"
15
16
class nsWeakReference;
17
18
class nsSupportsWeakReference : public nsISupportsWeakReference
19
{
20
public:
21
  nsSupportsWeakReference() : mProxy(0) {}
22
23
  NS_DECL_NSISUPPORTSWEAKREFERENCE
24
25
protected:
26
  inline ~nsSupportsWeakReference();
27
28
private:
29
  friend class nsWeakReference;
30
31
  // Called (only) by an |nsWeakReference| from _its_ dtor.
32
  // The thread safety check is made by the caller.
33
0
  void NoticeProxyDestruction() { mProxy = nullptr; }
34
35
  nsWeakReference* MOZ_NON_OWNING_REF mProxy;
36
37
protected:
38
39
  void ClearWeakReferences();
40
0
  bool HasWeakReferences() const { return !!mProxy; }
41
};
42
43
inline
44
nsSupportsWeakReference::~nsSupportsWeakReference()
45
{
46
  ClearWeakReferences();
47
}
48
49
#endif