Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/xpcom/base/nsMemoryImpl.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 nsMemoryImpl_h__
8
#define nsMemoryImpl_h__
9
10
#include "mozilla/Atomics.h"
11
12
#include "nsIMemory.h"
13
#include "nsIRunnable.h"
14
15
// nsMemoryImpl is a static object. We can do this because it doesn't have
16
// a constructor/destructor or any instance members. Please don't add
17
// instance member variables, only static member variables.
18
19
class nsMemoryImpl : public nsIMemory
20
{
21
public:
22
  // We don't use the generic macros because we are a special static object
23
  NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult) override;
24
  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override
25
0
  {
26
0
    return 1;
27
0
  }
28
  NS_IMETHOD_(MozExternalRefCountType) Release(void) override
29
0
  {
30
0
    return 1;
31
0
  }
32
33
  NS_DECL_NSIMEMORY
34
35
  static nsresult Create(nsISupports* aOuter,
36
                         const nsIID& aIID, void** aResult);
37
38
  nsresult FlushMemory(const char16_t* aReason, bool aImmediate);
39
  nsresult RunFlushers(const char16_t* aReason);
40
41
protected:
42
  struct FlushEvent : public nsIRunnable
43
  {
44
0
    constexpr FlushEvent() : mReason(nullptr) {}
45
    NS_DECL_ISUPPORTS_INHERITED
46
    NS_DECL_NSIRUNNABLE
47
    const char16_t* mReason;
48
  };
49
50
  static mozilla::Atomic<bool> sIsFlushing;
51
  static FlushEvent sFlushEvent;
52
  static PRIntervalTime sLastFlushTime;
53
};
54
55
#endif // nsMemoryImpl_h__