Title: [126376] trunk/Source/WebCore
Revision
126376
Author
[email protected]
Date
2012-08-22 18:23:12 -0700 (Wed, 22 Aug 2012)

Log Message

[V8] OwnHandle doesn't need to support weak handles
https://bugs.webkit.org/show_bug.cgi?id=94760

Reviewed by Kentaro Hara.

No code uses makeWeak(). We can drop support for it and simplify this
class.

* bindings/v8/OwnHandle.h:
(WebCore):
(OwnHandle):
(WebCore::OwnHandle::OwnHandle):
(WebCore::OwnHandle::~OwnHandle):
(WebCore::OwnHandle::get):
(WebCore::OwnHandle::set):
(WebCore::OwnHandle::clear):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (126375 => 126376)


--- trunk/Source/WebCore/ChangeLog	2012-08-23 01:12:54 UTC (rev 126375)
+++ trunk/Source/WebCore/ChangeLog	2012-08-23 01:23:12 UTC (rev 126376)
@@ -1,3 +1,22 @@
+2012-08-22  Adam Barth  <[email protected]>
+
+        [V8] OwnHandle doesn't need to support weak handles
+        https://bugs.webkit.org/show_bug.cgi?id=94760
+
+        Reviewed by Kentaro Hara.
+
+        No code uses makeWeak(). We can drop support for it and simplify this
+        class.
+
+        * bindings/v8/OwnHandle.h:
+        (WebCore):
+        (OwnHandle):
+        (WebCore::OwnHandle::OwnHandle):
+        (WebCore::OwnHandle::~OwnHandle):
+        (WebCore::OwnHandle::get):
+        (WebCore::OwnHandle::set):
+        (WebCore::OwnHandle::clear):
+
 2012-08-22  Kentaro Hara  <[email protected]>
 
         [V8] Remove V8Proxy from getXPathNSResolver()

Modified: trunk/Source/WebCore/bindings/v8/OwnHandle.h (126375 => 126376)


--- trunk/Source/WebCore/bindings/v8/OwnHandle.h	2012-08-23 01:12:54 UTC (rev 126375)
+++ trunk/Source/WebCore/bindings/v8/OwnHandle.h	2012-08-23 01:23:12 UTC (rev 126376)
@@ -35,46 +35,42 @@
 
 namespace WebCore {
 
-    template<typename T>
-    class OwnHandle {
-    public:
-        OwnHandle() { }
-        explicit OwnHandle(v8::Handle<T> handle) : m_handle(v8::Persistent<T>::New(handle)) { }
-        ~OwnHandle() { clear(); }
+template<typename T>
+class OwnHandle {
+public:
+    OwnHandle() { }
 
-        v8::Handle<T> get() const { return m_handle; }
-        void set(v8::Handle<T> handle) { clear(); m_handle = v8::Persistent<T>::New(handle); }
+    explicit OwnHandle(v8::Handle<T> handle)
+        : m_handle(v8::Persistent<T>::New(handle))
+    {
+    }
 
-        // Note: This is clear in the OwnPtr sense, not the v8::Handle sense.
-        void clear()
-        {
-            if (m_handle.IsEmpty())
-                return;
-            if (m_handle.IsWeak())
-                m_handle.ClearWeak();
-            m_handle.Dispose();
-            m_handle.Clear();
-        }
+    ~OwnHandle()
+    {
+        clear();
+    }
 
-        // Make the underlying handle weak.  The client doesn't get a callback,
-        // we just make the handle empty.
-        void makeWeak()
-        {
-            if (m_handle.IsEmpty())
-                return;
-            m_handle.MakeWeak(this, &OwnHandle<T>::weakCallback);
-        }
+    v8::Handle<T> get() const { return m_handle; }
 
-    private:
-        static void weakCallback(v8::Persistent<v8::Value> object, void* ownHandle)
-        {
-            OwnHandle<T>* handle = static_cast<OwnHandle<T>*>(ownHandle);
-            handle->clear();
-        }
+    void set(v8::Handle<T> handle)
+    {
+        clear();
+        m_handle = v8::Persistent<T>::New(handle);
+    }
 
-        v8::Persistent<T> m_handle;
-    };
+    // Note: This is clear in the OwnPtr sense, not the v8::Handle sense.
+    void clear()
+    {
+        if (m_handle.IsEmpty())
+            return;
+        m_handle.Dispose();
+        m_handle.Clear();
+    }
 
+private:
+    v8::Persistent<T> m_handle;
+};
+
 } // namespace WebCore
 
 #endif // OwnHandle_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to