| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 { | 65 { |
| 66 return v8::Local<T>::New(isolate, m_handle); | 66 return v8::Local<T>::New(isolate, m_handle); |
| 67 } | 67 } |
| 68 | 68 |
| 69 template<typename P> | 69 template<typename P> |
| 70 void setWeak(P* parameters, void (*callback)(const v8::WeakCallbackInfo<P>&)
, v8::WeakCallbackType type = v8::WeakCallbackType::kParameter) | 70 void setWeak(P* parameters, void (*callback)(const v8::WeakCallbackInfo<P>&)
, v8::WeakCallbackType type = v8::WeakCallbackType::kParameter) |
| 71 { | 71 { |
| 72 m_handle.SetWeak(parameters, callback, type); | 72 m_handle.SetWeak(parameters, callback, type); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void setWeak() |
| 76 { |
| 77 m_handle.SetWeak(); |
| 78 } |
| 79 |
| 75 void clearWeak() | 80 void clearWeak() |
| 76 { | 81 { |
| 77 m_handle.template ClearWeak<void>(); | 82 m_handle.template ClearWeak<void>(); |
| 78 } | 83 } |
| 79 | 84 |
| 80 bool isEmpty() const { return m_handle.IsEmpty(); } | 85 bool isEmpty() const { return m_handle.IsEmpty(); } |
| 81 bool isWeak() const { return m_handle.IsWeak(); } | 86 bool isWeak() const { return m_handle.IsWeak(); } |
| 82 | 87 |
| 83 void set(v8::Isolate* isolate, v8::Local<T> handle) | 88 void set(v8::Isolate* isolate, v8::Local<T> handle) |
| 84 { | 89 { |
| 85 m_handle.Reset(isolate, handle); | 90 m_handle.Reset(isolate, handle); |
| 86 } | 91 } |
| 87 | 92 |
| 88 // Note: This is clear in the OwnPtr sense, not the v8::Handle sense. | 93 // Note: This is clear in the OwnPtr sense, not the v8::Handle sense. |
| 89 void clear() | 94 void clear() |
| 90 { | 95 { |
| 91 m_handle.Reset(); | 96 m_handle.Reset(); |
| 92 } | 97 } |
| 93 | 98 |
| 94 void setReference(const v8::Persistent<v8::Object>& parent, v8::Isolate* iso
late) | 99 void setReference(const v8::Persistent<v8::Object>& parent, v8::Isolate* iso
late) const |
| 95 { | 100 { |
| 96 isolate->SetReference(parent, m_handle); | 101 isolate->SetReference(parent, m_handle); |
| 97 } | 102 } |
| 98 | 103 |
| 99 bool operator==(const ScopedPersistent<T>& other) | 104 bool operator==(const ScopedPersistent<T>& other) |
| 100 { | 105 { |
| 101 return m_handle == other.m_handle; | 106 return m_handle == other.m_handle; |
| 102 } | 107 } |
| 103 | 108 |
| 104 template <class S> | 109 template <class S> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 115 { | 120 { |
| 116 return m_handle; | 121 return m_handle; |
| 117 } | 122 } |
| 118 | 123 |
| 119 v8::Persistent<T> m_handle; | 124 v8::Persistent<T> m_handle; |
| 120 }; | 125 }; |
| 121 | 126 |
| 122 } // namespace blink | 127 } // namespace blink |
| 123 | 128 |
| 124 #endif // ScopedPersistent_h | 129 #endif // ScopedPersistent_h |
| OLD | NEW |