CryptoAlgorithmRegistry.h [plain text]
#ifndef CryptoAlgorithmRegistry_h
#define CryptoAlgorithmRegistry_h
#include "CryptoAlgorithmIdentifier.h"
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/text/StringHash.h>
#if ENABLE(SUBTLE_CRYPTO)
namespace WebCore {
typedef int ExceptionCode;
class CryptoAlgorithm;
class CryptoAlgorithmRegistry {
WTF_MAKE_NONCOPYABLE(CryptoAlgorithmRegistry);
friend class NeverDestroyed<CryptoAlgorithmRegistry>;
public:
static CryptoAlgorithmRegistry& singleton();
bool getIdentifierForName(const String&, CryptoAlgorithmIdentifier&);
String nameForIdentifier(CryptoAlgorithmIdentifier);
std::unique_ptr<CryptoAlgorithm> create(CryptoAlgorithmIdentifier);
private:
CryptoAlgorithmRegistry();
void platformRegisterAlgorithms();
typedef std::unique_ptr<CryptoAlgorithm> (*CryptoAlgorithmConstructor)();
template<typename AlgorithmClass> void registerAlgorithm()
{
registerAlgorithm(AlgorithmClass::s_name, AlgorithmClass::s_identifier, AlgorithmClass::create);
}
void registerAlgorithm(const String& name, CryptoAlgorithmIdentifier, CryptoAlgorithmConstructor);
HashMap<String, CryptoAlgorithmIdentifier, CaseFoldingHash> m_nameToIdentifierMap;
HashMap<unsigned, String> m_identifierToNameMap;
HashMap<unsigned, CryptoAlgorithmConstructor> m_identifierToConstructorMap;
};
}
#endif // ENABLE(SUBTLE_CRYPTO)
#endif // CryptoAlgorithmRegistry_h