Main thread tasks in ThreadableBlobRegistry should use std::unique_ptr
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Nov 2013 10:48:57 +0000 (10:48 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Nov 2013 10:48:57 +0000 (10:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=122946

Reviewed by Darin Adler.

The new BlobRegistryContext objects don't have to be adopted into OwnPtr and then have OwnPtr's leaked pointer
passed into the WTF::callOnMainThread call - the pointer to the new heap-allocated object is passed in directly,
with the object ending up being managed by std::unique_ptr in the designated main thread task.

* fileapi/ThreadableBlobRegistry.cpp:
(WebCore::registerBlobURLTask):
(WebCore::ThreadableBlobRegistry::registerBlobURL):
(WebCore::registerBlobURLFromTask):
(WebCore::unregisterBlobURLTask):
(WebCore::ThreadableBlobRegistry::unregisterBlobURL):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158661 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/fileapi/ThreadableBlobRegistry.cpp

index 913c81d..c4a730e 100644 (file)
@@ -1,3 +1,21 @@
+2013-11-05  Zan Dobersek  <zdobersek@igalia.com>
+
+        Main thread tasks in ThreadableBlobRegistry should use std::unique_ptr
+        https://bugs.webkit.org/show_bug.cgi?id=122946
+
+        Reviewed by Darin Adler.
+
+        The new BlobRegistryContext objects don't have to be adopted into OwnPtr and then have OwnPtr's leaked pointer
+        passed into the WTF::callOnMainThread call - the pointer to the new heap-allocated object is passed in directly,
+        with the object ending up being managed by std::unique_ptr in the designated main thread task.
+
+        * fileapi/ThreadableBlobRegistry.cpp:
+        (WebCore::registerBlobURLTask):
+        (WebCore::ThreadableBlobRegistry::registerBlobURL):
+        (WebCore::registerBlobURLFromTask):
+        (WebCore::unregisterBlobURLTask):
+        (WebCore::ThreadableBlobRegistry::unregisterBlobURL):
+
 2013-11-05  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         [CSS] Enable css-image-orientation on EFL and GTK ports.
index 3cd53cb..bbc389b 100644 (file)
@@ -29,7 +29,6 @@
  */
 
 #include "config.h"
-
 #include "ThreadableBlobRegistry.h"
 
 #include "BlobData.h"
@@ -83,7 +82,7 @@ static ThreadSpecific<BlobUrlOriginMap>& originMap()
 
 static void registerBlobURLTask(void* context)
 {
-    OwnPtr<BlobRegistryContext> blobRegistryContext = adoptPtr(static_cast<BlobRegistryContext*>(context));
+    std::unique_ptr<BlobRegistryContext> blobRegistryContext(static_cast<BlobRegistryContext*>(context));
     blobRegistry().registerBlobURL(blobRegistryContext->url, std::move(blobRegistryContext->blobData));
 }
 
@@ -91,15 +90,13 @@ void ThreadableBlobRegistry::registerBlobURL(const URL& url, std::unique_ptr<Blo
 {
     if (isMainThread())
         blobRegistry().registerBlobURL(url, std::move(blobData));
-    else {
-        OwnPtr<BlobRegistryContext> context = adoptPtr(new BlobRegistryContext(url, std::move(blobData)));
-        callOnMainThread(&registerBlobURLTask, context.leakPtr());
-    }
+    else
+        callOnMainThread(&registerBlobURLTask, new BlobRegistryContext(url, std::move(blobData)));
 }
 
 static void registerBlobURLFromTask(void* context)
 {
-    OwnPtr<BlobRegistryContext> blobRegistryContext = adoptPtr(static_cast<BlobRegistryContext*>(context));
+    std::unique_ptr<BlobRegistryContext> blobRegistryContext(static_cast<BlobRegistryContext*>(context));
     blobRegistry().registerBlobURL(blobRegistryContext->url, blobRegistryContext->srcURL);
 }
 
@@ -111,15 +108,13 @@ void ThreadableBlobRegistry::registerBlobURL(SecurityOrigin* origin, const URL&
 
     if (isMainThread())
         blobRegistry().registerBlobURL(url, srcURL);
-    else {
-        OwnPtr<BlobRegistryContext> context = adoptPtr(new BlobRegistryContext(url, srcURL));
-        callOnMainThread(&registerBlobURLFromTask, context.leakPtr());
-    }
+    else
+        callOnMainThread(&registerBlobURLFromTask, new BlobRegistryContext(url, srcURL));
 }
 
 static void unregisterBlobURLTask(void* context)
 {
-    OwnPtr<BlobRegistryContext> blobRegistryContext = adoptPtr(static_cast<BlobRegistryContext*>(context));
+    std::unique_ptr<BlobRegistryContext> blobRegistryContext(static_cast<BlobRegistryContext*>(context));
     blobRegistry().unregisterBlobURL(blobRegistryContext->url);
 }
 
@@ -130,10 +125,8 @@ void ThreadableBlobRegistry::unregisterBlobURL(const URL& url)
 
     if (isMainThread())
         blobRegistry().unregisterBlobURL(url);
-    else {
-        OwnPtr<BlobRegistryContext> context = adoptPtr(new BlobRegistryContext(url));
-        callOnMainThread(&unregisterBlobURLTask, context.leakPtr());
-    }
+    else
+        callOnMainThread(&unregisterBlobURLTask, new BlobRegistryContext(url));
 }
 
 PassRefPtr<SecurityOrigin> ThreadableBlobRegistry::getCachedOrigin(const URL& url)