Title: [206638] trunk/Source
Revision
206638
Author
[email protected]
Date
2016-09-30 09:41:20 -0700 (Fri, 30 Sep 2016)

Log Message

Add a way to go from a RefPtr<T> to Ref<const T>
https://bugs.webkit.org/show_bug.cgi?id=162683

Patch by Youenn Fablet <[email protected]> on 2016-09-30
Reviewed by Alex Christensen.

Source/WebCore:

No change of behavior.

* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::extract):

Source/WTF:

* wtf/RefPtr.h:
(WTF::RefPtr::releaseConstNonNull): Added.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (206637 => 206638)


--- trunk/Source/WTF/ChangeLog	2016-09-30 16:18:25 UTC (rev 206637)
+++ trunk/Source/WTF/ChangeLog	2016-09-30 16:41:20 UTC (rev 206638)
@@ -1,3 +1,13 @@
+2016-09-30  Youenn Fablet  <[email protected]>
+
+        Add a way to go from a RefPtr<T> to Ref<const T>
+        https://bugs.webkit.org/show_bug.cgi?id=162683
+
+        Reviewed by Alex Christensen.
+
+        * wtf/RefPtr.h:
+        (WTF::RefPtr::releaseConstNonNull): Added.
+
 2016-09-29  Mark Lam  <[email protected]>
 
         Re-enable StringView life-cycle checking.

Modified: trunk/Source/WTF/wtf/RefPtr.h (206637 => 206638)


--- trunk/Source/WTF/wtf/RefPtr.h	2016-09-30 16:18:25 UTC (rev 206637)
+++ trunk/Source/WTF/wtf/RefPtr.h	2016-09-30 16:41:20 UTC (rev 206638)
@@ -62,16 +62,17 @@
     ALWAYS_INLINE ~RefPtr() { derefIfNotNull(std::exchange(m_ptr, nullptr)); }
 
     T* get() const { return m_ptr; }
-    
+
     // FIXME: Remove release() and change all call sites to call WTFMove().
     RefPtr<T> release() { RefPtr<T> tmp = adoptRef(m_ptr); m_ptr = nullptr; return tmp; }
     Ref<T> releaseNonNull() { ASSERT(m_ptr); Ref<T> tmp(adoptRef(*m_ptr)); m_ptr = nullptr; return tmp; }
+    Ref<const T> releaseConstNonNull() { ASSERT(m_ptr); Ref<const T> tmp(adoptRef(*m_ptr)); m_ptr = nullptr; return tmp; }
 
     T* leakRef() WARN_UNUSED_RETURN;
 
     T& operator*() const { ASSERT(m_ptr); return *m_ptr; }
     ALWAYS_INLINE T* operator->() const { return m_ptr; }
-    
+
     bool operator!() const { return !m_ptr; }
 
     // This conversion operator allows implicit conversion to bool but not to other integer types.

Modified: trunk/Source/WebCore/ChangeLog (206637 => 206638)


--- trunk/Source/WebCore/ChangeLog	2016-09-30 16:18:25 UTC (rev 206637)
+++ trunk/Source/WebCore/ChangeLog	2016-09-30 16:41:20 UTC (rev 206638)
@@ -1,3 +1,15 @@
+2016-09-30  Youenn Fablet  <[email protected]>
+
+        Add a way to go from a RefPtr<T> to Ref<const T>
+        https://bugs.webkit.org/show_bug.cgi?id=162683
+
+        Reviewed by Alex Christensen.
+
+        No change of behavior.
+
+        * Modules/fetch/FetchBody.cpp:
+        (WebCore::FetchBody::extract):
+
 2016-09-30  Said Abou-Hallawa  <[email protected]>
 
         Unreviewed, fix 32-bit build.

Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (206637 => 206638)


--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2016-09-30 16:18:25 UTC (rev 206637)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2016-09-30 16:41:20 UTC (rev 206638)
@@ -113,12 +113,9 @@
         ASSERT(data);
         return { *data };
     }
-    if (value.inherits(JSC::JSArrayBufferView::info())) {
-        auto data = ""
-        ASSERT(data);
-        // FIXME: We should be able to efficiently get a Ref<const T> from a RefPtr<T>.
-        return { *data };
-    }
+    if (value.inherits(JSC::JSArrayBufferView::info()))
+        return { toArrayBufferView(value).releaseConstNonNull() };
+
     return { };
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to