Changeset 167164 in webkit


Ignore:
Timestamp:
Apr 11, 2014 3:36:37 PM (10 years ago)
Author:
jer.noble@apple.com
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:]):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r167155 r167164  
     12014-04-10  Jer Noble  <jer.noble@apple.com>
     2
     3        [WK2] Dispatch to main thread's run loop to handle cookie requests.
     4        https://bugs.webkit.org/show_bug.cgi?id=131524
     5
     6        Reviewed by Brady Eidson.
     7
     8        When using synchronous network APIs from the main thread (e.g., -[NSImage
     9        initWithContentsOfURL:]) our cookie shim would attempt to dispath_async
     10        to the main thread to handle the cookie request, and block against the original
     11        request. CFNetwork is still servicing the run loop however, so rather than
     12        dispatch_async to the main queue, use the RunLoop to dispatch to the main thread.
     13
     14        * Shared/mac/CookieStorageShim.mm:
     15        (-[WKNSURLSessionLocal _getCookieHeadersForTask:completionHandler:]):
     16
    1172014-04-11  Tim Horton  <timothy_horton@apple.com>
    218
  • trunk/Source/WebKit2/Shared/mac/CookieStorageShim.mm

    r166940 r167164  
    4040#include <wtf/MainThread.h>
    4141#include <wtf/RetainPtr.h>
     42#include <wtf/RunLoop.h>
    4243#include <wtf/text/WTFString.h>
    4344
     
    121122        return;
    122123
    123     dispatch_async(dispatch_get_main_queue(), ^{
    124         completionHandler(WebKit::webKitCookieStorageCopyRequestHeaderFieldsForURL(nullptr, (CFURLRef)[[task currentRequest] URL]));
     124    RetainPtr<NSURLSessionTask> strongTask = task;
     125    RunLoop::main().dispatch([strongTask, completionHandler]{
     126        completionHandler(WebKit::webKitCookieStorageCopyRequestHeaderFieldsForURL(nullptr, (CFURLRef)[[strongTask currentRequest] URL]));
    125127    });
    126128}
Note: See TracChangeset for help on using the changeset viewer.