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

Unified Diff: Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp

Issue 44993003: [webcrypto] Make WebCryptoAlgorithm "nullable". (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 | « no previous file | Source/core/platform/chromium/support/WebCryptoKey.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp
diff --git a/Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp b/Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp
index 2a4805b71e33e327f66cadbe72c9958844190bbb..812548748f9c3a6b2fb69f85e362d216b3f17906 100644
--- a/Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp
+++ b/Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp
@@ -54,18 +54,30 @@ WebCryptoAlgorithm::WebCryptoAlgorithm(WebCryptoAlgorithmId id, PassOwnPtr<WebCr
{
}
+WebCryptoAlgorithm WebCryptoAlgorithm::createNull()
+{
+ return WebCryptoAlgorithm();
+}
+
WebCryptoAlgorithm WebCryptoAlgorithm::adoptParamsAndCreate(WebCryptoAlgorithmId id, WebCryptoAlgorithmParams* params)
{
return WebCryptoAlgorithm(id, adoptPtr(params));
}
+bool WebCryptoAlgorithm::isNull() const
+{
+ return m_private.isNull();
+}
+
WebCryptoAlgorithmId WebCryptoAlgorithm::id() const
{
+ ASSERT(!isNull());
return m_private->id;
}
WebCryptoAlgorithmParamsType WebCryptoAlgorithm::paramsType() const
{
+ ASSERT(!isNull());
if (!m_private->params)
return WebCryptoAlgorithmParamsTypeNone;
return m_private->params->type();
@@ -73,6 +85,7 @@ WebCryptoAlgorithmParamsType WebCryptoAlgorithm::paramsType() const
const WebCryptoAesCbcParams* WebCryptoAlgorithm::aesCbcParams() const
{
+ ASSERT(!isNull());
if (paramsType() == WebCryptoAlgorithmParamsTypeAesCbcParams)
return static_cast<WebCryptoAesCbcParams*>(m_private->params.get());
return 0;
@@ -80,6 +93,7 @@ const WebCryptoAesCbcParams* WebCryptoAlgorithm::aesCbcParams() const
const WebCryptoAesKeyGenParams* WebCryptoAlgorithm::aesKeyGenParams() const
{
+ ASSERT(!isNull());
if (paramsType() == WebCryptoAlgorithmParamsTypeAesKeyGenParams)
return static_cast<WebCryptoAesKeyGenParams*>(m_private->params.get());
return 0;
@@ -87,6 +101,7 @@ const WebCryptoAesKeyGenParams* WebCryptoAlgorithm::aesKeyGenParams() const
const WebCryptoHmacParams* WebCryptoAlgorithm::hmacParams() const
{
+ ASSERT(!isNull());
if (paramsType() == WebCryptoAlgorithmParamsTypeHmacParams)
return static_cast<WebCryptoHmacParams*>(m_private->params.get());
return 0;
@@ -94,6 +109,7 @@ const WebCryptoHmacParams* WebCryptoAlgorithm::hmacParams() const
const WebCryptoHmacKeyParams* WebCryptoAlgorithm::hmacKeyParams() const
{
+ ASSERT(!isNull());
if (paramsType() == WebCryptoAlgorithmParamsTypeHmacKeyParams)
return static_cast<WebCryptoHmacKeyParams*>(m_private->params.get());
return 0;
@@ -101,6 +117,7 @@ const WebCryptoHmacKeyParams* WebCryptoAlgorithm::hmacKeyParams() const
const WebCryptoRsaSsaParams* WebCryptoAlgorithm::rsaSsaParams() const
{
+ ASSERT(!isNull());
if (paramsType() == WebCryptoAlgorithmParamsTypeRsaSsaParams)
return static_cast<WebCryptoRsaSsaParams*>(m_private->params.get());
return 0;
@@ -108,6 +125,7 @@ const WebCryptoRsaSsaParams* WebCryptoAlgorithm::rsaSsaParams() const
const WebCryptoRsaKeyGenParams* WebCryptoAlgorithm::rsaKeyGenParams() const
{
+ ASSERT(!isNull());
if (paramsType() == WebCryptoAlgorithmParamsTypeRsaKeyGenParams)
return static_cast<WebCryptoRsaKeyGenParams*>(m_private->params.get());
return 0;
@@ -115,6 +133,7 @@ const WebCryptoRsaKeyGenParams* WebCryptoAlgorithm::rsaKeyGenParams() const
const WebCryptoAesGcmParams* WebCryptoAlgorithm::aesGcmParams() const
{
+ ASSERT(!isNull());
if (paramsType() == WebCryptoAlgorithmParamsTypeAesGcmParams)
return static_cast<WebCryptoAesGcmParams*>(m_private->params.get());
return 0;
@@ -122,6 +141,7 @@ const WebCryptoAesGcmParams* WebCryptoAlgorithm::aesGcmParams() const
const WebCryptoRsaOaepParams* WebCryptoAlgorithm::rsaOaepParams() const
{
+ ASSERT(!isNull());
if (paramsType() == WebCryptoAlgorithmParamsTypeRsaOaepParams)
return static_cast<WebCryptoRsaOaepParams*>(m_private->params.get());
return 0;
« no previous file with comments | « no previous file | Source/core/platform/chromium/support/WebCryptoKey.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698