diff options
author | dcarney <dcarney@chromium.org> | 2015-04-22 02:55:42 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-22 09:55:53 +0000 |
commit | 99ade908da2443a531001afafea4a72fb7e755bc (patch) | |
tree | d7c6c13542a03ed7cdc8355e3d67adce5d5e8f18 /gin/array_buffer.cc | |
parent | 79e175cc0b41e7d960dffc5e2bd350e701697ac3 (diff) | |
download | chromium_src-99ade908da2443a531001afafea4a72fb7e755bc.zip chromium_src-99ade908da2443a531001afafea4a72fb7e755bc.tar.gz chromium_src-99ade908da2443a531001afafea4a72fb7e755bc.tar.bz2 |
convert gin to use phantom weak callbacks
the old style callbacks are going away
BUG=
Review URL: https://codereview.chromium.org/1102513002
Cr-Commit-Position: refs/heads/master@{#326259}
Diffstat (limited to 'gin/array_buffer.cc')
-rw-r--r-- | gin/array_buffer.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/gin/array_buffer.cc b/gin/array_buffer.cc index d592b27..dba7763 100644 --- a/gin/array_buffer.cc +++ b/gin/array_buffer.cc @@ -73,10 +73,10 @@ class ArrayBuffer::Private : public base::RefCounted<ArrayBuffer::Private> { Private(v8::Isolate* isolate, v8::Handle<v8::ArrayBuffer> array); ~Private(); - static void WeakCallback( - const v8::WeakCallbackData<v8::ArrayBuffer, Private>& data); + static void FirstWeakCallback(const v8::WeakCallbackInfo<Private>& data); + static void SecondWeakCallback(const v8::WeakCallbackInfo<Private>& data); - v8::Persistent<v8::ArrayBuffer> array_buffer_; + v8::Global<v8::ArrayBuffer> array_buffer_; scoped_refptr<Private> self_reference_; v8::Isolate* isolate_; void* buffer_; @@ -108,18 +108,25 @@ ArrayBuffer::Private::Private(v8::Isolate* isolate, &g_array_buffer_wrapper_info); array->SetAlignedPointerInInternalField(kEncodedValueIndex, this); - self_reference_ = this; // Cleared in WeakCallback. - array_buffer_.SetWeak(this, WeakCallback); + self_reference_ = this; // Cleared in SecondWeakCallback. + array_buffer_.SetWeak(this, FirstWeakCallback, + v8::WeakCallbackType::kParameter); } ArrayBuffer::Private::~Private() { PerIsolateData::From(isolate_)->allocator()->Free(buffer_, length_); } -void ArrayBuffer::Private::WeakCallback( - const v8::WeakCallbackData<v8::ArrayBuffer, Private>& data) { +void ArrayBuffer::Private::FirstWeakCallback( + const v8::WeakCallbackInfo<Private>& data) { Private* parameter = data.GetParameter(); parameter->array_buffer_.Reset(); + data.SetSecondPassCallback(SecondWeakCallback); +} + +void ArrayBuffer::Private::SecondWeakCallback( + const v8::WeakCallbackInfo<Private>& data) { + Private* parameter = data.GetParameter(); parameter->self_reference_ = NULL; } |