| 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 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef ScopedPersistent_h | 31 #ifndef ScopedPersistent_h |
| 32 #define ScopedPersistent_h | 32 #define ScopedPersistent_h |
| 33 | 33 |
| 34 #include "wtf/Allocator.h" | 34 #include "wtf/Allocator.h" |
| 35 #include "wtf/Noncopyable.h" | 35 #include "wtf/Noncopyable.h" |
| 36 #include <memory> |
| 36 #include <v8.h> | 37 #include <v8.h> |
| 37 | 38 |
| 38 namespace blink { | 39 namespace blink { |
| 39 | 40 |
| 40 template<typename T> | 41 template<typename T> |
| 41 class ScopedPersistent { | 42 class ScopedPersistent { |
| 42 USING_FAST_MALLOC(ScopedPersistent); | 43 USING_FAST_MALLOC(ScopedPersistent); |
| 43 WTF_MAKE_NONCOPYABLE(ScopedPersistent); | 44 WTF_MAKE_NONCOPYABLE(ScopedPersistent); |
| 44 public: | 45 public: |
| 45 ScopedPersistent() { } | 46 ScopedPersistent() { } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 86 } |
| 86 | 87 |
| 87 bool isEmpty() const { return m_handle.IsEmpty(); } | 88 bool isEmpty() const { return m_handle.IsEmpty(); } |
| 88 bool isWeak() const { return m_handle.IsWeak(); } | 89 bool isWeak() const { return m_handle.IsWeak(); } |
| 89 | 90 |
| 90 void set(v8::Isolate* isolate, v8::Local<T> handle) | 91 void set(v8::Isolate* isolate, v8::Local<T> handle) |
| 91 { | 92 { |
| 92 m_handle.Reset(isolate, handle); | 93 m_handle.Reset(isolate, handle); |
| 93 } | 94 } |
| 94 | 95 |
| 95 // Note: This is clear in the OwnPtr sense, not the v8::Handle sense. | 96 // Note: This is clear in the std::unique_ptr sense, not the v8::Handle sens
e. |
| 96 void clear() | 97 void clear() |
| 97 { | 98 { |
| 98 m_handle.Reset(); | 99 m_handle.Reset(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void setReference(const v8::Persistent<v8::Object>& parent, v8::Isolate* iso
late) | 102 void setReference(const v8::Persistent<v8::Object>& parent, v8::Isolate* iso
late) |
| 102 { | 103 { |
| 103 isolate->SetReference(parent, m_handle); | 104 isolate->SetReference(parent, m_handle); |
| 104 } | 105 } |
| 105 | 106 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 120 } | 121 } |
| 121 | 122 |
| 122 | 123 |
| 123 private: | 124 private: |
| 124 v8::Persistent<T> m_handle; | 125 v8::Persistent<T> m_handle; |
| 125 }; | 126 }; |
| 126 | 127 |
| 127 } // namespace blink | 128 } // namespace blink |
| 128 | 129 |
| 129 #endif // ScopedPersistent_h | 130 #endif // ScopedPersistent_h |
| OLD | NEW |