#include "bindings/core/v8/SerializedScriptValue.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/V8ArrayBuffer.h"
+#include "bindings/core/v8/V8ArrayBufferView.h"
#include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8Blob.h"
+#include "bindings/core/v8/V8DataView.h"
#include "bindings/core/v8/V8File.h"
#include "bindings/core/v8/V8FileList.h"
+#include "bindings/core/v8/V8Float32Array.h"
+#include "bindings/core/v8/V8Float64Array.h"
#include "bindings/core/v8/V8ImageData.h"
+#include "bindings/core/v8/V8Int16Array.h"
+#include "bindings/core/v8/V8Int32Array.h"
+#include "bindings/core/v8/V8Int8Array.h"
#include "bindings/core/v8/V8MessagePort.h"
+#include "bindings/core/v8/V8Uint16Array.h"
+#include "bindings/core/v8/V8Uint32Array.h"
+#include "bindings/core/v8/V8Uint8Array.h"
+#include "bindings/core/v8/V8Uint8ClampedArray.h"
#include "bindings/core/v8/WorkerScriptController.h"
-#include "bindings/core/v8/custom/V8ArrayBufferCustom.h"
-#include "bindings/core/v8/custom/V8ArrayBufferViewCustom.h"
-#include "bindings/core/v8/custom/V8DataViewCustom.h"
-#include "bindings/core/v8/custom/V8Float32ArrayCustom.h"
-#include "bindings/core/v8/custom/V8Float64ArrayCustom.h"
-#include "bindings/core/v8/custom/V8Int16ArrayCustom.h"
-#include "bindings/core/v8/custom/V8Int32ArrayCustom.h"
-#include "bindings/core/v8/custom/V8Int8ArrayCustom.h"
-#include "bindings/core/v8/custom/V8Uint16ArrayCustom.h"
-#include "bindings/core/v8/custom/V8Uint32ArrayCustom.h"
-#include "bindings/core/v8/custom/V8Uint8ArrayCustom.h"
-#include "bindings/core/v8/custom/V8Uint8ClampedArrayCustom.h"
#include "bindings/modules/v8/V8CryptoKey.h"
#include "bindings/modules/v8/V8DOMFileSystem.h"
#include "core/dom/ExceptionCode.h"
RsaOaepTag = 10,
AesCtrTag = 11,
AesKwTag = 12,
+ RsaPssTag = 13,
// Maximum allowed value is 2^32-1
};
doWriteUint32(blobIndices[i]);
}
- bool writeCryptoKey(const blink::WebCryptoKey& key)
+ bool writeCryptoKey(const WebCryptoKey& key)
{
append(static_cast<uint8_t>(CryptoKeyTag));
switch (key.algorithm().paramsType()) {
- case blink::WebCryptoKeyAlgorithmParamsTypeAes:
+ case WebCryptoKeyAlgorithmParamsTypeAes:
doWriteAesKey(key);
break;
- case blink::WebCryptoKeyAlgorithmParamsTypeHmac:
+ case WebCryptoKeyAlgorithmParamsTypeHmac:
doWriteHmacKey(key);
break;
- case blink::WebCryptoKeyAlgorithmParamsTypeRsaHashed:
+ case WebCryptoKeyAlgorithmParamsTypeRsaHashed:
doWriteRsaHashedKey(key);
break;
- case blink::WebCryptoKeyAlgorithmParamsTypeNone:
+ case WebCryptoKeyAlgorithmParamsTypeNone:
ASSERT_NOT_REACHED();
return false;
}
doWriteKeyUsages(key.usages(), key.extractable());
- blink::WebVector<uint8_t> keyData;
- if (!blink::Platform::current()->crypto()->serializeKeyForClone(key, keyData))
+ WebVector<uint8_t> keyData;
+ if (!Platform::current()->crypto()->serializeKeyForClone(key, keyData))
return false;
doWriteUint32(keyData.size());
doWriteString(stringUTF8.data(), stringUTF8.length());
}
- void doWriteHmacKey(const blink::WebCryptoKey& key)
+ void doWriteHmacKey(const WebCryptoKey& key)
{
- ASSERT(key.algorithm().paramsType() == blink::WebCryptoKeyAlgorithmParamsTypeHmac);
+ ASSERT(key.algorithm().paramsType() == WebCryptoKeyAlgorithmParamsTypeHmac);
append(static_cast<uint8_t>(HmacKeyTag));
ASSERT(!(key.algorithm().hmacParams()->lengthBits() % 8));
doWriteAlgorithmId(key.algorithm().hmacParams()->hash().id());
}
- void doWriteAesKey(const blink::WebCryptoKey& key)
+ void doWriteAesKey(const WebCryptoKey& key)
{
- ASSERT(key.algorithm().paramsType() == blink::WebCryptoKeyAlgorithmParamsTypeAes);
+ ASSERT(key.algorithm().paramsType() == WebCryptoKeyAlgorithmParamsTypeAes);
append(static_cast<uint8_t>(AesKeyTag));
doWriteAlgorithmId(key.algorithm().id());
doWriteUint32(key.algorithm().aesParams()->lengthBits() / 8);
}
- void doWriteRsaHashedKey(const blink::WebCryptoKey& key)
+ void doWriteRsaHashedKey(const WebCryptoKey& key)
{
ASSERT(key.algorithm().rsaHashedParams());
append(static_cast<uint8_t>(RsaHashedKeyTag));
doWriteAlgorithmId(key.algorithm().id());
switch (key.type()) {
- case blink::WebCryptoKeyTypePublic:
+ case WebCryptoKeyTypePublic:
doWriteUint32(PublicKeyType);
break;
- case blink::WebCryptoKeyTypePrivate:
+ case WebCryptoKeyTypePrivate:
doWriteUint32(PrivateKeyType);
break;
- case blink::WebCryptoKeyTypeSecret:
+ case WebCryptoKeyTypeSecret:
ASSERT_NOT_REACHED();
}
- const blink::WebCryptoRsaHashedKeyAlgorithmParams* params = key.algorithm().rsaHashedParams();
+ const WebCryptoRsaHashedKeyAlgorithmParams* params = key.algorithm().rsaHashedParams();
doWriteUint32(params->modulusLengthBits());
doWriteUint32(params->publicExponent().size());
append(params->publicExponent().data(), params->publicExponent().size());
doWriteAlgorithmId(key.algorithm().rsaHashedParams()->hash().id());
}
- void doWriteAlgorithmId(blink::WebCryptoAlgorithmId id)
+ void doWriteAlgorithmId(WebCryptoAlgorithmId id)
{
switch (id) {
- case blink::WebCryptoAlgorithmIdAesCbc:
+ case WebCryptoAlgorithmIdAesCbc:
return doWriteUint32(AesCbcTag);
- case blink::WebCryptoAlgorithmIdHmac:
+ case WebCryptoAlgorithmIdHmac:
return doWriteUint32(HmacTag);
- case blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5:
+ case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5:
return doWriteUint32(RsaSsaPkcs1v1_5Tag);
- case blink::WebCryptoAlgorithmIdSha1:
+ case WebCryptoAlgorithmIdSha1:
return doWriteUint32(Sha1Tag);
- case blink::WebCryptoAlgorithmIdSha256:
+ case WebCryptoAlgorithmIdSha256:
return doWriteUint32(Sha256Tag);
- case blink::WebCryptoAlgorithmIdSha384:
+ case WebCryptoAlgorithmIdSha384:
return doWriteUint32(Sha384Tag);
- case blink::WebCryptoAlgorithmIdSha512:
+ case WebCryptoAlgorithmIdSha512:
return doWriteUint32(Sha512Tag);
- case blink::WebCryptoAlgorithmIdAesGcm:
+ case WebCryptoAlgorithmIdAesGcm:
return doWriteUint32(AesGcmTag);
- case blink::WebCryptoAlgorithmIdRsaOaep:
+ case WebCryptoAlgorithmIdRsaOaep:
return doWriteUint32(RsaOaepTag);
- case blink::WebCryptoAlgorithmIdAesCtr:
+ case WebCryptoAlgorithmIdAesCtr:
return doWriteUint32(AesCtrTag);
- case blink::WebCryptoAlgorithmIdAesKw:
+ case WebCryptoAlgorithmIdAesKw:
return doWriteUint32(AesKwTag);
+ case WebCryptoAlgorithmIdRsaPss:
+ return doWriteUint32(RsaPssTag);
}
ASSERT_NOT_REACHED();
}
- void doWriteKeyUsages(const blink::WebCryptoKeyUsageMask usages, bool extractable)
+ void doWriteKeyUsages(const WebCryptoKeyUsageMask usages, bool extractable)
{
// Reminder to update this when adding new key usages.
- COMPILE_ASSERT(blink::EndOfWebCryptoKeyUsage == (1 << 7) + 1, UpdateMe);
+ COMPILE_ASSERT(EndOfWebCryptoKeyUsage == (1 << 7) + 1, UpdateMe);
uint32_t value = 0;
if (extractable)
value |= ExtractableUsage;
- if (usages & blink::WebCryptoKeyUsageEncrypt)
+ if (usages & WebCryptoKeyUsageEncrypt)
value |= EncryptUsage;
- if (usages & blink::WebCryptoKeyUsageDecrypt)
+ if (usages & WebCryptoKeyUsageDecrypt)
value |= DecryptUsage;
- if (usages & blink::WebCryptoKeyUsageSign)
+ if (usages & WebCryptoKeyUsageSign)
value |= SignUsage;
- if (usages & blink::WebCryptoKeyUsageVerify)
+ if (usages & WebCryptoKeyUsageVerify)
value |= VerifyUsage;
- if (usages & blink::WebCryptoKeyUsageDeriveKey)
+ if (usages & WebCryptoKeyUsageDeriveKey)
value |= DeriveKeyUsage;
- if (usages & blink::WebCryptoKeyUsageWrapKey)
+ if (usages & WebCryptoKeyUsageWrapKey)
value |= WrapKeyUsage;
- if (usages & blink::WebCryptoKeyUsageUnwrapKey)
+ if (usages & WebCryptoKeyUsageUnwrapKey)
value |= UnwrapKeyUsage;
- if (usages & blink::WebCryptoKeyUsageDeriveBits)
+ if (usages & WebCryptoKeyUsageDeriveBits)
value |= DeriveBitsUsage;
doWriteUint32(value);
return wrapper.As<v8::Object>();
}
-static v8::Handle<v8::ArrayBuffer> toV8Object(ArrayBuffer* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+static v8::Handle<v8::ArrayBuffer> toV8Object(DOMArrayBuffer* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
if (!impl)
return v8::Handle<v8::ArrayBuffer>();
};
// Dummy state that is used to signal serialization errors.
- class ErrorState FINAL : public StateBase {
+ class ErrorState final : public StateBase {
public:
ErrorState()
: StateBase(v8Undefined(), 0)
{
}
- virtual StateBase* advance(Serializer&) OVERRIDE
+ virtual StateBase* advance(Serializer&) override
{
delete this;
return 0;
bool m_nameDone;
};
- class ObjectState FINAL : public AbstractObjectState {
+ class ObjectState final : public AbstractObjectState {
public:
ObjectState(v8::Handle<v8::Object> object, StateBase* next)
: AbstractObjectState(object, next)
{
}
- virtual StateBase* advance(Serializer& serializer) OVERRIDE
+ virtual StateBase* advance(Serializer& serializer) override
{
if (m_propertyNames.IsEmpty()) {
m_propertyNames = composite()->GetPropertyNames();
}
protected:
- virtual StateBase* objectDone(unsigned numProperties, Serializer& serializer) OVERRIDE
+ virtual StateBase* objectDone(unsigned numProperties, Serializer& serializer) override
{
return serializer.writeObject(numProperties, this);
}
};
- class DenseArrayState FINAL : public AbstractObjectState {
+ class DenseArrayState final : public AbstractObjectState {
public:
DenseArrayState(v8::Handle<v8::Array> array, v8::Handle<v8::Array> propertyNames, StateBase* next, v8::Isolate* isolate)
: AbstractObjectState(array, next)
m_propertyNames = v8::Local<v8::Array>::New(isolate, propertyNames);
}
- virtual StateBase* advance(Serializer& serializer) OVERRIDE
+ virtual StateBase* advance(Serializer& serializer) override
{
while (m_arrayIndex < m_arrayLength) {
v8::Handle<v8::Value> value = composite().As<v8::Array>()->Get(m_arrayIndex);
}
protected:
- virtual StateBase* objectDone(unsigned numProperties, Serializer& serializer) OVERRIDE
+ virtual StateBase* objectDone(unsigned numProperties, Serializer& serializer) override
{
return serializer.writeDenseArray(numProperties, m_arrayLength, this);
}
uint32_t m_arrayLength;
};
- class SparseArrayState FINAL : public AbstractObjectState {
+ class SparseArrayState final : public AbstractObjectState {
public:
SparseArrayState(v8::Handle<v8::Array> array, v8::Handle<v8::Array> propertyNames, StateBase* next, v8::Isolate* isolate)
: AbstractObjectState(array, next)
m_propertyNames = v8::Local<v8::Array>::New(isolate, propertyNames);
}
- virtual StateBase* advance(Serializer& serializer) OVERRIDE
+ virtual StateBase* advance(Serializer& serializer) override
{
return serializeProperties(false, serializer);
}
protected:
- virtual StateBase* objectDone(unsigned numProperties, Serializer& serializer) OVERRIDE
+ virtual StateBase* objectDone(unsigned numProperties, Serializer& serializer) override
{
return serializer.writeSparseArray(numProperties, composite().As<v8::Array>()->Length(), this);
}
StateBase* writeAndGreyArrayBufferView(v8::Handle<v8::Object> object, StateBase* next)
{
ASSERT(!object.IsEmpty());
- ArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(object);
+ DOMArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(object);
if (!arrayBufferView)
return 0;
if (!arrayBufferView->buffer())
StateBase* stateOut = doSerializeArrayBuffer(underlyingBuffer, next);
if (stateOut)
return stateOut;
- m_writer.writeArrayBufferView(*arrayBufferView);
+ m_writer.writeArrayBufferView(*arrayBufferView->view());
// This should be safe: we serialize something that we know to be a wrapper (see
// the toV8 call above), so the call to doSerializeArrayBuffer should neither
// cause the system stack to overflow nor should it have potential to reach
StateBase* writeArrayBuffer(v8::Handle<v8::Value> value, StateBase* next)
{
- ArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(value.As<v8::Object>());
+ DOMArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(value.As<v8::Object>());
if (!arrayBuffer)
return 0;
if (arrayBuffer->isNeutered())
return handleError(DataCloneError, "An ArrayBuffer is neutered and could not be cloned.", next);
ASSERT(!m_transferredArrayBuffers.contains(value.As<v8::Object>()));
- m_writer.writeArrayBuffer(*arrayBuffer);
+ m_writer.writeArrayBuffer(*arrayBuffer->buffer());
return 0;
}
StateBase* writeTransferredArrayBuffer(v8::Handle<v8::Value> value, uint32_t index, StateBase* next)
{
- ArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(value.As<v8::Object>());
+ DOMArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(value.As<v8::Object>());
if (!arrayBuffer)
return 0;
if (arrayBuffer->isNeutered())
if (m_position + byteLength > m_length)
return nullptr;
const void* bufferStart = m_buffer + m_position;
- RefPtr<ArrayBuffer> arrayBuffer = ArrayBuffer::create(bufferStart, byteLength);
- arrayBuffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instanceTemplate());
m_position += byteLength;
- return arrayBuffer.release();
+ return ArrayBuffer::create(bufferStart, byteLength);
}
bool readArrayBuffer(v8::Handle<v8::Value>* value)
RefPtr<ArrayBuffer> arrayBuffer = doReadArrayBuffer();
if (!arrayBuffer)
return false;
- *value = toV8(arrayBuffer.release(), m_scriptState->context()->Global(), isolate());
+ *value = toV8(DOMArrayBuffer::create(arrayBuffer.release()), m_scriptState->context()->Global(), isolate());
return true;
}
ArrayBufferViewSubTag subTag;
uint32_t byteOffset;
uint32_t byteLength;
- RefPtr<ArrayBuffer> arrayBuffer;
+ RefPtr<DOMArrayBuffer> arrayBuffer;
v8::Handle<v8::Value> arrayBufferV8Value;
if (!readArrayBufferViewSubTag(&subTag))
return false;
v8::Handle<v8::Object> creationContext = m_scriptState->context()->Global();
switch (subTag) {
case ByteArrayTag:
- *value = toV8(Int8Array::create(arrayBuffer.release(), byteOffset, byteLength), creationContext, isolate());
+ *value = toV8(DOMInt8Array::create(arrayBuffer.release(), byteOffset, byteLength), creationContext, isolate());
break;
case UnsignedByteArrayTag:
- *value = toV8(Uint8Array::create(arrayBuffer.release(), byteOffset, byteLength), creationContext, isolate());
+ *value = toV8(DOMUint8Array::create(arrayBuffer.release(), byteOffset, byteLength), creationContext, isolate());
break;
case UnsignedByteClampedArrayTag:
- *value = toV8(Uint8ClampedArray::create(arrayBuffer.release(), byteOffset, byteLength), creationContext, isolate());
+ *value = toV8(DOMUint8ClampedArray::create(arrayBuffer.release(), byteOffset, byteLength), creationContext, isolate());
break;
case ShortArrayTag: {
uint32_t shortLength = byteLength / sizeof(int16_t);
if (shortLength * sizeof(int16_t) != byteLength)
return false;
- *value = toV8(Int16Array::create(arrayBuffer.release(), byteOffset, shortLength), creationContext, isolate());
+ *value = toV8(DOMInt16Array::create(arrayBuffer.release(), byteOffset, shortLength), creationContext, isolate());
break;
}
case UnsignedShortArrayTag: {
uint32_t shortLength = byteLength / sizeof(uint16_t);
if (shortLength * sizeof(uint16_t) != byteLength)
return false;
- *value = toV8(Uint16Array::create(arrayBuffer.release(), byteOffset, shortLength), creationContext, isolate());
+ *value = toV8(DOMUint16Array::create(arrayBuffer.release(), byteOffset, shortLength), creationContext, isolate());
break;
}
case IntArrayTag: {
uint32_t intLength = byteLength / sizeof(int32_t);
if (intLength * sizeof(int32_t) != byteLength)
return false;
- *value = toV8(Int32Array::create(arrayBuffer.release(), byteOffset, intLength), creationContext, isolate());
+ *value = toV8(DOMInt32Array::create(arrayBuffer.release(), byteOffset, intLength), creationContext, isolate());
break;
}
case UnsignedIntArrayTag: {
uint32_t intLength = byteLength / sizeof(uint32_t);
if (intLength * sizeof(uint32_t) != byteLength)
return false;
- *value = toV8(Uint32Array::create(arrayBuffer.release(), byteOffset, intLength), creationContext, isolate());
+ *value = toV8(DOMUint32Array::create(arrayBuffer.release(), byteOffset, intLength), creationContext, isolate());
break;
}
case FloatArrayTag: {
uint32_t floatLength = byteLength / sizeof(float);
if (floatLength * sizeof(float) != byteLength)
return false;
- *value = toV8(Float32Array::create(arrayBuffer.release(), byteOffset, floatLength), creationContext, isolate());
+ *value = toV8(DOMFloat32Array::create(arrayBuffer.release(), byteOffset, floatLength), creationContext, isolate());
break;
}
case DoubleArrayTag: {
uint32_t floatLength = byteLength / sizeof(double);
if (floatLength * sizeof(double) != byteLength)
return false;
- *value = toV8(Float64Array::create(arrayBuffer.release(), byteOffset, floatLength), creationContext, isolate());
+ *value = toV8(DOMFloat64Array::create(arrayBuffer.release(), byteOffset, floatLength), creationContext, isolate());
break;
}
case DataViewTag:
- *value = toV8(DataView::create(arrayBuffer.release(), byteOffset, byteLength), creationContext, isolate());
+ *value = toV8(DOMDataView::create(arrayBuffer.release(), byteOffset, byteLength), creationContext, isolate());
break;
default:
return false;
{
if (m_version < 3)
return false;
- RefPtrWillBeRawPtr<Blob> blob;
+ Blob* blob = nullptr;
if (isIndexed) {
if (m_version < 6)
return false;
uint32_t index;
if (!doReadUint32(&index) || index >= m_blobInfo->size())
return false;
- const blink::WebBlobInfo& info = (*m_blobInfo)[index];
+ const WebBlobInfo& info = (*m_blobInfo)[index];
blob = Blob::create(getOrCreateBlobDataHandle(info.uuid(), info.type(), info.size()));
} else {
ASSERT(!m_blobInfo);
return false;
blob = Blob::create(getOrCreateBlobDataHandle(uuid, type, size));
}
- *value = toV8(blob.release(), m_scriptState->context()->Global(), isolate());
+ *value = toV8(blob, m_scriptState->context()->Global(), isolate());
return true;
}
return false;
if (!readWebCoreString(&url))
return false;
- DOMFileSystem* fs = DOMFileSystem::create(m_scriptState->executionContext(), name, static_cast<blink::FileSystemType>(type), KURL(ParsedURLString, url));
+ DOMFileSystem* fs = DOMFileSystem::create(m_scriptState->executionContext(), name, static_cast<FileSystemType>(type), KURL(ParsedURLString, url));
*value = toV8(fs, m_scriptState->context()->Global(), isolate());
return true;
}
bool readFile(v8::Handle<v8::Value>* value, bool isIndexed)
{
- RefPtrWillBeRawPtr<File> file;
+ File* file = nullptr;
if (isIndexed) {
if (m_version < 6)
return false;
}
if (!file)
return false;
- *value = toV8(file.release(), m_scriptState->context()->Global(), isolate());
+ *value = toV8(file, m_scriptState->context()->Global(), isolate());
return true;
}
uint32_t length;
if (!doReadUint32(&length))
return false;
- RefPtrWillBeRawPtr<FileList> fileList = FileList::create();
+ FileList* fileList = FileList::create();
for (unsigned i = 0; i < length; ++i) {
- RefPtrWillBeRawPtr<File> file;
+ File* file = nullptr;
if (isIndexed) {
if (m_version < 6)
return false;
}
if (!file)
return false;
- fileList->append(file.release());
+ fileList->append(file);
}
- *value = toV8(fileList.release(), m_scriptState->context()->Global(), isolate());
+ *value = toV8(fileList, m_scriptState->context()->Global(), isolate());
return true;
}
if (!doReadUint32(&rawKeyType))
return false;
- blink::WebCryptoKeyAlgorithm algorithm;
- blink::WebCryptoKeyType type = blink::WebCryptoKeyTypeSecret;
+ WebCryptoKeyAlgorithm algorithm;
+ WebCryptoKeyType type = WebCryptoKeyTypeSecret;
switch (static_cast<CryptoKeySubTag>(rawKeyType)) {
case AesKeyTag:
return false;
}
- blink::WebCryptoKeyUsageMask usages;
+ WebCryptoKeyUsageMask usages;
bool extractable;
if (!doReadKeyUsages(usages, extractable))
return false;
const uint8_t* keyData = m_buffer + m_position;
m_position += keyDataLength;
- blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
- if (!blink::Platform::current()->crypto()->deserializeKeyForClone(
+ WebCryptoKey key = WebCryptoKey::createNull();
+ if (!Platform::current()->crypto()->deserializeKeyForClone(
algorithm, type, extractable, usages, keyData, keyDataLength, key)) {
return false;
}
return true;
}
- PassRefPtrWillBeRawPtr<File> readFileHelper()
+ File* readFileHelper()
{
if (m_version < 3)
return nullptr;
return File::createFromSerialization(path, name, relativePath, userVisibility, hasSnapshot > 0, size, lastModified, getOrCreateBlobDataHandle(uuid, type));
}
- PassRefPtrWillBeRawPtr<File> readFileIndexHelper()
+ File* readFileIndexHelper()
{
if (m_version < 3)
return nullptr;
return BlobDataHandle::create(uuid, type, size);
}
- bool doReadHmacKey(blink::WebCryptoKeyAlgorithm& algorithm, blink::WebCryptoKeyType& type)
+ bool doReadHmacKey(WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyType& type)
{
uint32_t lengthBytes;
if (!doReadUint32(&lengthBytes))
return false;
- blink::WebCryptoAlgorithmId hash;
+ WebCryptoAlgorithmId hash;
if (!doReadAlgorithmId(hash))
return false;
- algorithm = blink::WebCryptoKeyAlgorithm::createHmac(hash, lengthBytes * 8);
- type = blink::WebCryptoKeyTypeSecret;
+ algorithm = WebCryptoKeyAlgorithm::createHmac(hash, lengthBytes * 8);
+ type = WebCryptoKeyTypeSecret;
return !algorithm.isNull();
}
- bool doReadAesKey(blink::WebCryptoKeyAlgorithm& algorithm, blink::WebCryptoKeyType& type)
+ bool doReadAesKey(WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyType& type)
{
- blink::WebCryptoAlgorithmId id;
+ WebCryptoAlgorithmId id;
if (!doReadAlgorithmId(id))
return false;
uint32_t lengthBytes;
if (!doReadUint32(&lengthBytes))
return false;
- algorithm = blink::WebCryptoKeyAlgorithm::createAes(id, lengthBytes * 8);
- type = blink::WebCryptoKeyTypeSecret;
+ algorithm = WebCryptoKeyAlgorithm::createAes(id, lengthBytes * 8);
+ type = WebCryptoKeyTypeSecret;
return !algorithm.isNull();
}
- bool doReadRsaHashedKey(blink::WebCryptoKeyAlgorithm& algorithm, blink::WebCryptoKeyType& type)
+ bool doReadRsaHashedKey(WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyType& type)
{
- blink::WebCryptoAlgorithmId id;
+ WebCryptoAlgorithmId id;
if (!doReadAlgorithmId(id))
return false;
switch (static_cast<AssymetricCryptoKeyType>(rawType)) {
case PublicKeyType:
- type = blink::WebCryptoKeyTypePublic;
+ type = WebCryptoKeyTypePublic;
break;
case PrivateKeyType:
- type = blink::WebCryptoKeyTypePrivate;
+ type = WebCryptoKeyTypePrivate;
break;
default:
return false;
const uint8_t* publicExponent = m_buffer + m_position;
m_position += publicExponentSize;
- blink::WebCryptoAlgorithmId hash;
+ WebCryptoAlgorithmId hash;
if (!doReadAlgorithmId(hash))
return false;
- algorithm = blink::WebCryptoKeyAlgorithm::createRsaHashed(id, modulusLengthBits, publicExponent, publicExponentSize, hash);
+ algorithm = WebCryptoKeyAlgorithm::createRsaHashed(id, modulusLengthBits, publicExponent, publicExponentSize, hash);
return !algorithm.isNull();
}
- bool doReadAlgorithmId(blink::WebCryptoAlgorithmId& id)
+ bool doReadAlgorithmId(WebCryptoAlgorithmId& id)
{
uint32_t rawId;
if (!doReadUint32(&rawId))
switch (static_cast<CryptoKeyAlgorithmTag>(rawId)) {
case AesCbcTag:
- id = blink::WebCryptoAlgorithmIdAesCbc;
+ id = WebCryptoAlgorithmIdAesCbc;
return true;
case HmacTag:
- id = blink::WebCryptoAlgorithmIdHmac;
+ id = WebCryptoAlgorithmIdHmac;
return true;
case RsaSsaPkcs1v1_5Tag:
- id = blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5;
+ id = WebCryptoAlgorithmIdRsaSsaPkcs1v1_5;
return true;
case Sha1Tag:
- id = blink::WebCryptoAlgorithmIdSha1;
+ id = WebCryptoAlgorithmIdSha1;
return true;
case Sha256Tag:
- id = blink::WebCryptoAlgorithmIdSha256;
+ id = WebCryptoAlgorithmIdSha256;
return true;
case Sha384Tag:
- id = blink::WebCryptoAlgorithmIdSha384;
+ id = WebCryptoAlgorithmIdSha384;
return true;
case Sha512Tag:
- id = blink::WebCryptoAlgorithmIdSha512;
+ id = WebCryptoAlgorithmIdSha512;
return true;
case AesGcmTag:
- id = blink::WebCryptoAlgorithmIdAesGcm;
+ id = WebCryptoAlgorithmIdAesGcm;
return true;
case RsaOaepTag:
- id = blink::WebCryptoAlgorithmIdRsaOaep;
+ id = WebCryptoAlgorithmIdRsaOaep;
return true;
case AesCtrTag:
- id = blink::WebCryptoAlgorithmIdAesCtr;
+ id = WebCryptoAlgorithmIdAesCtr;
return true;
case AesKwTag:
- id = blink::WebCryptoAlgorithmIdAesKw;
+ id = WebCryptoAlgorithmIdAesKw;
+ return true;
+ case RsaPssTag:
+ id = WebCryptoAlgorithmIdRsaPss;
return true;
}
return false;
}
- bool doReadKeyUsages(blink::WebCryptoKeyUsageMask& usages, bool& extractable)
+ bool doReadKeyUsages(WebCryptoKeyUsageMask& usages, bool& extractable)
{
// Reminder to update this when adding new key usages.
- COMPILE_ASSERT(blink::EndOfWebCryptoKeyUsage == (1 << 7) + 1, UpdateMe);
+ COMPILE_ASSERT(EndOfWebCryptoKeyUsage == (1 << 7) + 1, UpdateMe);
const uint32_t allPossibleUsages = ExtractableUsage | EncryptUsage | DecryptUsage | SignUsage | VerifyUsage | DeriveKeyUsage | WrapKeyUsage | UnwrapKeyUsage | DeriveBitsUsage;
uint32_t rawUsages;
extractable = rawUsages & ExtractableUsage;
if (rawUsages & EncryptUsage)
- usages |= blink::WebCryptoKeyUsageEncrypt;
+ usages |= WebCryptoKeyUsageEncrypt;
if (rawUsages & DecryptUsage)
- usages |= blink::WebCryptoKeyUsageDecrypt;
+ usages |= WebCryptoKeyUsageDecrypt;
if (rawUsages & SignUsage)
- usages |= blink::WebCryptoKeyUsageSign;
+ usages |= WebCryptoKeyUsageSign;
if (rawUsages & VerifyUsage)
- usages |= blink::WebCryptoKeyUsageVerify;
+ usages |= WebCryptoKeyUsageVerify;
if (rawUsages & DeriveKeyUsage)
- usages |= blink::WebCryptoKeyUsageDeriveKey;
+ usages |= WebCryptoKeyUsageDeriveKey;
if (rawUsages & WrapKeyUsage)
- usages |= blink::WebCryptoKeyUsageWrapKey;
+ usages |= WebCryptoKeyUsageWrapKey;
if (rawUsages & UnwrapKeyUsage)
- usages |= blink::WebCryptoKeyUsageUnwrapKey;
+ usages |= WebCryptoKeyUsageUnwrapKey;
if (rawUsages & DeriveBitsUsage)
- usages |= blink::WebCryptoKeyUsageDeriveBits;
+ usages |= WebCryptoKeyUsageDeriveBits;
return true;
}
typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray;
-class Deserializer FINAL : public CompositeCreator {
+class Deserializer final : public CompositeCreator {
public:
Deserializer(Reader& reader, MessagePortArray* messagePorts, ArrayBufferContentsArray* arrayBufferContents)
: m_reader(reader)
return result;
}
- virtual bool newSparseArray(uint32_t) OVERRIDE
+ virtual bool newSparseArray(uint32_t) override
{
v8::Local<v8::Array> array = v8::Array::New(m_reader.scriptState()->isolate(), 0);
openComposite(array);
return true;
}
- virtual bool newDenseArray(uint32_t length) OVERRIDE
+ virtual bool newDenseArray(uint32_t length) override
{
v8::Local<v8::Array> array = v8::Array::New(m_reader.scriptState()->isolate(), length);
openComposite(array);
return true;
}
- virtual bool consumeTopOfStack(v8::Handle<v8::Value>* object) OVERRIDE
+ virtual bool consumeTopOfStack(v8::Handle<v8::Value>* object) override
{
if (stackDepth() < 1)
return false;
return true;
}
- virtual bool newObject() OVERRIDE
+ virtual bool newObject() override
{
v8::Local<v8::Object> object = v8::Object::New(m_reader.scriptState()->isolate());
if (object.IsEmpty())
return true;
}
- virtual bool completeObject(uint32_t numProperties, v8::Handle<v8::Value>* value) OVERRIDE
+ virtual bool completeObject(uint32_t numProperties, v8::Handle<v8::Value>* value) override
{
v8::Local<v8::Object> object;
if (m_version > 0) {
return initializeObject(object, numProperties, value);
}
- virtual bool completeSparseArray(uint32_t numProperties, uint32_t length, v8::Handle<v8::Value>* value) OVERRIDE
+ virtual bool completeSparseArray(uint32_t numProperties, uint32_t length, v8::Handle<v8::Value>* value) override
{
v8::Local<v8::Array> array;
if (m_version > 0) {
return initializeObject(array, numProperties, value);
}
- virtual bool completeDenseArray(uint32_t numProperties, uint32_t length, v8::Handle<v8::Value>* value) OVERRIDE
+ virtual bool completeDenseArray(uint32_t numProperties, uint32_t length, v8::Handle<v8::Value>* value) override
{
v8::Local<v8::Array> array;
if (m_version > 0) {
return true;
}
- virtual void pushObjectReference(const v8::Handle<v8::Value>& object) OVERRIDE
+ virtual void pushObjectReference(const v8::Handle<v8::Value>& object) override
{
m_objectPool.append(object);
}
- virtual bool tryGetTransferredMessagePort(uint32_t index, v8::Handle<v8::Value>* object) OVERRIDE
+ virtual bool tryGetTransferredMessagePort(uint32_t index, v8::Handle<v8::Value>* object) override
{
if (!m_transferredMessagePorts)
return false;
return true;
}
- virtual bool tryGetTransferredArrayBuffer(uint32_t index, v8::Handle<v8::Value>* object) OVERRIDE
+ virtual bool tryGetTransferredArrayBuffer(uint32_t index, v8::Handle<v8::Value>* object) override
{
if (!m_arrayBufferContents)
return false;
return false;
v8::Handle<v8::Object> result = m_arrayBuffers.at(index);
if (result.IsEmpty()) {
- RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(m_arrayBufferContents->at(index));
- buffer->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instanceTemplate());
+ RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(m_arrayBufferContents->at(index));
v8::Isolate* isolate = m_reader.scriptState()->isolate();
v8::Handle<v8::Object> creationContext = m_reader.scriptState()->context()->Global();
- isolate->AdjustAmountOfExternalAllocatedMemory(buffer->byteLength());
result = toV8Object(buffer.get(), creationContext, isolate);
m_arrayBuffers[index] = result;
}
return true;
}
- virtual bool tryGetObjectFromObjectReference(uint32_t reference, v8::Handle<v8::Value>* object) OVERRIDE
+ virtual bool tryGetObjectFromObjectReference(uint32_t reference, v8::Handle<v8::Value>* object) override
{
if (reference >= m_objectPool.size())
return false;
return object;
}
- virtual uint32_t objectReferenceCount() OVERRIDE
+ virtual uint32_t objectReferenceCount() override
{
return m_objectPool.size();
}
return adoptRef(new SerializedScriptValue(value, messagePorts, arrayBuffers, 0, exceptionState, isolate));
}
-PassRefPtr<SerializedScriptValue> SerializedScriptValue::createAndSwallowExceptions(v8::Handle<v8::Value> value, v8::Isolate* isolate)
+PassRefPtr<SerializedScriptValue> SerializedScriptValue::createAndSwallowExceptions(v8::Isolate* isolate, v8::Handle<v8::Value> value)
{
TrackExceptionState exceptionState;
return adoptRef(new SerializedScriptValue(value, 0, 0, 0, exceptionState, isolate));
{
}
-static void neuterArrayBufferInAllWorlds(ArrayBuffer* object)
+static void neuterArrayBufferInAllWorlds(DOMArrayBuffer* object)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
if (isMainThread()) {
Vector<RefPtr<DOMWrapperWorld> > worlds;
DOMWrapperWorld::allWorldsInMainThread(worlds);
for (size_t i = 0; i < worlds.size(); i++) {
- v8::Handle<v8::Object> wrapper = worlds[i]->domDataStore().get<V8ArrayBuffer>(object, isolate);
+ v8::Handle<v8::Object> wrapper = worlds[i]->domDataStore().get(object, isolate);
if (!wrapper.IsEmpty()) {
ASSERT(wrapper->IsArrayBuffer());
v8::Handle<v8::ArrayBuffer>::Cast(wrapper)->Neuter();
}
}
} else {
- v8::Handle<v8::Object> wrapper = DOMWrapperWorld::current(isolate).domDataStore().get<V8ArrayBuffer>(object, isolate);
+ v8::Handle<v8::Object> wrapper = DOMWrapperWorld::current(isolate).domDataStore().get(object, isolate);
if (!wrapper.IsEmpty()) {
ASSERT(wrapper->IsArrayBuffer());
v8::Handle<v8::ArrayBuffer>::Cast(wrapper)->Neuter();
}
}
-PassOwnPtr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValue::transferArrayBuffers(ArrayBufferArray& arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate)
+PassOwnPtr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValue::transferArrayBuffers(v8::Isolate* isolate, ArrayBufferArray& arrayBuffers, ExceptionState& exceptionState)
{
ASSERT(arrayBuffers.size());
OwnPtr<ArrayBufferContentsArray> contents = adoptPtr(new ArrayBufferContentsArray(arrayBuffers.size()));
- HashSet<ArrayBuffer*> visited;
+ HashSet<DOMArrayBuffer*> visited;
for (size_t i = 0; i < arrayBuffers.size(); i++) {
if (visited.contains(arrayBuffers[i].get()))
continue;
m_data = writer.takeWireString();
ASSERT(m_data.impl()->hasOneRef());
if (arrayBuffers && arrayBuffers->size())
- m_arrayBufferContentsArray = transferArrayBuffers(*arrayBuffers, exceptionState, isolate);
+ m_arrayBufferContentsArray = transferArrayBuffers(isolate, *arrayBuffers, exceptionState);
return;
case Serializer::JSException:
ASSERT_NOT_REACHED();
return deserializer.deserialize();
}
-bool SerializedScriptValue::extractTransferables(v8::Local<v8::Value> value, int argumentIndex, MessagePortArray& ports, ArrayBufferArray& arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate)
+bool SerializedScriptValue::extractTransferables(v8::Isolate* isolate, v8::Local<v8::Value> value, int argumentIndex, MessagePortArray& ports, ArrayBufferArray& arrayBuffers, ExceptionState& exceptionState)
{
if (isUndefinedOrNull(value)) {
ports.resize(0);
}
ports.append(port.release());
} else if (V8ArrayBuffer::hasInstance(transferrable, isolate)) {
- RefPtr<ArrayBuffer> arrayBuffer = V8ArrayBuffer::toImpl(v8::Handle<v8::Object>::Cast(transferrable));
+ RefPtr<DOMArrayBuffer> arrayBuffer = V8ArrayBuffer::toImpl(v8::Handle<v8::Object>::Cast(transferrable));
if (arrayBuffers.contains(arrayBuffer)) {
exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at index " + String::number(i) + " is a duplicate of an earlier ArrayBuffer.");
return false;