Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 return m_handle == other.m_handle; | 96 return m_handle == other.m_handle; |
| 97 } | 97 } |
| 98 | 98 |
| 99 template <class S> | 99 template <class S> |
| 100 bool operator==(const v8::Local<S> other) const { | 100 bool operator==(const v8::Local<S> other) const { |
| 101 return m_handle == other; | 101 return m_handle == other; |
| 102 } | 102 } |
| 103 | 103 |
| 104 ALWAYS_INLINE v8::Persistent<T>& get() { return m_handle; } | 104 ALWAYS_INLINE v8::Persistent<T>& get() { return m_handle; } |
| 105 | 105 |
| 106 template <typename S> | |
| 107 const ScopedPersistent<S>& cast() const { | |
|
Michael Lippautz
2016/11/07 10:36:13
Dead code.
| |
| 108 return reinterpret_cast<const ScopedPersistent<v8::Object>&>( | |
| 109 const_cast<const ScopedPersistent<T>&>(*this)); | |
| 110 } | |
| 111 | |
| 112 private: | 106 private: |
| 113 v8::Persistent<T> m_handle; | 107 v8::Persistent<T> m_handle; |
| 114 }; | 108 }; |
| 115 | 109 |
| 116 /** | |
| 117 * TraceWrapperV8Reference is used to trace from Blink to V8. | |
| 118 * | |
| 119 * TODO(mlippautz): Once shipped, create a separate type with a more | |
| 120 * appropriate handle type than v8::Persistent. The handle should have regular | |
| 121 * tracing semantics, i.e., only hold strongly on to an object if reached | |
| 122 * through tracing. | |
| 123 */ | |
| 124 template <typename T> | |
| 125 class TraceWrapperV8Reference : public ScopedPersistent<T> { | |
| 126 public: | |
| 127 explicit TraceWrapperV8Reference(void* parent) | |
| 128 : ScopedPersistent<T>(), m_parent(parent) {} | |
| 129 | |
| 130 TraceWrapperV8Reference(v8::Isolate* isolate, | |
| 131 void* parent, | |
| 132 v8::Local<T> handle) | |
| 133 : ScopedPersistent<T>(isolate, handle), m_parent(parent) { | |
| 134 ScriptWrappableVisitor::writeBarrier(m_parent, &cast<v8::Value>()); | |
| 135 } | |
| 136 | |
| 137 void set(v8::Isolate* isolate, v8::Local<T> handle) override { | |
| 138 ScopedPersistent<T>::set(isolate, handle); | |
| 139 ScriptWrappableVisitor::writeBarrier(m_parent, &cast<v8::Value>()); | |
| 140 } | |
| 141 | |
| 142 template <typename S> | |
| 143 const TraceWrapperV8Reference<S>& cast() const { | |
| 144 return reinterpret_cast<const TraceWrapperV8Reference<S>&>( | |
| 145 const_cast<const TraceWrapperV8Reference<T>&>(*this)); | |
| 146 } | |
| 147 | |
| 148 private: | |
| 149 void* m_parent; | |
| 150 }; | |
| 151 | |
| 152 } // namespace blink | 110 } // namespace blink |
| 153 | 111 |
| 154 #endif // ScopedPersistent_h | 112 #endif // ScopedPersistent_h |
| OLD | NEW |