Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: third_party/WebKit/Source/core/dom/DOMDataView.cpp

Issue 1964183004: Revert of Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/DOMDataView.cpp
diff --git a/third_party/WebKit/Source/core/dom/DOMDataView.cpp b/third_party/WebKit/Source/core/dom/DOMDataView.cpp
index b76e0a4b3b020de67612dea5df6a313ba3ff571f..d95163d4cc25f01a63b355a3f5703f48e5b570d8 100644
--- a/third_party/WebKit/Source/core/dom/DOMDataView.cpp
+++ b/third_party/WebKit/Source/core/dom/DOMDataView.cpp
@@ -15,7 +15,7 @@
class DataView final : public ArrayBufferView {
public:
- static PassRefPtr<DataView> create(ArrayBuffer* buffer, unsigned byteOffset, unsigned byteLength)
+ static PassRefPtr<DataView> create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned byteLength)
{
RELEASE_ASSERT(byteOffset <= buffer->byteLength());
CheckedInt<uint32_t> checkedOffset(byteOffset);
@@ -37,7 +37,7 @@
}
private:
- DataView(ArrayBuffer* buffer, unsigned byteOffset, unsigned byteLength)
+ DataView(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned byteLength)
: ArrayBufferView(buffer, byteOffset)
, m_byteLength(byteLength) { }
@@ -46,14 +46,20 @@
} // anonymous namespace
-DOMDataView* DOMDataView::create(DOMArrayBufferBase* buffer, unsigned byteOffset, unsigned byteLength)
+PassRefPtr<DOMDataView> DOMDataView::create(PassRefPtr<DOMArrayBufferBase> prpBuffer, unsigned byteOffset, unsigned byteLength)
{
+ RefPtr<DOMArrayBufferBase> buffer = prpBuffer;
RefPtr<DataView> dataView = DataView::create(buffer->buffer(), byteOffset, byteLength);
- return new DOMDataView(dataView, buffer);
+ return adoptRef(new DOMDataView(dataView.release(), buffer.release()));
}
v8::Local<v8::Object> DOMDataView::wrap(v8::Isolate* isolate, v8::Local<v8::Object> creationContext)
{
+ // It's possible that no one except for the new wrapper owns this object at
+ // this moment, so we have to prevent GC to collect this object until the
+ // object gets associated with the wrapper.
+ RefPtr<DOMDataView> protect(this);
+
DCHECK(!DOMDataStore::containsWrapper(this, isolate));
const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo();
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMDataView.h ('k') | third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698