| 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/ArrayBufferOrArrayBufferView.h" | 7 #include "bindings/core/v8/ArrayBufferOrArrayBufferView.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 DOMArrayPiece::DOMArrayPiece( | 11 DOMArrayPiece::DOMArrayPiece( |
| 12 const ArrayBufferOrArrayBufferView& arrayBufferOrView, | 12 const ArrayBufferOrArrayBufferView& arrayBufferOrView, |
| 13 InitWithUnionOption option) { | 13 InitWithUnionOption option) { |
| 14 if (arrayBufferOrView.isArrayBuffer()) { | 14 if (arrayBufferOrView.isArrayBuffer()) { |
| 15 DOMArrayBuffer* arrayBuffer = arrayBufferOrView.getAsArrayBuffer(); | 15 DOMArrayBuffer* arrayBuffer = arrayBufferOrView.getAsArrayBuffer(); |
| 16 initWithData(arrayBuffer->data(), arrayBuffer->byteLength()); | 16 initWithData(arrayBuffer->data(), arrayBuffer->byteLength()); |
| 17 } else if (arrayBufferOrView.isArrayBufferView()) { | 17 } else if (arrayBufferOrView.isArrayBufferView()) { |
| 18 DOMArrayBufferView* arrayBufferView = | 18 DOMArrayBufferView* arrayBufferView = |
| 19 arrayBufferOrView.getAsArrayBufferView(); | 19 arrayBufferOrView.getAsArrayBufferView().view(); |
| 20 initWithData(arrayBufferView->baseAddress(), arrayBufferView->byteLength()); | 20 initWithData(arrayBufferView->baseAddress(), arrayBufferView->byteLength()); |
| 21 } else if (arrayBufferOrView.isNull() && | 21 } else if (arrayBufferOrView.isNull() && |
| 22 option == AllowNullPointToNullWithZeroSize) { | 22 option == AllowNullPointToNullWithZeroSize) { |
| 23 initWithData(nullptr, 0); | 23 initWithData(nullptr, 0); |
| 24 } // Otherwise, leave the obejct as null. | 24 } // Otherwise, leave the obejct as null. |
| 25 } | 25 } |
| 26 | 26 |
| 27 } // namespace blink | 27 } // namespace blink |
| OLD | NEW |