| 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> | |
| 37 #include <v8.h> | 36 #include <v8.h> |
| 38 | 37 |
| 39 namespace blink { | 38 namespace blink { |
| 40 | 39 |
| 41 template<typename T> | 40 template<typename T> |
| 42 class ScopedPersistent { | 41 class ScopedPersistent { |
| 43 USING_FAST_MALLOC(ScopedPersistent); | 42 USING_FAST_MALLOC(ScopedPersistent); |
| 44 WTF_MAKE_NONCOPYABLE(ScopedPersistent); | 43 WTF_MAKE_NONCOPYABLE(ScopedPersistent); |
| 45 public: | 44 public: |
| 46 ScopedPersistent() { } | 45 ScopedPersistent() { } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 85 } |
| 87 | 86 |
| 88 bool isEmpty() const { return m_handle.IsEmpty(); } | 87 bool isEmpty() const { return m_handle.IsEmpty(); } |
| 89 bool isWeak() const { return m_handle.IsWeak(); } | 88 bool isWeak() const { return m_handle.IsWeak(); } |
| 90 | 89 |
| 91 void set(v8::Isolate* isolate, v8::Local<T> handle) | 90 void set(v8::Isolate* isolate, v8::Local<T> handle) |
| 92 { | 91 { |
| 93 m_handle.Reset(isolate, handle); | 92 m_handle.Reset(isolate, handle); |
| 94 } | 93 } |
| 95 | 94 |
| 96 // Note: This is clear in the std::unique_ptr sense, not the v8::Handle sens
e. | 95 // Note: This is clear in the OwnPtr sense, not the v8::Handle sense. |
| 97 void clear() | 96 void clear() |
| 98 { | 97 { |
| 99 m_handle.Reset(); | 98 m_handle.Reset(); |
| 100 } | 99 } |
| 101 | 100 |
| 102 void setReference(const v8::Persistent<v8::Object>& parent, v8::Isolate* iso
late) | 101 void setReference(const v8::Persistent<v8::Object>& parent, v8::Isolate* iso
late) |
| 103 { | 102 { |
| 104 isolate->SetReference(parent, m_handle); | 103 isolate->SetReference(parent, m_handle); |
| 105 } | 104 } |
| 106 | 105 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 121 } | 120 } |
| 122 | 121 |
| 123 | 122 |
| 124 private: | 123 private: |
| 125 v8::Persistent<T> m_handle; | 124 v8::Persistent<T> m_handle; |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 } // namespace blink | 127 } // namespace blink |
| 129 | 128 |
| 130 #endif // ScopedPersistent_h | 129 #endif // ScopedPersistent_h |
| OLD | NEW |