| 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& array_buffer_or_view, | 12 const ArrayBufferOrArrayBufferView& array_buffer_or_view, |
| 13 InitWithUnionOption option) { | 13 InitWithUnionOption option) { |
| 14 if (array_buffer_or_view.isArrayBuffer()) { | 14 if (array_buffer_or_view.isArrayBuffer()) { |
| 15 DOMArrayBuffer* array_buffer = array_buffer_or_view.getAsArrayBuffer(); | 15 DOMArrayBuffer* array_buffer = array_buffer_or_view.getAsArrayBuffer(); |
| 16 InitWithData(array_buffer->Data(), array_buffer->ByteLength()); | 16 InitWithData(array_buffer->Data(), array_buffer->ByteLength()); |
| 17 } else if (array_buffer_or_view.isArrayBufferView()) { | 17 } else if (array_buffer_or_view.isArrayBufferView()) { |
| 18 DOMArrayBufferView* array_buffer_view = | 18 DOMArrayBufferView* array_buffer_view = |
| 19 array_buffer_or_view.getAsArrayBufferView(); | 19 array_buffer_or_view.getAsArrayBufferView().View(); |
| 20 InitWithData(array_buffer_view->BaseAddress(), | 20 InitWithData(array_buffer_view->BaseAddress(), |
| 21 array_buffer_view->byteLength()); | 21 array_buffer_view->byteLength()); |
| 22 } else if (array_buffer_or_view.isNull() && | 22 } else if (array_buffer_or_view.isNull() && |
| 23 option == kAllowNullPointToNullWithZeroSize) { | 23 option == kAllowNullPointToNullWithZeroSize) { |
| 24 InitWithData(nullptr, 0); | 24 InitWithData(nullptr, 0); |
| 25 } // Otherwise, leave the obejct as null. | 25 } // Otherwise, leave the obejct as null. |
| 26 } | 26 } |
| 27 | 27 |
| 28 } // namespace blink | 28 } // namespace blink |
| OLD | NEW |