Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
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 "nsIObserverService.h"
11 : #include "nsIThreadPool.h"
12 :
13 : namespace mozilla {
14 : namespace dom {
15 :
16 : class WebCryptoThreadPool final : nsIObserver {
17 : public:
18 : NS_DECL_THREADSAFE_ISUPPORTS
19 :
20 : static void
21 : Initialize();
22 :
23 : static nsresult
24 : Dispatch(nsIRunnable* aRunnable);
25 :
26 : private:
27 3 : WebCryptoThreadPool()
28 3 : : mMutex("WebCryptoThreadPool::mMutex")
29 3 : , mPool(nullptr)
30 3 : { }
31 0 : virtual ~WebCryptoThreadPool()
32 0 : { }
33 :
34 : nsresult
35 : Init();
36 :
37 : nsresult
38 : DispatchInternal(nsIRunnable* aRunnable);
39 :
40 : void
41 : Shutdown();
42 :
43 : NS_IMETHOD Observe(nsISupports* aSubject,
44 : const char* aTopic,
45 : const char16_t* aData) override;
46 :
47 : mozilla::Mutex mMutex;
48 : nsCOMPtr<nsIThreadPool> mPool;
49 : };
50 :
51 : } // namespace dom
52 : } // namespace mozilla
53 :
54 : #endif // mozilla_dom_WebCryptoThreadPool_h
|