| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef TraceWrapperV8Reference_h | 5 #ifndef TraceWrapperV8Reference_h |
| 6 #define TraceWrapperV8Reference_h | 6 #define TraceWrapperV8Reference_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptWrappableVisitor.h" | 8 #include "bindings/core/v8/ScriptWrappableVisitor.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 ALWAYS_INLINE v8::Local<T> newLocal(v8::Isolate* isolate) const { | 49 ALWAYS_INLINE v8::Local<T> newLocal(v8::Isolate* isolate) const { |
| 50 return v8::Local<T>::New(isolate, m_handle); | 50 return v8::Local<T>::New(isolate, m_handle); |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool isEmpty() const { return m_handle.IsEmpty(); } | 53 bool isEmpty() const { return m_handle.IsEmpty(); } |
| 54 void clear() { m_handle.Reset(); } | 54 void clear() { m_handle.Reset(); } |
| 55 ALWAYS_INLINE v8::Persistent<T>& get() { return m_handle; } | 55 ALWAYS_INLINE v8::Persistent<T>& get() { return m_handle; } |
| 56 | 56 |
| 57 void setReference(const v8::Persistent<v8::Object>& parent, | |
| 58 v8::Isolate* isolate) { | |
| 59 isolate->SetReference(parent, m_handle); | |
| 60 } | |
| 61 | |
| 62 template <typename S> | 57 template <typename S> |
| 63 const TraceWrapperV8Reference<S>& cast() const { | 58 const TraceWrapperV8Reference<S>& cast() const { |
| 64 return reinterpret_cast<const TraceWrapperV8Reference<S>&>( | 59 return reinterpret_cast<const TraceWrapperV8Reference<S>&>( |
| 65 const_cast<const TraceWrapperV8Reference<T>&>(*this)); | 60 const_cast<const TraceWrapperV8Reference<T>&>(*this)); |
| 66 } | 61 } |
| 67 | 62 |
| 68 private: | 63 private: |
| 69 inline void internalSet(v8::Isolate* isolate, v8::Local<T> handle) { | 64 inline void internalSet(v8::Isolate* isolate, v8::Local<T> handle) { |
| 70 m_handle.Reset(isolate, handle); | 65 m_handle.Reset(isolate, handle); |
| 71 ScriptWrappableVisitor::writeBarrier(m_parent, &cast<v8::Value>()); | 66 ScriptWrappableVisitor::writeBarrier(m_parent, &cast<v8::Value>()); |
| 72 } | 67 } |
| 73 | 68 |
| 74 v8::Persistent<T> m_handle; | 69 v8::Persistent<T> m_handle; |
| 75 void* m_parent; | 70 void* m_parent; |
| 76 }; | 71 }; |
| 77 | 72 |
| 78 } // namespace blink | 73 } // namespace blink |
| 79 | 74 |
| 80 #endif // TraceWrapperV8Reference_h | 75 #endif // TraceWrapperV8Reference_h |
| OLD | NEW |