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" | |
56 #include "wtf/Vector.h" | 55 #include "wtf/Vector.h" |
57 #include "wtf/text/StringBuffer.h" | 56 #include "wtf/text/StringBuffer.h" |
58 #include "wtf/text/StringHash.h" | 57 #include "wtf/text/StringHash.h" |
59 #include <memory> | |
60 | 58 |
61 namespace blink { | 59 namespace blink { |
62 | 60 |
63 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(v8::Isolate*
isolate, v8::Local<v8::Value> value, Transferables* transferables, WebBlobInfoAr
ray* blobInfo, ExceptionState& exception) | 61 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(v8::Isolate*
isolate, v8::Local<v8::Value> value, Transferables* transferables, WebBlobInfoAr
ray* blobInfo, ExceptionState& exception) |
64 { | 62 { |
65 return SerializedScriptValueFactory::instance().create(isolate, value, trans
ferables, blobInfo, exception); | 63 return SerializedScriptValueFactory::instance().create(isolate, value, trans
ferables, blobInfo, exception); |
66 } | 64 } |
67 | 65 |
68 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(const String&
str) | 66 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(const String&
str) |
69 { | 67 { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 if (!imageBitmaps.size()) | 169 if (!imageBitmaps.size()) |
172 return; | 170 return; |
173 | 171 |
174 for (size_t i = 0; i < imageBitmaps.size(); ++i) { | 172 for (size_t i = 0; i < imageBitmaps.size(); ++i) { |
175 if (imageBitmaps[i]->isNeutered()) { | 173 if (imageBitmaps[i]->isNeutered()) { |
176 exceptionState.throwDOMException(DataCloneError, "ImageBitmap at ind
ex " + String::number(i) + " is already detached."); | 174 exceptionState.throwDOMException(DataCloneError, "ImageBitmap at ind
ex " + String::number(i) + " is already detached."); |
177 return; | 175 return; |
178 } | 176 } |
179 } | 177 } |
180 | 178 |
181 std::unique_ptr<ImageBitmapContentsArray> contents = wrapUnique(new ImageBit
mapContentsArray); | 179 OwnPtr<ImageBitmapContentsArray> contents = adoptPtr(new ImageBitmapContents
Array); |
182 HeapHashSet<Member<ImageBitmap>> visited; | 180 HeapHashSet<Member<ImageBitmap>> visited; |
183 for (size_t i = 0; i < imageBitmaps.size(); ++i) { | 181 for (size_t i = 0; i < imageBitmaps.size(); ++i) { |
184 if (visited.contains(imageBitmaps[i])) | 182 if (visited.contains(imageBitmaps[i])) |
185 continue; | 183 continue; |
186 visited.add(imageBitmaps[i]); | 184 visited.add(imageBitmaps[i]); |
187 contents->append(imageBitmaps[i]->transfer()); | 185 contents->append(imageBitmaps[i]->transfer()); |
188 } | 186 } |
189 m_imageBitmapContentsArray = std::move(contents); | 187 m_imageBitmapContentsArray = std::move(contents); |
190 } | 188 } |
191 | 189 |
(...skipping 24 matching lines...) Expand all Loading... |
216 if (!arrayBuffers.size()) | 214 if (!arrayBuffers.size()) |
217 return; | 215 return; |
218 | 216 |
219 for (size_t i = 0; i < arrayBuffers.size(); ++i) { | 217 for (size_t i = 0; i < arrayBuffers.size(); ++i) { |
220 if (arrayBuffers[i]->isNeutered()) { | 218 if (arrayBuffers[i]->isNeutered()) { |
221 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at ind
ex " + String::number(i) + " is already neutered."); | 219 exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at ind
ex " + String::number(i) + " is already neutered."); |
222 return; | 220 return; |
223 } | 221 } |
224 } | 222 } |
225 | 223 |
226 std::unique_ptr<ArrayBufferContentsArray> contents = wrapUnique(new ArrayBuf
ferContentsArray(arrayBuffers.size())); | 224 OwnPtr<ArrayBufferContentsArray> contents = adoptPtr(new ArrayBufferContents
Array(arrayBuffers.size())); |
227 | 225 |
228 HeapHashSet<Member<DOMArrayBufferBase>> visited; | 226 HeapHashSet<Member<DOMArrayBufferBase>> visited; |
229 for (size_t i = 0; i < arrayBuffers.size(); ++i) { | 227 for (size_t i = 0; i < arrayBuffers.size(); ++i) { |
230 if (visited.contains(arrayBuffers[i])) | 228 if (visited.contains(arrayBuffers[i])) |
231 continue; | 229 continue; |
232 visited.add(arrayBuffers[i]); | 230 visited.add(arrayBuffers[i]); |
233 | 231 |
234 if (arrayBuffers[i]->isShared()) { | 232 if (arrayBuffers[i]->isShared()) { |
235 bool result = arrayBuffers[i]->shareContentsWith(contents->at(i)); | 233 bool result = arrayBuffers[i]->shareContentsWith(contents->at(i)); |
236 if (!result) { | 234 if (!result) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); | 350 m_externallyAllocatedMemory = static_cast<intptr_t>(m_data.length()); |
353 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall
yAllocatedMemory); | 351 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externall
yAllocatedMemory); |
354 } | 352 } |
355 | 353 |
356 bool SerializedScriptValue::containsTransferableArrayBuffer() const | 354 bool SerializedScriptValue::containsTransferableArrayBuffer() const |
357 { | 355 { |
358 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); | 356 return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty(); |
359 } | 357 } |
360 | 358 |
361 } // namespace blink | 359 } // namespace blink |
OLD | NEW |