| OLD | NEW |
| 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/dom/DOMArrayBuffer.h" | 6 #include "core/dom/DOMSharedArrayBuffer.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/DOMDataStore.h" | 8 #include "bindings/core/v8/DOMDataStore.h" |
| 9 #include "bindings/core/v8/V8DOMWrapper.h" | 9 #include "bindings/core/v8/V8DOMWrapper.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 v8::Local<v8::Object> DOMArrayBuffer::wrap(v8::Isolate* isolate, v8::Local<v8::O
bject> creationContext) | 13 v8::Local<v8::Object> DOMSharedArrayBuffer::wrap(v8::Isolate* isolate, v8::Local
<v8::Object> creationContext) |
| 14 { | 14 { |
| 15 // It's possible that no one except for the new wrapper owns this object at | 15 // It's possible that no one except for the new wrapper owns this object at |
| 16 // this moment, so we have to prevent GC to collect this object until the | 16 // this moment, so we have to prevent GC to collect this object until the |
| 17 // object gets associated with the wrapper. | 17 // object gets associated with the wrapper. |
| 18 RefPtr<DOMArrayBuffer> protect(this); | 18 RefPtr<DOMSharedArrayBuffer> protect(this); |
| 19 | 19 |
| 20 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); | 20 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); |
| 21 | 21 |
| 22 const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo(); | 22 const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo(); |
| 23 v8::Local<v8::Object> wrapper = v8::ArrayBuffer::New(isolate, data(), byteLe
ngth()); | 23 v8::Local<v8::Object> wrapper = v8::SharedArrayBuffer::New(isolate, data(),
byteLength()); |
| 24 // V8::ArrayBuffer::New may run an arbitrary script and it may result in | 24 // V8::SharedArrayBuffer::New may run an arbitrary script and it may result
in |
| 25 // creating a new wrapper and associating it with |this|. If so, the | 25 // creating a new wrapper and associating it with |this|. If so, the |
| 26 // wrapper already created and associated must be used. | 26 // wrapper already created and associated must be used. |
| 27 v8::Local<v8::Object> associatedWrapper = DOMDataStore::getWrapper(this, iso
late); | 27 v8::Local<v8::Object> associatedWrapper = DOMDataStore::getWrapper(this, iso
late); |
| 28 if (UNLIKELY(!associatedWrapper.IsEmpty())) | 28 if (UNLIKELY(!associatedWrapper.IsEmpty())) |
| 29 return associatedWrapper; | 29 return associatedWrapper; |
| 30 | 30 |
| 31 return associateWithWrapper(isolate, wrapperTypeInfo, wrapper); | 31 return associateWithWrapper(isolate, wrapperTypeInfo, wrapper); |
| 32 } | 32 } |
| 33 | 33 |
| 34 v8::Local<v8::Object> DOMArrayBuffer::associateWithWrapper(v8::Isolate* isolate,
const WrapperTypeInfo* wrapperTypeInfo, v8::Local<v8::Object> wrapper) | 34 v8::Local<v8::Object> DOMSharedArrayBuffer::associateWithWrapper(v8::Isolate* is
olate, const WrapperTypeInfo* wrapperTypeInfo, v8::Local<v8::Object> wrapper) |
| 35 { | 35 { |
| 36 // This function does not set a deallocation observer to the underlying | |
| 37 // array buffer. It's a caller's duty. | |
| 38 | |
| 39 return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTypeIn
fo, wrapper); | 36 return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTypeIn
fo, wrapper); |
| 40 } | 37 } |
| 41 | 38 |
| 42 } // namespace blink | 39 } // namespace blink |
| OLD | NEW |