| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "core/dom/DOMArrayBuffer.h" | 45 #include "core/dom/DOMArrayBuffer.h" |
| 46 #include "core/dom/DOMSharedArrayBuffer.h" | 46 #include "core/dom/DOMSharedArrayBuffer.h" |
| 47 #include "core/dom/ExceptionCode.h" | 47 #include "core/dom/ExceptionCode.h" |
| 48 #include "core/dom/MessagePort.h" | 48 #include "core/dom/MessagePort.h" |
| 49 #include "core/frame/ImageBitmap.h" | 49 #include "core/frame/ImageBitmap.h" |
| 50 #include "platform/SharedBuffer.h" | 50 #include "platform/SharedBuffer.h" |
| 51 #include "platform/blob/BlobData.h" | 51 #include "platform/blob/BlobData.h" |
| 52 #include "platform/heap/Handle.h" | 52 #include "platform/heap/Handle.h" |
| 53 #include "wtf/Assertions.h" | 53 #include "wtf/Assertions.h" |
| 54 #include "wtf/ByteOrder.h" | 54 #include "wtf/ByteOrder.h" |
| 55 #include "wtf/PtrUtil.h" |
| 55 #include "wtf/Vector.h" | 56 #include "wtf/Vector.h" |
| 56 #include "wtf/text/StringBuffer.h" | 57 #include "wtf/text/StringBuffer.h" |
| 57 #include "wtf/text/StringHash.h" | 58 #include "wtf/text/StringHash.h" |
| 59 #include <memory> |
| 58 | 60 |
| 59 namespace blink { | 61 namespace blink { |
| 60 | 62 |
| 61 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(v8::Isolate*
isolate, v8::Local<v8::Value> value, Transferables* transferables, WebBlobInfoAr
ray* blobInfo, ExceptionState& exception) | 63 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(v8::Isolate*
isolate, v8::Local<v8::Value> value, Transferables* transferables, WebBlobInfoAr
ray* blobInfo, ExceptionState& exception) |
| 62 { | 64 { |
| 63 return SerializedScriptValueFactory::instance().create(isolate, value, trans
ferables, blobInfo, exception); | 65 return SerializedScriptValueFactory::instance().create(isolate, value, trans
ferables, blobInfo, exception); |
| 64 } | 66 } |
| 65 | 67 |
| 66 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(const String&
str) | 68 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(const String&
str) |
| 67 { | 69 { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if (!imageBitmaps.size()) | 171 if (!imageBitmaps.size()) |
| 170 return; | 172 return; |
| 171 | 173 |
| 172 for (size_t i = 0; i < imageBitmaps.size(); ++i) { | 174 for (size_t i = 0; i < imageBitmaps.size(); ++i) { |
| 173 if (imageBitmaps[i]->isNeutered()) { | 175 if (imageBitmaps[i]->isNeutered()) { |
| 174 exceptionState.throwDOMException(DataCloneError, "ImageBitmap at ind
ex " + String::number(i) + " is already detached."); | 176 exceptionState.throwDOMException(DataCloneError, "ImageBitmap at ind
ex " + String::number(i) + " is already detached."); |
| 175 return; | 177 return; |
| 176 } | 178 } |
| 177 } | 179 } |
| 178 | 180 |
| 179 OwnPtr<ImageBitmapContentsArray> contents = adoptPtr(new ImageBitmapContents
Array); | 181 std::unique_ptr<ImageBitmapContentsArray> contents = wrapUnique(new ImageBit
mapContentsArray); |
| 180 HeapHashSet<Member<ImageBitmap>> visited; | 182 HeapHashSet<Member<ImageBitmap>> visited; |
| 181 for (size_t i = 0; i < imageBitmaps.size(); ++i) { | 183 for (size_t i = 0; i < imageBitmaps.size(); ++i) { |
| 182 if (visited.contains(imageBitmaps[i])) | 184 if (visited.contains(imageBitmaps[i])) |
| 183 continue; | 185 continue; |
| 184 visited.add(imageBitmaps[i]); | 186 visited.add(imageBitmaps[i]); |
| 185 contents->append(imageBitmaps[i]->transfer()); | 187 contents->append(imageBitmaps[i]->transfer()); |
| 186 } | 188 } |
| 187 m_imageBitmapContentsArray = std::move(contents); | 189 m_imageBitmapContentsArray = std::move(contents); |
| 188 } | 190 } |
| 189 | 191 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 214 if (!arrayBuffers.size()) | 216 if (!arrayBuffers.size()) |
| 215 return; | 217 return; |
| 216 | 218 |
| 217 for (size_t i = 0; i < arrayBuffers.size(); ++i) { | 219 for (size_t i = 0; i < arrayBuffers.size(); ++i) { |
| 218 if (arrayBuffers[i]->isNeutered()) { | 220 if (arrayBuffers[i]->isNeutered()) { |
| 219 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at ind
ex " + String::number(i) + " is already neutered."); | 221 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at ind
ex " + String::number(i) + " is already neutered."); |
| 220 return; | 222 return; |
| 221 } | 223 } |
| 222 } | 224 } |
| 223 | 225 |
| 224 OwnPtr<ArrayBufferContentsArray> contents = adoptPtr(new ArrayBufferContents
Array(arrayBuffers.size())); | 226 std::unique_ptr<ArrayBufferContentsArray> contents = wrapUnique(new ArrayBuf
ferContentsArray(arrayBuffers.size())); |
| 225 | 227 |
| 226 HeapHashSet<Member<DOMArrayBufferBase>> visited; | 228 HeapHashSet<Member<DOMArrayBufferBase>> visited; |
| 227 for (size_t i = 0; i < arrayBuffers.size(); ++i) { | 229 for (size_t i = 0; i < arrayBuffers.size(); ++i) { |
| 228 if (visited.contains(arrayBuffers[i])) | 230 if (visited.contains(arrayBuffers[i])) |
| 229 continue; | 231 continue; |
| 230 visited.add(arrayBuffers[i]); | 232 visited.add(arrayBuffers[i]); |
| 231 | 233 |
| 232 if (arrayBuffers[i]->isShared()) { | 234 if (arrayBuffers[i]->isShared()) { |
| 233 bool result = arrayBuffers[i]->shareContentsWith(contents->at(i)); | 235 bool result = arrayBuffers[i]->shareContentsWith(contents->at(i)); |
| 234 if (!result) { | 236 if (!result) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); | 352 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); |
| 351 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall
yAllocatedMemory); | 353 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall
yAllocatedMemory); |
| 352 } | 354 } |
| 353 | 355 |
| 354 bool SerializedScriptValue::containsTransferableArrayBuffer() const | 356 bool SerializedScriptValue::containsTransferableArrayBuffer() const |
| 355 { | 357 { |
| 356 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); | 358 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); |
| 357 } | 359 } |
| 358 | 360 |
| 359 } // namespace blink | 361 } // namespace blink |
| OLD | NEW |