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

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

Issue 16820007: Expose crypto.getRandomValues() to workers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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
Index: Source/modules/crypto/Crypto.cpp
diff --git a/Source/modules/crypto/Crypto.cpp b/Source/modules/crypto/Crypto.cpp
index a2e55daaa82295fd417022c3b1cbe7a6cb09e019..211d679fc6af2aa0807e77d0a26f1abd15a48abe 100644
--- a/Source/modules/crypto/Crypto.cpp
+++ b/Source/modules/crypto/Crypto.cpp
@@ -30,46 +30,13 @@
#include "config.h"
#include "modules/crypto/Crypto.h"
-#include "core/dom/ExceptionCode.h"
-#include "wtf/ArrayBufferView.h"
-#include "wtf/CryptographicallyRandomNumber.h"
-
namespace WebCore {
-namespace {
-
-bool isIntegerArray(ArrayBufferView* array)
-{
- ArrayBufferView::ViewType type = array->getType();
- return type == ArrayBufferView::TypeInt8
- || type == ArrayBufferView::TypeUint8
- || type == ArrayBufferView::TypeUint8Clamped
- || type == ArrayBufferView::TypeInt16
- || type == ArrayBufferView::TypeUint16
- || type == ArrayBufferView::TypeInt32
- || type == ArrayBufferView::TypeUint32;
-}
-
-}
-
Crypto::Crypto()
{
ScriptWrappable::init(this);
}
-void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec)
-{
- if (!array || !isIntegerArray(array)) {
- ec = TYPE_MISMATCH_ERR;
- return;
- }
- if (array->byteLength() > 65536) {
- ec = QUOTA_EXCEEDED_ERR;
- return;
- }
- cryptographicallyRandomValues(array->baseAddress(), array->byteLength());
-}
-
SubtleCrypto* Crypto::subtle()
{
if (!m_subtleCrypto)

Powered by Google App Engine
This is Rietveld 408576698