Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/cache/nsCacheUtils.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 _nsCacheUtils_h_
8
#define _nsCacheUtils_h_
9
10
#include "nsThreadUtils.h"
11
#include "nsCOMPtr.h"
12
#include "mozilla/Monitor.h"
13
14
class nsIThread;
15
16
/**
17
 * A class with utility methods for shutting down nsIThreads easily.
18
  */
19
class nsShutdownThread : public mozilla::Runnable {
20
public:
21
  explicit nsShutdownThread(nsIThread *aThread);
22
0
  ~nsShutdownThread() = default;
23
24
  NS_IMETHOD Run() override;
25
26
/**
27
 * Shutdown ensures that aThread->Shutdown() is called on a main thread
28
 */
29
  static nsresult Shutdown(nsIThread *aThread);
30
31
/**
32
 * BlockingShutdown ensures that by the time it returns, aThread->Shutdown() has
33
 * been called and no pending events have been processed on the current thread.
34
 */
35
  static nsresult BlockingShutdown(nsIThread *aThread);
36
37
private:
38
  mozilla::Monitor    mMonitor;
39
  bool                mShuttingDown;
40
  nsCOMPtr<nsIThread> mThread;
41
};
42
43
#endif