Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / core / v8 / SerializedScriptValue.cpp
index 3aba0c3..134cfbd 100644 (file)
 #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"
@@ -275,6 +275,7 @@ enum CryptoKeyAlgorithmTag {
     RsaOaepTag = 10,
     AesCtrTag = 11,
     AesKwTag = 12,
+    RsaPssTag = 13,
     // Maximum allowed value is 2^32-1
 };
 
@@ -504,29 +505,29 @@ public:
             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());
@@ -707,9 +708,9 @@ private:
         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));
@@ -717,9 +718,9 @@ private:
         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());
@@ -729,7 +730,7 @@ private:
         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));
@@ -737,77 +738,79 @@ private:
         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);
@@ -911,7 +914,7 @@ static v8::Handle<v8::Object> toV8Object(MessagePort* impl, v8::Handle<v8::Objec
     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>();
@@ -1032,14 +1035,14 @@ private:
     };
 
     // 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;
@@ -1124,14 +1127,14 @@ private:
         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();
@@ -1144,13 +1147,13 @@ private:
         }
 
     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)
@@ -1160,7 +1163,7 @@ private:
             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);
@@ -1174,7 +1177,7 @@ private:
         }
 
     protected:
-        virtual StateBase* objectDone(unsigned numProperties, Serializer& serializer) OVERRIDE
+        virtual StateBase* objectDone(unsigned numProperties, Serializer& serializer) override
         {
             return serializer.writeDenseArray(numProperties, m_arrayLength, this);
         }
@@ -1184,7 +1187,7 @@ private:
         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)
@@ -1192,13 +1195,13 @@ private:
             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);
         }
@@ -1373,7 +1376,7 @@ private:
     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())
@@ -1384,7 +1387,7 @@ private:
         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
@@ -1401,19 +1404,19 @@ private:
 
     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())
@@ -2034,10 +2037,8 @@ private:
         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)
@@ -2045,7 +2046,7 @@ private:
         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;
     }
 
@@ -2054,7 +2055,7 @@ private:
         ArrayBufferViewSubTag subTag;
         uint32_t byteOffset;
         uint32_t byteLength;
-        RefPtr<ArrayBuffer> arrayBuffer;
+        RefPtr<DOMArrayBuffer> arrayBuffer;
         v8::Handle<v8::Value> arrayBufferV8Value;
         if (!readArrayBufferViewSubTag(&subTag))
             return false;
@@ -2073,58 +2074,58 @@ private:
         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;
@@ -2151,7 +2152,7 @@ private:
     {
         if (m_version < 3)
             return false;
-        RefPtrWillBeRawPtr<Blob> blob;
+        Blob* blob = nullptr;
         if (isIndexed) {
             if (m_version < 6)
                 return false;
@@ -2159,7 +2160,7 @@ private:
             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);
@@ -2175,7 +2176,7 @@ private:
                 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;
     }
 
@@ -2190,14 +2191,14 @@ private:
             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;
@@ -2207,7 +2208,7 @@ private:
         }
         if (!file)
             return false;
-        *value = toV8(file.release(), m_scriptState->context()->Global(), isolate());
+        *value = toV8(file, m_scriptState->context()->Global(), isolate());
         return true;
     }
 
@@ -2218,9 +2219,9 @@ private:
         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;
@@ -2230,9 +2231,9 @@ private:
             }
             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;
     }
 
@@ -2242,8 +2243,8 @@ private:
         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:
@@ -2262,7 +2263,7 @@ private:
             return false;
         }
 
-        blink::WebCryptoKeyUsageMask usages;
+        WebCryptoKeyUsageMask usages;
         bool extractable;
         if (!doReadKeyUsages(usages, extractable))
             return false;
@@ -2277,8 +2278,8 @@ private:
         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;
         }
@@ -2287,7 +2288,7 @@ private:
         return true;
     }
 
-    PassRefPtrWillBeRawPtr<File> readFileHelper()
+    File* readFileHelper()
     {
         if (m_version < 3)
             return nullptr;
@@ -2325,7 +2326,7 @@ private:
         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;
@@ -2393,35 +2394,35 @@ private:
         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;
 
@@ -2431,10 +2432,10 @@ private:
 
         switch (static_cast<AssymetricCryptoKeyType>(rawType)) {
         case PublicKeyType:
-            type = blink::WebCryptoKeyTypePublic;
+            type = WebCryptoKeyTypePublic;
             break;
         case PrivateKeyType:
-            type = blink::WebCryptoKeyTypePrivate;
+            type = WebCryptoKeyTypePrivate;
             break;
         default:
             return false;
@@ -2454,15 +2455,15 @@ private:
         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))
@@ -2470,47 +2471,50 @@ private:
 
         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;
@@ -2526,21 +2530,21 @@ private:
         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;
     }
@@ -2557,7 +2561,7 @@ private:
 
 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)
@@ -2585,21 +2589,21 @@ public:
         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;
@@ -2608,7 +2612,7 @@ public:
         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())
@@ -2617,7 +2621,7 @@ public:
         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) {
@@ -2633,7 +2637,7 @@ public:
         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) {
@@ -2649,7 +2653,7 @@ public:
         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) {
@@ -2673,12 +2677,12 @@ public:
         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;
@@ -2689,7 +2693,7 @@ public:
         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;
@@ -2697,11 +2701,9 @@ public:
             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;
         }
@@ -2709,7 +2711,7 @@ public:
         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;
@@ -2717,7 +2719,7 @@ public:
         return object;
     }
 
-    virtual uint32_t objectReferenceCount() OVERRIDE
+    virtual uint32_t objectReferenceCount() override
     {
         return m_objectPool.size();
     }
@@ -2800,7 +2802,7 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(v8::Handle<v8::V
     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));
@@ -2881,21 +2883,21 @@ SerializedScriptValue::SerializedScriptValue()
 {
 }
 
-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();
@@ -2903,7 +2905,7 @@ static void neuterArrayBufferInAllWorlds(ArrayBuffer* object)
     }
 }
 
-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());
 
@@ -2916,7 +2918,7 @@ PassOwnPtr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValu
 
     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;
@@ -2959,7 +2961,7 @@ SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, Messag
         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();
@@ -2998,7 +3000,7 @@ v8::Handle<v8::Value> SerializedScriptValue::deserialize(v8::Isolate* isolate, M
     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);
@@ -3036,7 +3038,7 @@ bool SerializedScriptValue::extractTransferables(v8::Local<v8::Value> value, int
             }
             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;