Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: include/v8.h

Issue 260017: Implemented really weak handles. (Closed)
Patch Set: Fix typo. Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/global-handles.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index adb9f431766a6e173b5a9df029c915c756dab9f9..11a3e56cf241fd20bed3c082aff617b21ce41c3e 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -389,16 +389,29 @@ template <class T> class V8EXPORT_INLINE Persistent : public Handle<T> {
*/
inline void MakeWeak(void* parameters, WeakReferenceCallback callback);
- /** Clears the weak reference to this object.*/
+ /**
+ * Similar to the above function except that when the callback is
+ * invoked for a really weak handle the object may have been
+ * collected already. Accessing the object in the callback is not
+ * allowed. The embedder can only use the data that is stored in
+ * the handle itself.
+ */
+ inline void MakeReallyWeak(void* parameters, WeakReferenceCallback callback);
Christian Plesner Hansen 2009/10/06 13:47:21 I think we need to find a more informative name.
+
+ /**
+ * Clears weak status of this handle. Clearing status in weak
+ * callback is not allowed for really weak handles since the object
+ * may have been collected already.
+ */
inline void ClearWeak();
/**
- *Checks if the handle holds the only reference to an object.
+ * Checks if the handle holds the only reference to an object.
*/
inline bool IsNearDeath() const;
/**
- * Returns true if the handle's reference is weak.
+ * Returns true if the handle's reference is weak or really weak.
*/
inline bool IsWeak() const;
@@ -2369,6 +2382,9 @@ class V8EXPORT V8 {
static void MakeWeak(internal::Object** global_handle,
void* data,
WeakReferenceCallback);
+ static void MakeReallyWeak(internal::Object** global_handle,
+ void* data,
+ WeakReferenceCallback);
static void ClearWeak(internal::Object** global_handle);
static bool IsGlobalNearDeath(internal::Object** global_handle);
static bool IsGlobalWeak(internal::Object** global_handle);
@@ -2836,6 +2852,14 @@ void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callback) {
}
template <class T>
+void Persistent<T>::MakeReallyWeak(void* parameters,
+ WeakReferenceCallback callback) {
+ V8::MakeReallyWeak(reinterpret_cast<internal::Object**>(**this),
+ parameters,
+ callback);
+}
+
+template <class T>
void Persistent<T>::ClearWeak() {
V8::ClearWeak(reinterpret_cast<internal::Object**>(**this));
}
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/global-handles.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698