| Index: Source/modules/crypto/NormalizeAlgorithm.cpp
|
| diff --git a/Source/modules/crypto/NormalizeAlgorithm.cpp b/Source/modules/crypto/NormalizeAlgorithm.cpp
|
| index c53c7c66b99d8e9c4a4e05200467323e32ae0a26..3563c19a47ce4db770fec953a28695b557686e60 100644
|
| --- a/Source/modules/crypto/NormalizeAlgorithm.cpp
|
| +++ b/Source/modules/crypto/NormalizeAlgorithm.cpp
|
| @@ -124,7 +124,10 @@ struct AlgorithmInfo {
|
| // but in a more convenient runtime form.
|
| class AlgorithmRegistry {
|
| public:
|
| - static const AlgorithmInfo* lookupAlgorithmByName(const String& algorithmName);
|
| + static AlgorithmRegistry& instance();
|
| +
|
| + const AlgorithmInfo* lookupAlgorithmByName(const String&) const;
|
| + const AlgorithmInfo* lookupAlgorithmById(WebKit::WebCryptoAlgorithmId) const;
|
|
|
| private:
|
| AlgorithmRegistry();
|
| @@ -137,14 +140,24 @@ private:
|
| AlgorithmInfo m_algorithms[WebKit::NumberOfWebCryptoAlgorithmId];
|
| };
|
|
|
| -const AlgorithmInfo* AlgorithmRegistry::lookupAlgorithmByName(const String& algorithmName)
|
| +AlgorithmRegistry& AlgorithmRegistry::instance()
|
| {
|
| DEFINE_STATIC_LOCAL(AlgorithmRegistry, registry, ());
|
| + return registry;
|
| +}
|
|
|
| - AlgorithmNameToIdMap::const_iterator it = registry.m_algorithmNameToId.find(algorithmName);
|
| - if (it == registry.m_algorithmNameToId.end())
|
| +const AlgorithmInfo* AlgorithmRegistry::lookupAlgorithmByName(const String& algorithmName) const
|
| +{
|
| + AlgorithmNameToIdMap::const_iterator it = m_algorithmNameToId.find(algorithmName);
|
| + if (it == m_algorithmNameToId.end())
|
| return 0;
|
| - return ®istry.m_algorithms[it->value];
|
| + return lookupAlgorithmById(it->value);
|
| +}
|
| +
|
| +const AlgorithmInfo* AlgorithmRegistry::lookupAlgorithmById(WebKit::WebCryptoAlgorithmId algorithmId) const
|
| +{
|
| + ASSERT(algorithmId >= 0 && algorithmId < WTF_ARRAY_LENGTH(m_algorithms));
|
| + return &m_algorithms[algorithmId];
|
| }
|
|
|
| AlgorithmRegistry::AlgorithmRegistry()
|
| @@ -431,7 +444,7 @@ const AlgorithmInfo* algorithmInfo(const Dictionary& raw, const ExceptionContext
|
| return 0;
|
| }
|
|
|
| - const AlgorithmInfo* info = AlgorithmRegistry::lookupAlgorithmByName(algorithmName);
|
| + const AlgorithmInfo* info = AlgorithmRegistry::instance().lookupAlgorithmByName(algorithmName);
|
| if (!info) {
|
| es.throwDOMException(NotSupportedError, context.toString("Unrecognized algorithm name"));
|
| return 0;
|
| @@ -462,7 +475,7 @@ bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, WebKit::We
|
| if (!parseAlgorithmParams(raw, paramsType, params, context, es))
|
| return false;
|
|
|
| - algorithm = WebKit::WebCryptoAlgorithm(info->algorithmId, info->algorithmName, params.release());
|
| + algorithm = WebKit::WebCryptoAlgorithm(info->algorithmId, params.release());
|
| return true;
|
| }
|
|
|
| @@ -473,4 +486,9 @@ bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, WebKit::We
|
| return normalizeAlgorithm(raw, op, algorithm, ExceptionContext(), es);
|
| }
|
|
|
| +const char* algorithmIdToName(WebKit::WebCryptoAlgorithmId id)
|
| +{
|
| + return AlgorithmRegistry::instance().lookupAlgorithmById(id)->algorithmName;
|
| +}
|
| +
|
| } // namespace WebCore
|
|
|