Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/WebCryptoThreadPool.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 mozilla_dom_WebCryptoThreadPool_h
8
#define mozilla_dom_WebCryptoThreadPool_h
9
10
#include "mozilla/Mutex.h"
11
#include "nsIObserver.h"
12
#include "nsIObserverService.h"
13
#include "nsIThreadPool.h"
14
15
namespace mozilla {
16
namespace dom {
17
18
class WebCryptoThreadPool final : nsIObserver {
19
public:
20
  NS_DECL_THREADSAFE_ISUPPORTS
21
22
  static void
23
  Initialize();
24
25
  static nsresult
26
  Dispatch(nsIRunnable* aRunnable);
27
28
private:
29
  WebCryptoThreadPool()
30
    : mMutex("WebCryptoThreadPool::mMutex")
31
    , mPool(nullptr)
32
    , mShutdown(false)
33
3
  { }
34
  virtual ~WebCryptoThreadPool()
35
0
  { }
36
37
  nsresult
38
  Init();
39
40
  nsresult
41
  DispatchInternal(nsIRunnable* aRunnable);
42
43
  void
44
  Shutdown();
45
46
  NS_IMETHOD Observe(nsISupports* aSubject,
47
                     const char* aTopic,
48
                     const char16_t* aData) override;
49
50
  mozilla::Mutex mMutex;
51
  nsCOMPtr<nsIThreadPool> mPool;
52
  bool mShutdown;
53
};
54
55
} // namespace dom
56
} // namespace mozilla
57
58
#endif // mozilla_dom_WebCryptoThreadPool_h