OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/dom/DOMArrayPiece.h" | 5 #include "core/dom/DOMArrayPiece.h" |
6 | 6 |
7 #include "bindings/core/v8/UnionTypesCore.h" | 7 #include "bindings/core/v8/ArrayBufferOrArrayBufferView.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 DOMArrayPiece::DOMArrayPiece(const ArrayBufferOrArrayBufferView& arrayBufferOrVi
ew, InitWithUnionOption option) | 11 DOMArrayPiece::DOMArrayPiece(const ArrayBufferOrArrayBufferView& arrayBufferOrVi
ew, InitWithUnionOption option) |
12 { | 12 { |
13 if (arrayBufferOrView.isArrayBuffer()) { | 13 if (arrayBufferOrView.isArrayBuffer()) { |
14 DOMArrayBuffer* arrayBuffer = arrayBufferOrView.getAsArrayBuffer(); | 14 DOMArrayBuffer* arrayBuffer = arrayBufferOrView.getAsArrayBuffer(); |
15 initWithData(arrayBuffer->data(), arrayBuffer->byteLength()); | 15 initWithData(arrayBuffer->data(), arrayBuffer->byteLength()); |
16 } else if (arrayBufferOrView.isArrayBufferView()) { | 16 } else if (arrayBufferOrView.isArrayBufferView()) { |
17 DOMArrayBufferView* arrayBufferView = arrayBufferOrView.getAsArrayBuffer
View(); | 17 DOMArrayBufferView* arrayBufferView = arrayBufferOrView.getAsArrayBuffer
View(); |
18 initWithData(arrayBufferView->baseAddress(), arrayBufferView->byteLength
()); | 18 initWithData(arrayBufferView->baseAddress(), arrayBufferView->byteLength
()); |
19 } else if (arrayBufferOrView.isNull() && option == AllowNullPointToNullWithZ
eroSize) { | 19 } else if (arrayBufferOrView.isNull() && option == AllowNullPointToNullWithZ
eroSize) { |
20 initWithData(nullptr, 0); | 20 initWithData(nullptr, 0); |
21 } // Otherwise, leave the obejct as null. | 21 } // Otherwise, leave the obejct as null. |
22 } | 22 } |
23 | 23 |
24 } // namespace blink | 24 } // namespace blink |
OLD | NEW |