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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, | 57 void setReference(const v8::Persistent<v8::Object>& parent, |
58 v8::Isolate* isolate) { | 58 v8::Isolate* isolate) { |
59 DCHECK(!RuntimeEnabledFeatures::traceWrappablesEnabled()); | |
60 isolate->SetReference(parent, m_handle); | 59 isolate->SetReference(parent, m_handle); |
61 } | 60 } |
62 | 61 |
63 template <typename S> | 62 template <typename S> |
64 const TraceWrapperV8Reference<S>& cast() const { | 63 const TraceWrapperV8Reference<S>& cast() const { |
65 return reinterpret_cast<const TraceWrapperV8Reference<S>&>( | 64 return reinterpret_cast<const TraceWrapperV8Reference<S>&>( |
66 const_cast<const TraceWrapperV8Reference<T>&>(*this)); | 65 const_cast<const TraceWrapperV8Reference<T>&>(*this)); |
67 } | 66 } |
68 | 67 |
69 private: | 68 private: |
70 inline void internalSet(v8::Isolate* isolate, v8::Local<T> handle) { | 69 inline void internalSet(v8::Isolate* isolate, v8::Local<T> handle) { |
71 m_handle.Reset(isolate, handle); | 70 m_handle.Reset(isolate, handle); |
72 ScriptWrappableVisitor::writeBarrier(m_parent, &cast<v8::Value>()); | 71 ScriptWrappableVisitor::writeBarrier(m_parent, &cast<v8::Value>()); |
73 } | 72 } |
74 | 73 |
75 v8::Persistent<T> m_handle; | 74 v8::Persistent<T> m_handle; |
76 void* m_parent; | 75 void* m_parent; |
77 }; | 76 }; |
78 | 77 |
79 } // namespace blink | 78 } // namespace blink |
80 | 79 |
81 #endif // TraceWrapperV8Reference_h | 80 #endif // TraceWrapperV8Reference_h |
OLD | NEW |