Title: [154086] trunk/Source/WebCore
- Revision
- 154086
- Author
- [email protected]
- Date
- 2013-08-14 17:45:01 -0700 (Wed, 14 Aug 2013)
Log Message
<https://webkit.org/b/119810> [Mac] No AutoreleasePool leaks when dragging image out of WebView
Reviewed by Dan Bernstein.
This code was just running a block of code asynchronously using a
pthread. Convert this to use a dispatch block, which does provide
an autorelease pool so there are no leaks and ends up much simpler.
* platform/mac/FileSystemMac.mm:
(WebCore::setMetadataURL):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (154085 => 154086)
--- trunk/Source/WebCore/ChangeLog 2013-08-15 00:43:19 UTC (rev 154085)
+++ trunk/Source/WebCore/ChangeLog 2013-08-15 00:45:01 UTC (rev 154086)
@@ -1,3 +1,16 @@
+2013-08-14 Joseph Pecoraro <[email protected]>
+
+ <https://webkit.org/b/119810> [Mac] No AutoreleasePool leaks when dragging image out of WebView
+
+ Reviewed by Dan Bernstein.
+
+ This code was just running a block of code asynchronously using a
+ pthread. Convert this to use a dispatch block, which does provide
+ an autorelease pool so there are no leaks and ends up much simpler.
+
+ * platform/mac/FileSystemMac.mm:
+ (WebCore::setMetadataURL):
+
2013-08-14 Tim Horton <[email protected]>
Un-inline dataLog dumpers for IntSize and IntPoint
Modified: trunk/Source/WebCore/platform/mac/FileSystemMac.mm (154085 => 154086)
--- trunk/Source/WebCore/platform/mac/FileSystemMac.mm 2013-08-15 00:43:19 UTC (rev 154085)
+++ trunk/Source/WebCore/platform/mac/FileSystemMac.mm 2013-08-15 00:45:01 UTC (rev 154086)
@@ -67,45 +67,19 @@
return String::fromUTF8(temporaryFilePath.data());
}
-typedef struct MetaDataInfo
-{
- String URLString;
- String referrer;
- String path;
-} MetaDataInfo;
-
-static void* setMetaData(void* context)
-{
- MetaDataInfo *info = (MetaDataInfo *)context;
- wkSetMetadataURL((NSString *)info->URLString, (NSString *)info->referrer, (NSString *)String::fromUTF8(fileSystemRepresentation(info->path).data()));
-
- delete info;
-
- return 0;
-}
-
void setMetadataURL(String& URLString, const String& referrer, const String& path)
{
NSURL *URL = "" nil);
if (URL)
URLString = userVisibleString(URLByRemovingUserInfo(URL));
-
- // Spawn a background thread for WKSetMetadataURL because this function will not return until mds has
- // journaled the data we're're trying to set. Depending on what other I/O is going on, it can take some
- // time.
- pthread_t tid;
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-
- MetaDataInfo *info = new MetaDataInfo;
-
- info->URLString = URLString;
- info->referrer = referrer;
- info->path = path;
-
- pthread_create(&tid, &attr, setMetaData, info);
- pthread_attr_destroy(&attr);
+
+ // Call WKSetMetadataURL on a background queue because it can take some time.
+ NSString *URLStringCopy = URLString;
+ NSString *referrerCopy = referrer;
+ NSString *pathCopy = path;
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ wkSetMetadataURL(URLStringCopy, referrerCopy, [NSString stringWithUTF8String:[pathCopy fileSystemRepresentation]]);
+ });
}
#if !PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes