Title: [167164] trunk/Source/WebKit2
- Revision
- 167164
- Author
- jer.no...@apple.com
- Date
- 2014-04-11 15:36:37 -0700 (Fri, 11 Apr 2014)
Log Message
[WK2] Dispatch to main thread's run loop to handle cookie requests.
https://bugs.webkit.org/show_bug.cgi?id=131524
Reviewed by Brady Eidson.
When using synchronous network APIs from the main thread (e.g., -[NSImage
initWithContentsOfURL:]) our cookie shim would attempt to dispath_async
to the main thread to handle the cookie request, and block against the original
request. CFNetwork is still servicing the run loop however, so rather than
dispatch_async to the main queue, use the RunLoop to dispatch to the main thread.
* Shared/mac/CookieStorageShim.mm:
(-[WKNSURLSessionLocal _getCookieHeadersForTask:completionHandler:]):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (167163 => 167164)
--- trunk/Source/WebKit2/ChangeLog 2014-04-11 22:29:32 UTC (rev 167163)
+++ trunk/Source/WebKit2/ChangeLog 2014-04-11 22:36:37 UTC (rev 167164)
@@ -1,3 +1,19 @@
+2014-04-10 Jer Noble <jer.no...@apple.com>
+
+ [WK2] Dispatch to main thread's run loop to handle cookie requests.
+ https://bugs.webkit.org/show_bug.cgi?id=131524
+
+ Reviewed by Brady Eidson.
+
+ When using synchronous network APIs from the main thread (e.g., -[NSImage
+ initWithContentsOfURL:]) our cookie shim would attempt to dispath_async
+ to the main thread to handle the cookie request, and block against the original
+ request. CFNetwork is still servicing the run loop however, so rather than
+ dispatch_async to the main queue, use the RunLoop to dispatch to the main thread.
+
+ * Shared/mac/CookieStorageShim.mm:
+ (-[WKNSURLSessionLocal _getCookieHeadersForTask:completionHandler:]):
+
2014-04-11 Tim Horton <timothy_hor...@apple.com>
Make the stylebot happier with r167154.
Modified: trunk/Source/WebKit2/Shared/mac/CookieStorageShim.mm (167163 => 167164)
--- trunk/Source/WebKit2/Shared/mac/CookieStorageShim.mm 2014-04-11 22:29:32 UTC (rev 167163)
+++ trunk/Source/WebKit2/Shared/mac/CookieStorageShim.mm 2014-04-11 22:36:37 UTC (rev 167164)
@@ -39,6 +39,7 @@
#include <dlfcn.h>
#include <wtf/MainThread.h>
#include <wtf/RetainPtr.h>
+#include <wtf/RunLoop.h>
#include <wtf/text/WTFString.h>
typedef const struct _CFURLRequest* CFURLRequestRef;
@@ -120,8 +121,9 @@
if (!completionHandler)
return;
- dispatch_async(dispatch_get_main_queue(), ^{
- completionHandler(WebKit::webKitCookieStorageCopyRequestHeaderFieldsForURL(nullptr, (CFURLRef)[[task currentRequest] URL]));
+ RetainPtr<NSURLSessionTask> strongTask = task;
+ RunLoop::main().dispatch([strongTask, completionHandler]{
+ completionHandler(WebKit::webKitCookieStorageCopyRequestHeaderFieldsForURL(nullptr, (CFURLRef)[[strongTask currentRequest] URL]));
});
}
#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes