2017-10-27 01:08:41 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2015-09-11 17:01:20 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_WebCryptoThreadPool_h
|
|
|
|
#define mozilla_dom_WebCryptoThreadPool_h
|
|
|
|
|
2017-10-12 15:50:23 +03:00
|
|
|
#include "mozilla/Mutex.h"
|
|
|
|
#include "nsIObserver.h"
|
2015-09-11 17:01:20 +03:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIThreadPool.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class WebCryptoThreadPool final : nsIObserver {
|
|
|
|
public:
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
|
|
|
|
static void
|
|
|
|
Initialize();
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
Dispatch(nsIRunnable* aRunnable);
|
|
|
|
|
|
|
|
private:
|
|
|
|
WebCryptoThreadPool()
|
|
|
|
: mMutex("WebCryptoThreadPool::mMutex")
|
|
|
|
, mPool(nullptr)
|
2018-06-29 01:34:40 +03:00
|
|
|
, mShutdown(false)
|
2015-09-11 17:01:20 +03:00
|
|
|
{ }
|
|
|
|
virtual ~WebCryptoThreadPool()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
Init();
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
DispatchInternal(nsIRunnable* aRunnable);
|
|
|
|
|
|
|
|
void
|
|
|
|
Shutdown();
|
|
|
|
|
2016-08-08 03:54:47 +03:00
|
|
|
NS_IMETHOD Observe(nsISupports* aSubject,
|
|
|
|
const char* aTopic,
|
|
|
|
const char16_t* aData) override;
|
2015-09-11 17:01:20 +03:00
|
|
|
|
|
|
|
mozilla::Mutex mMutex;
|
|
|
|
nsCOMPtr<nsIThreadPool> mPool;
|
2018-06-29 01:34:40 +03:00
|
|
|
bool mShutdown;
|
2015-09-11 17:01:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_WebCryptoThreadPool_h
|