From 3627acd8d97682fd458d2939c6665e5582c89b74 Mon Sep 17 00:00:00 2001 From: "zandobersek@gmail.com" Date: Tue, 5 Nov 2013 10:48:57 +0000 Subject: [PATCH] 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): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158661 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 18 ++++++++++++++++ Source/WebCore/fileapi/ThreadableBlobRegistry.cpp | 25 ++++++++--------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 913c81d..c4a730e 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2013-11-05 Zan Dobersek + + 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 [CSS] Enable css-image-orientation on EFL and GTK ports. diff --git a/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp b/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp index 3cd53cb..bbc389b 100644 --- a/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp +++ b/Source/WebCore/fileapi/ThreadableBlobRegistry.cpp @@ -29,7 +29,6 @@ */ #include "config.h" - #include "ThreadableBlobRegistry.h" #include "BlobData.h" @@ -83,7 +82,7 @@ static ThreadSpecific& originMap() static void registerBlobURLTask(void* context) { - OwnPtr blobRegistryContext = adoptPtr(static_cast(context)); + std::unique_ptr blobRegistryContext(static_cast(context)); blobRegistry().registerBlobURL(blobRegistryContext->url, std::move(blobRegistryContext->blobData)); } @@ -91,15 +90,13 @@ void ThreadableBlobRegistry::registerBlobURL(const URL& url, std::unique_ptr context = adoptPtr(new BlobRegistryContext(url, std::move(blobData))); - callOnMainThread(®isterBlobURLTask, context.leakPtr()); - } + else + callOnMainThread(®isterBlobURLTask, new BlobRegistryContext(url, std::move(blobData))); } static void registerBlobURLFromTask(void* context) { - OwnPtr blobRegistryContext = adoptPtr(static_cast(context)); + std::unique_ptr blobRegistryContext(static_cast(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 context = adoptPtr(new BlobRegistryContext(url, srcURL)); - callOnMainThread(®isterBlobURLFromTask, context.leakPtr()); - } + else + callOnMainThread(®isterBlobURLFromTask, new BlobRegistryContext(url, srcURL)); } static void unregisterBlobURLTask(void* context) { - OwnPtr blobRegistryContext = adoptPtr(static_cast(context)); + std::unique_ptr blobRegistryContext(static_cast(context)); blobRegistry().unregisterBlobURL(blobRegistryContext->url); } @@ -130,10 +125,8 @@ void ThreadableBlobRegistry::unregisterBlobURL(const URL& url) if (isMainThread()) blobRegistry().unregisterBlobURL(url); - else { - OwnPtr context = adoptPtr(new BlobRegistryContext(url)); - callOnMainThread(&unregisterBlobURLTask, context.leakPtr()); - } + else + callOnMainThread(&unregisterBlobURLTask, new BlobRegistryContext(url)); } PassRefPtr ThreadableBlobRegistry::getCachedOrigin(const URL& url) -- 1.8.3.1