Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1514)

Unified Diff: Source/modules/crypto/NormalizeAlgorithm.cpp

Issue 23503016: Cleanup: Remove the WebCryptoAlgorithm::name() attribute. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename get() --> instance() Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/crypto/NormalizeAlgorithm.h ('k') | public/platform/WebCryptoAlgorithm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 &registry.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
« no previous file with comments | « Source/modules/crypto/NormalizeAlgorithm.h ('k') | public/platform/WebCryptoAlgorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698