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

Unified Diff: Source/modules/crypto/RandomSource.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/RandomSource.cpp
diff --git a/Source/modules/crypto/Crypto.cpp b/Source/modules/crypto/RandomSource.cpp
similarity index 88%
copy from Source/modules/crypto/Crypto.cpp
copy to Source/modules/crypto/RandomSource.cpp
index a2e55daaa82295fd417022c3b1cbe7a6cb09e019..cdab398134a57ede5cd3b7ca1969088d788862ca 100644
--- a/Source/modules/crypto/Crypto.cpp
+++ b/Source/modules/crypto/RandomSource.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,7 +28,7 @@
#include "config.h"
-#include "modules/crypto/Crypto.h"
+#include "modules/crypto/RandomSource.h"
#include "core/dom/ExceptionCode.h"
#include "wtf/ArrayBufferView.h"
@@ -52,12 +52,13 @@ bool isIntegerArray(ArrayBufferView* array)
}
-Crypto::Crypto()
+RandomSource::RandomSource()
{
ScriptWrappable::init(this);
}
-void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec)
+// Note: This implementation MUST be thread-safe, as it is used by workers.
+void RandomSource::getRandomValues(ArrayBufferView* array, ExceptionCode& ec)
{
if (!array || !isIntegerArray(array)) {
ec = TYPE_MISMATCH_ERR;
@@ -70,11 +71,4 @@ void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec)
cryptographicallyRandomValues(array->baseAddress(), array->byteLength());
}
-SubtleCrypto* Crypto::subtle()
-{
- if (!m_subtleCrypto)
- m_subtleCrypto = SubtleCrypto::create();
- return m_subtleCrypto.get();
-}
-
}

Powered by Google App Engine
This is Rietveld 408576698