Changeset 272636 in webkit


Ignore:
Timestamp:
Feb 9, 2021, 9:21:11 PM (4 years ago)
Author:
achristensen@apple.com
Message:

Use CompletionHandler instead of DataCallback
https://bugs.webkit.org/show_bug.cgi?id=221639

Reviewed by Chris Dumez.

  • UIProcess/API/C/WKFrame.cpp:

(WKFrameGetMainResourceData):
(WKFrameGetResourceData):
(WKFrameGetWebArchive):

  • UIProcess/API/C/WKPage.cpp:

(WKPageGetSelectionAsWebArchiveData):
(WKPageDrawPagesToPDF):

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView createWebArchiveDataWithCompletionHandler:]):
(-[WKWebView _getMainResourceDataWithCompletionHandler:]):

  • UIProcess/WebFrameProxy.cpp:

(WebKit::WebFrameProxy::getWebArchive):
(WebKit::WebFrameProxy::getMainResourceData):
(WebKit::WebFrameProxy::getResourceData):

  • UIProcess/WebFrameProxy.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::CompletionHandler<void):
(WebKit::WebPageProxy::getContentsAsMHTMLData):
(WebKit::WebPageProxy::getSelectionAsWebArchiveData):
(WebKit::WebPageProxy::getMainResourceDataOfFrame):
(WebKit::WebPageProxy::getResourceDataFromFrame):
(WebKit::WebPageProxy::getWebArchiveOfFrame):
(WebKit::WebPageProxy::drawPagesToPDF):
(WebKit::WebPageProxy::dataCallback): Deleted.

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/mac/WKPrintingView.mm:

(-[WKPrintingView _preparePDFDataForPrintingOnSecondaryThread]):

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::getContentsAsMHTMLData):
(WebKit::WebPage::getSelectionAsWebArchiveData):
(WebKit::WebPage::getMainResourceDataOfFrame):
(WebKit::WebPage::getResourceDataFromFrame):
(WebKit::WebPage::getWebArchiveOfFrame):
(WebKit::WebPage::drawPagesToPDF):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
Location:
trunk/Source/WebKit
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r272635 r272636  
     12021-02-09  Alex Christensen  <achristensen@webkit.org>
     2
     3        Use CompletionHandler instead of DataCallback
     4        https://bugs.webkit.org/show_bug.cgi?id=221639
     5
     6        Reviewed by Chris Dumez.
     7
     8        * UIProcess/API/C/WKFrame.cpp:
     9        (WKFrameGetMainResourceData):
     10        (WKFrameGetResourceData):
     11        (WKFrameGetWebArchive):
     12        * UIProcess/API/C/WKPage.cpp:
     13        (WKPageGetSelectionAsWebArchiveData):
     14        (WKPageDrawPagesToPDF):
     15        * UIProcess/API/Cocoa/WKWebView.mm:
     16        (-[WKWebView createWebArchiveDataWithCompletionHandler:]):
     17        (-[WKWebView _getMainResourceDataWithCompletionHandler:]):
     18        * UIProcess/WebFrameProxy.cpp:
     19        (WebKit::WebFrameProxy::getWebArchive):
     20        (WebKit::WebFrameProxy::getMainResourceData):
     21        (WebKit::WebFrameProxy::getResourceData):
     22        * UIProcess/WebFrameProxy.h:
     23        * UIProcess/WebPageProxy.cpp:
     24        (WebKit::CompletionHandler<void):
     25        (WebKit::WebPageProxy::getContentsAsMHTMLData):
     26        (WebKit::WebPageProxy::getSelectionAsWebArchiveData):
     27        (WebKit::WebPageProxy::getMainResourceDataOfFrame):
     28        (WebKit::WebPageProxy::getResourceDataFromFrame):
     29        (WebKit::WebPageProxy::getWebArchiveOfFrame):
     30        (WebKit::WebPageProxy::drawPagesToPDF):
     31        (WebKit::WebPageProxy::dataCallback): Deleted.
     32        * UIProcess/WebPageProxy.h:
     33        * UIProcess/WebPageProxy.messages.in:
     34        * UIProcess/mac/WKPrintingView.mm:
     35        (-[WKPrintingView _preparePDFDataForPrintingOnSecondaryThread]):
     36        * WebProcess/WebPage/WebPage.cpp:
     37        (WebKit::WebPage::getContentsAsMHTMLData):
     38        (WebKit::WebPage::getSelectionAsWebArchiveData):
     39        (WebKit::WebPage::getMainResourceDataOfFrame):
     40        (WebKit::WebPage::getResourceDataFromFrame):
     41        (WebKit::WebPage::getWebArchiveOfFrame):
     42        (WebKit::WebPage::drawPagesToPDF):
     43        * WebProcess/WebPage/WebPage.h:
     44        * WebProcess/WebPage/WebPage.messages.in:
     45
    1462021-02-09  Alex Christensen  <achristensen@webkit.org>
    247
  • trunk/Source/WebKit/UIProcess/API/C/WKFrame.cpp

    r261586 r272636  
    140140void WKFrameGetMainResourceData(WKFrameRef frameRef, WKFrameGetResourceDataFunction callback, void* context)
    141141{
    142     toImpl(frameRef)->getMainResourceData(toGenericCallbackFunction(context, callback));
     142    toImpl(frameRef)->getMainResourceData([context, callback] (API::Data* data) {
     143        callback(toAPI(data), nullptr, context);
     144    });
    143145}
    144146
    145147void WKFrameGetResourceData(WKFrameRef frameRef, WKURLRef resourceURL, WKFrameGetResourceDataFunction callback, void* context)
    146148{
    147     toImpl(frameRef)->getResourceData(toImpl(resourceURL), toGenericCallbackFunction(context, callback));
     149    toImpl(frameRef)->getResourceData(toImpl(resourceURL), [context, callback] (API::Data* data) {
     150        callback(toAPI(data), nullptr, context);
     151    });
    148152}
    149153
    150154void WKFrameGetWebArchive(WKFrameRef frameRef, WKFrameGetWebArchiveFunction callback, void* context)
    151155{
    152     toImpl(frameRef)->getWebArchive(toGenericCallbackFunction(context, callback));
     156    toImpl(frameRef)->getWebArchive([context, callback] (API::Data* data) {
     157        callback(toAPI(data), nullptr, context);
     158    });
    153159}
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r272606 r272636  
    25692569void WKPageGetSelectionAsWebArchiveData(WKPageRef pageRef, void* context, WKPageGetSelectionAsWebArchiveDataFunction callback)
    25702570{
    2571     toImpl(pageRef)->getSelectionAsWebArchiveData(toGenericCallbackFunction(context, callback));
     2571    toImpl(pageRef)->getSelectionAsWebArchiveData([context, callback] (API::Data* data) {
     2572        callback(toAPI(data), nullptr, context);
     2573    });
    25722574}
    25732575
     
    25752577{
    25762578#if ENABLE(MHTML)
    2577     toImpl(pageRef)->getContentsAsMHTMLData(toGenericCallbackFunction(context, callback));
     2579    toImpl(pageRef)->getContentsAsMHTMLData([context, callback] (API::Data* data) {
     2580        callback(toAPI(data), nullptr, context);
     2581    });
    25782582#else
    25792583    UNUSED_PARAM(pageRef);
     
    26552659void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context)
    26562660{
    2657     toImpl(page)->drawPagesToPDF(toImpl(frame), printInfoFromWKPrintInfo(printInfo), first, count, DataCallback::create(toGenericCallbackFunction(context, callback)));
     2661    toImpl(page)->drawPagesToPDF(toImpl(frame), printInfoFromWKPrintInfo(printInfo), first, count, [context, callback] (API::Data* data) {
     2662        callback(toAPI(data), nullptr, context);
     2663    });
    26582664}
    26592665#endif
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r272629 r272636  
    14791479- (void)createWebArchiveDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler
    14801480{
    1481     auto handler = adoptNS([completionHandler copy]);
    1482 
    1483     _page->getWebArchiveOfFrame(_page->mainFrame(), [handler](API::Data* data, WebKit::CallbackBase::Error error) {
    1484         void (^completionHandlerBlock)(NSData *, NSError *) = (void (^)(NSData *, NSError *))handler.get();
    1485         if (error != WebKit::CallbackBase::Error::None) {
    1486             // FIXME: Pipe a proper error in from the WebPageProxy.
    1487             completionHandlerBlock(nil, [NSError errorWithDomain:WKErrorDomain code:static_cast<int>(error) userInfo:nil]);
    1488         } else
    1489             completionHandlerBlock(wrapper(*data), nil);
     1481    _page->getWebArchiveOfFrame(_page->mainFrame(), [completionHandler = makeBlockPtr(completionHandler)](API::Data* data) {
     1482        completionHandler(wrapper(data), nil);
    14901483    });
    14911484}
     
    25272520- (void)_getMainResourceDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler
    25282521{
    2529     auto handler = adoptNS([completionHandler copy]);
    2530 
    2531     _page->getMainResourceDataOfFrame(_page->mainFrame(), [handler](API::Data* data, WebKit::CallbackBase::Error error) {
    2532         void (^completionHandlerBlock)(NSData *, NSError *) = (void (^)(NSData *, NSError *))handler.get();
    2533         if (error != WebKit::CallbackBase::Error::None) {
    2534             // FIXME: Pipe a proper error in from the WebPageProxy.
    2535             completionHandlerBlock(nil, [NSError errorWithDomain:WKErrorDomain code:static_cast<int>(error) userInfo:nil]);
    2536         } else
    2537             completionHandlerBlock(wrapper(*data), nil);
     2522    _page->getMainResourceDataOfFrame(_page->mainFrame(), [completionHandler = makeBlockPtr(completionHandler)](API::Data* data) {
     2523        completionHandler(wrapper(*data), nil);
    25382524    });
    25392525}
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitWebResource.cpp

    r247510 r272636  
    343343WEBKIT_DEFINE_ASYNC_DATA_STRUCT(ResourceGetDataAsyncData)
    344344
    345 static void resourceDataCallback(API::Data* wkData, CallbackBase::Error error, GTask* task)
    346 {
    347     if (error != CallbackBase::Error::None) {
    348         // This fails when the page is closed or frame is destroyed, so we can just cancel the operation.
    349         g_task_return_new_error(task, G_IO_ERROR, G_IO_ERROR_CANCELLED, _("Operation was cancelled"));
    350         return;
    351     }
     345static void resourceDataCallback(API::Data* wkData, GTask* task)
     346{
    352347    ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task));
    353348    data->webData = wkData;
     
    376371    g_task_set_task_data(task.get(), createResourceGetDataAsyncData(), reinterpret_cast<GDestroyNotify>(destroyResourceGetDataAsyncData));
    377372    if (resource->priv->isMainResource)
    378         resource->priv->frame->getMainResourceData([task = WTFMove(task)](API::Data* data, CallbackBase::Error error) {
    379             resourceDataCallback(data, error, task.get());
     373        resource->priv->frame->getMainResourceData([task = WTFMove(task)](API::Data* data) {
     374            resourceDataCallback(data, task.get());
    380375        });
    381376    else {
    382377        String url = String::fromUTF8(resource->priv->uri.data());
    383         resource->priv->frame->getResourceData(API::URL::create(url).ptr(), [task = WTFMove(task)](API::Data* data, CallbackBase::Error error) {
    384             resourceDataCallback(data, error, task.get());
     378        resource->priv->frame->getResourceData(API::URL::create(url).ptr(), [task = WTFMove(task)](API::Data* data) {
     379            resourceDataCallback(data, task.get());
    385380        });
    386381    }
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp

    r272301 r272636  
    41684168    g_task_set_source_tag(task, reinterpret_cast<gpointer>(webkit_web_view_save));
    41694169    g_task_set_task_data(task, createViewSaveAsyncData(), reinterpret_cast<GDestroyNotify>(destroyViewSaveAsyncData));
    4170     getPage(webView).getContentsAsMHTMLData([task](API::Data* data, WebKit::CallbackBase::Error) {
     4170    getPage(webView).getContentsAsMHTMLData([task](API::Data* data) {
    41714171        getContentsAsMHTMLDataCallback(data, task);
    41724172    });
     
    42334233    g_task_set_task_data(task, data, reinterpret_cast<GDestroyNotify>(destroyViewSaveAsyncData));
    42344234
    4235     getPage(webView).getContentsAsMHTMLData([task](API::Data* data, WebKit::CallbackBase::Error) {
     4235    getPage(webView).getContentsAsMHTMLData([task](API::Data* data) {
    42364236        getContentsAsMHTMLDataCallback(data, task);
    42374237    });
  • trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp

    r261586 r272636  
    204204}
    205205
    206 void WebFrameProxy::getWebArchive(Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    207 {
    208     if (!m_page) {
    209         callbackFunction(nullptr, CallbackBase::Error::Unknown);
    210         return;
    211     }
    212 
    213     m_page->getWebArchiveOfFrame(this, WTFMove(callbackFunction));
    214 }
    215 
    216 void WebFrameProxy::getMainResourceData(Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    217 {
    218     if (!m_page) {
    219         callbackFunction(nullptr, CallbackBase::Error::Unknown);
    220         return;
    221     }
    222 
    223     m_page->getMainResourceDataOfFrame(this, WTFMove(callbackFunction));
    224 }
    225 
    226 void WebFrameProxy::getResourceData(API::URL* resourceURL, Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    227 {
    228     if (!m_page) {
    229         callbackFunction(nullptr, CallbackBase::Error::Unknown);
    230         return;
    231     }
    232 
    233     m_page->getResourceDataFromFrame(this, resourceURL, WTFMove(callbackFunction));
     206void WebFrameProxy::getWebArchive(CompletionHandler<void(API::Data*)>&& callback)
     207{
     208    if (!m_page)
     209        return callback(nullptr);
     210    m_page->getWebArchiveOfFrame(this, WTFMove(callback));
     211}
     212
     213void WebFrameProxy::getMainResourceData(CompletionHandler<void(API::Data*)>&& callback)
     214{
     215    if (!m_page)
     216        return callback(nullptr);
     217    m_page->getMainResourceDataOfFrame(this, WTFMove(callback));
     218}
     219
     220void WebFrameProxy::getResourceData(API::URL* resourceURL, CompletionHandler<void(API::Data*)>&& callback)
     221{
     222    if (!m_page)
     223        return callback(nullptr);
     224    m_page->getResourceDataFromFrame(*this, resourceURL, WTFMove(callback));
    234225}
    235226
  • trunk/Source/WebKit/UIProcess/WebFrameProxy.h

    r261586 r272636  
    104104    bool isDisplayingPDFDocument() const;
    105105
    106     void getWebArchive(Function<void (API::Data*, CallbackBase::Error)>&&);
    107     void getMainResourceData(Function<void (API::Data*, CallbackBase::Error)>&&);
    108     void getResourceData(API::URL*, Function<void (API::Data*, CallbackBase::Error)>&&);
     106    void getWebArchive(CompletionHandler<void(API::Data*)>&&);
     107    void getMainResourceData(CompletionHandler<void(API::Data*)>&&);
     108    void getResourceData(API::URL*, CompletionHandler<void(API::Data*)>&&);
    109109
    110110    void didStartProvisionalLoad(const URL&);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r272635 r272636  
    41544154}
    41554155
     4156static CompletionHandler<void(const IPC::DataReference& data)> toAPIDataCallback(CompletionHandler<void(API::Data*)>&& callback)
     4157{
     4158    return [callback = WTFMove(callback)] (const IPC::DataReference& data) mutable {
     4159        callback(API::Data::create(data).get());
     4160    };
     4161}
     4162
    41564163#if ENABLE(MHTML)
    4157 void WebPageProxy::getContentsAsMHTMLData(Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    4158 {
    4159     if (!hasRunningProcess()) {
    4160         callbackFunction(nullptr, CallbackBase::Error::Unknown);
    4161         return;
    4162     }
    4163 
    4164     auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getContentsAsMHTMLData"_s));
    4165     send(Messages::WebPage::GetContentsAsMHTMLData(callbackID));
     4164void WebPageProxy::getContentsAsMHTMLData(CompletionHandler<void(API::Data*)>&& callback)
     4165{
     4166    sendWithAsyncReply(Messages::WebPage::GetContentsAsMHTMLData(), toAPIDataCallback(WTFMove(callback)));
    41664167}
    41674168#endif
     
    41784179}
    41794180
    4180 void WebPageProxy::getSelectionAsWebArchiveData(Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    4181 {
    4182     if (!hasRunningProcess()) {
    4183         callbackFunction(nullptr, CallbackBase::Error::Unknown);
    4184         return;
    4185     }
    4186    
    4187     auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getSelectionAsWebArchiveData"_s));
    4188     send(Messages::WebPage::GetSelectionAsWebArchiveData(callbackID));
    4189 }
    4190 
    4191 void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    4192 {
    4193     if (!hasRunningProcess() || !frame) {
    4194         callbackFunction(nullptr, CallbackBase::Error::Unknown);
    4195         return;
    4196     }
    4197    
    4198     auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getMainResourceDataOfFrame"_s));
    4199     send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID));
    4200 }
    4201 
    4202 void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, API::URL* resourceURL, Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    4203 {
    4204     if (!hasRunningProcess()) {
    4205         callbackFunction(nullptr, CallbackBase::Error::Unknown);
    4206         return;
    4207     }
    4208    
    4209     auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getResourceDataFromFrame"_s));
    4210     send(Messages::WebPage::GetResourceDataFromFrame(frame->frameID(), resourceURL->string(), callbackID));
    4211 }
    4212 
    4213 void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
    4214 {
    4215     if (!hasRunningProcess()) {
    4216         callbackFunction(nullptr, CallbackBase::Error::Unknown);
    4217         return;
    4218     }
    4219    
    4220     auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getWebArchiveOfFrame"_s));
    4221     send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID));
     4181void WebPageProxy::getSelectionAsWebArchiveData(CompletionHandler<void(API::Data*)>&& callback)
     4182{
     4183    sendWithAsyncReply(Messages::WebPage::GetSelectionAsWebArchiveData(), toAPIDataCallback(WTFMove(callback)));
     4184}
     4185
     4186void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, CompletionHandler<void(API::Data*)>&& callback)
     4187{
     4188    if (!frame)
     4189        return callback(nullptr);
     4190    sendWithAsyncReply(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID()), toAPIDataCallback(WTFMove(callback)));
     4191}
     4192
     4193void WebPageProxy::getResourceDataFromFrame(WebFrameProxy& frame, API::URL* resourceURL, CompletionHandler<void(API::Data*)>&& callback)
     4194{
     4195    sendWithAsyncReply(Messages::WebPage::GetResourceDataFromFrame(frame.frameID(), resourceURL->string()), toAPIDataCallback(WTFMove(callback)));
     4196}
     4197
     4198void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, CompletionHandler<void(API::Data*)>&& callback)
     4199{
     4200    if (!frame)
     4201        return callback(nullptr);
     4202    sendWithAsyncReply(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID()), toAPIDataCallback(WTFMove(callback)));
    42224203}
    42234204
     
    71437124
    71447125    callback->performCallback();
    7145 }
    7146 
    7147 void WebPageProxy::dataCallback(const IPC::DataReference& dataReference, CallbackID callbackID)
    7148 {
    7149     auto callback = m_callbacks.take<DataCallback>(callbackID);
    7150     if (!callback)
    7151         return;
    7152 
    7153     callback->performCallbackWithReturnValue(API::Data::create(dataReference.data(), dataReference.size()).ptr());
    71547126}
    71557127
     
    85528524}
    85538525
    8554 void WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, const PrintInfo& printInfo, uint32_t first, uint32_t count, Ref<DataCallback>&& callback)
    8555 {
    8556     if (!hasRunningProcess()) {
    8557         callback->invalidate();
    8558         return;
    8559     }
    8560    
    8561     auto callbackID = callback->callbackID();
    8562     m_callbacks.put(WTFMove(callback));
    8563     send(Messages::WebPage::DrawPagesToPDF(frame->frameID(), printInfo, first, count, callbackID), printingSendOptions(m_isPerformingDOMPrintOperation));
     8526uint64_t WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, const PrintInfo& printInfo, uint32_t first, uint32_t count, CompletionHandler<void(API::Data*)>&& callback)
     8527{
     8528    return sendWithAsyncReply(Messages::WebPage::DrawPagesToPDF(frame->frameID(), printInfo, first, count), toAPIDataCallback(WTFMove(callback)), printingSendOptions(m_isPerformingDOMPrintOperation));
    85648529}
    85658530#elif PLATFORM(GTK)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r272635 r272636  
    381381enum class WebContentMode : uint8_t;
    382382
    383 typedef GenericCallback<API::Data*> DataCallback;
    384383typedef GenericCallback<const String&> StringCallback;
    385384
     
    11281127
    11291128#if ENABLE(MHTML)
    1130     void getContentsAsMHTMLData(Function<void (API::Data*, CallbackBase::Error)>&&);
    1131 #endif
    1132     void getMainResourceDataOfFrame(WebFrameProxy*, Function<void (API::Data*, CallbackBase::Error)>&&);
    1133     void getResourceDataFromFrame(WebFrameProxy*, API::URL*, Function<void (API::Data*, CallbackBase::Error)>&&);
     1129    void getContentsAsMHTMLData(CompletionHandler<void(API::Data*)>&&);
     1130#endif
     1131    void getMainResourceDataOfFrame(WebFrameProxy*, CompletionHandler<void(API::Data*)>&&);
     1132    void getResourceDataFromFrame(WebFrameProxy&, API::URL*, CompletionHandler<void(API::Data*)>&&);
    11341133    void getRenderTreeExternalRepresentation(WTF::Function<void (const String&, CallbackBase::Error)>&&);
    11351134    void getSelectionOrContentsAsString(WTF::Function<void (const String&, CallbackBase::Error)>&&);
    1136     void getSelectionAsWebArchiveData(Function<void (API::Data*, CallbackBase::Error)>&&);
     1135    void getSelectionAsWebArchiveData(CompletionHandler<void(API::Data*)>&&);
    11371136    void getSourceForFrame(WebFrameProxy*, WTF::Function<void (const String&, CallbackBase::Error)>&&);
    1138     void getWebArchiveOfFrame(WebFrameProxy*, Function<void (API::Data*, CallbackBase::Error)>&&);
     1137    void getWebArchiveOfFrame(WebFrameProxy*, CompletionHandler<void(API::Data*)>&&);
    11391138    void runJavaScriptInMainFrame(WebCore::RunJavaScriptParameters&&, CompletionHandler<void(Expected<RefPtr<API::SerializedScriptValue>, WebCore::ExceptionDetails>&&)>&&);
    11401139    void runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters&&, Optional<WebCore::FrameIdentifier>, API::ContentWorld&, CompletionHandler<void(Expected<RefPtr<API::SerializedScriptValue>, WebCore::ExceptionDetails>&&)>&&);
     
    12931292#if PLATFORM(COCOA)
    12941293    uint64_t drawRectToImage(WebFrameProxy*, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, CompletionHandler<void(const WebKit::ShareableBitmap::Handle&)>&&);
    1295     void drawPagesToPDF(WebFrameProxy*, const PrintInfo&, uint32_t first, uint32_t count, Ref<DataCallback>&&);
     1294    uint64_t drawPagesToPDF(WebFrameProxy*, const PrintInfo&, uint32_t first, uint32_t count, CompletionHandler<void(API::Data*)>&&);
    12961295    void drawToPDF(WebCore::FrameIdentifier, const Optional<WebCore::FloatRect>&, CompletionHandler<void(const IPC::DataReference&)>&&);
    12971296#if PLATFORM(IOS_FAMILY)
     
    21612160
    21622161    void voidCallback(CallbackID);
    2163     void dataCallback(const IPC::DataReference&, CallbackID);
    21642162    void stringCallback(const String&, CallbackID);
    21652163    void invalidateStringCallback(CallbackID);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r272635 r272636  
    165165    # Callback messages
    166166    VoidCallback(WebKit::CallbackID callbackID)
    167     DataCallback(IPC::SharedBufferDataReference resultData, WebKit::CallbackID callbackID)
    168167    StringCallback(String resultString, WebKit::CallbackID callbackID)
    169168    InvalidateStringCallback(WebKit::CallbackID callbackID)
  • trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm

    r272628 r272636  
    279279
    280280    IPCCallbackContext* context = new IPCCallbackContext;
    281     auto callback = WebKit::DataCallback::create([context](API::Data* data, WebKit::CallbackBase::Error) {
     281    auto callback = [context](API::Data* data) {
    282282        ASSERT(RunLoop::isMain());
    283283
     
    294294            view->_printingCallbackCondition.notifyOne();
    295295        }
    296     });
    297     _expectedPrintCallback = callback->callbackID().toInteger();
    298 
     296    };
     297    _expectedPrintCallback = _webFrame->page()->drawPagesToPDF(_webFrame.get(), printInfo, firstPage - 1, lastPage - firstPage + 1, WTFMove(callback));
    299298    context->view = self;
    300     context->callbackID = callback->callbackID().toInteger();
    301 
    302     _webFrame->page()->drawPagesToPDF(_webFrame.get(), printInfo, firstPage - 1, lastPage - firstPage + 1, WTFMove(callback));
     299    context->callbackID = _expectedPrintCallback;
    303300}
    304301
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r272635 r272636  
    36283628
    36293629#if ENABLE(MHTML)
    3630 void WebPage::getContentsAsMHTMLData(CallbackID callbackID)
    3631 {
    3632     send(Messages::WebPageProxy::DataCallback({ MHTMLArchive::generateMHTMLData(m_page.get()) }, callbackID));
     3630void WebPage::getContentsAsMHTMLData(CompletionHandler<void(const IPC::SharedBufferDataReference&)>&& callback)
     3631{
     3632    callback({ MHTMLArchive::generateMHTMLData(m_page.get()) });
    36333633}
    36343634#endif
     
    36503650}
    36513651
    3652 void WebPage::getSelectionAsWebArchiveData(CallbackID callbackID)
     3652void WebPage::getSelectionAsWebArchiveData(CompletionHandler<void(const IPC::DataReference&)>&& callback)
    36533653{
    36543654#if PLATFORM(COCOA)
     
    36583658#endif
    36593659
    3660     IPC::SharedBufferDataReference dataReference;
     3660    IPC::DataReference dataReference;
    36613661#if PLATFORM(COCOA)
    36623662    if (data)
    36633663        dataReference = { CFDataGetBytePtr(data.get()), static_cast<size_t>(CFDataGetLength(data.get())) };
    36643664#endif
    3665     send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
     3665    callback(dataReference);
    36663666}
    36673667
     
    36843684}
    36853685
    3686 void WebPage::getMainResourceDataOfFrame(FrameIdentifier frameID, CallbackID callbackID)
     3686void WebPage::getMainResourceDataOfFrame(FrameIdentifier frameID, CompletionHandler<void(const IPC::SharedBufferDataReference&)>&& callback)
    36873687{
    36883688    RefPtr<SharedBuffer> buffer;
     
    36993699    if (buffer)
    37003700        dataReference = { *buffer };
    3701     send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
     3701    callback(dataReference);
    37023702}
    37033703
     
    37153715}
    37163716
    3717 void WebPage::getResourceDataFromFrame(FrameIdentifier frameID, const String& resourceURLString, CallbackID callbackID)
     3717void WebPage::getResourceDataFromFrame(FrameIdentifier frameID, const String& resourceURLString, CompletionHandler<void(const IPC::SharedBufferDataReference&)>&& callback)
    37183718{
    37193719    RefPtr<SharedBuffer> buffer;
     
    37263726    if (buffer)
    37273727        dataReference = { *buffer };
    3728     send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
    3729 }
    3730 
    3731 void WebPage::getWebArchiveOfFrame(FrameIdentifier frameID, CallbackID callbackID)
     3728    callback(dataReference);
     3729}
     3730
     3731void WebPage::getWebArchiveOfFrame(FrameIdentifier frameID, CompletionHandler<void(const IPC::DataReference&)>&& callback)
    37323732{
    37333733#if PLATFORM(COCOA)
     
    37393739#endif
    37403740
    3741     IPC::SharedBufferDataReference dataReference;
     3741    IPC::DataReference dataReference;
    37423742#if PLATFORM(COCOA)
    37433743    if (data)
    37443744        dataReference = { CFDataGetBytePtr(data.get()), static_cast<size_t>(CFDataGetLength(data.get())) };
    37453745#endif
    3746     send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
     3746    callback(dataReference);
    37473747}
    37483748
     
    51855185}
    51865186
    5187 void WebPage::drawPagesToPDF(FrameIdentifier frameID, const PrintInfo& printInfo, uint32_t first, uint32_t count, CallbackID callbackID)
     5187void WebPage::drawPagesToPDF(FrameIdentifier frameID, const PrintInfo& printInfo, uint32_t first, uint32_t count, CompletionHandler<void(const IPC::DataReference&)>&& callback)
    51885188{
    51895189    RetainPtr<CFMutableDataRef> pdfPageData;
    51905190    drawPagesToPDFImpl(frameID, printInfo, first, count, pdfPageData);
    5191     send(Messages::WebPageProxy::DataCallback({ CFDataGetBytePtr(pdfPageData.get()), static_cast<size_t>(CFDataGetLength(pdfPageData.get())) }, callbackID));
     5191    callback({ CFDataGetBytePtr(pdfPageData.get()), static_cast<size_t>(CFDataGetLength(pdfPageData.get())) });
    51925192}
    51935193
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r272635 r272636  
    970970#if PLATFORM(COCOA)
    971971    void drawRectToImage(WebCore::FrameIdentifier, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, CompletionHandler<void(const WebKit::ShareableBitmap::Handle&)>&&);
    972     void drawPagesToPDF(WebCore::FrameIdentifier, const PrintInfo&, uint32_t first, uint32_t count, CallbackID);
     972    void drawPagesToPDF(WebCore::FrameIdentifier, const PrintInfo&, uint32_t first, uint32_t count, CompletionHandler<void(const IPC::DataReference&)>&&);
    973973    void drawPagesToPDFImpl(WebCore::FrameIdentifier, const PrintInfo&, uint32_t first, uint32_t count, RetainPtr<CFMutableDataRef>& pdfPageData);
    974974#endif
     
    15861586#endif
    15871587#if ENABLE(MHTML)
    1588     void getContentsAsMHTMLData(CallbackID);
    1589 #endif
    1590     void getMainResourceDataOfFrame(WebCore::FrameIdentifier, CallbackID);
    1591     void getResourceDataFromFrame(WebCore::FrameIdentifier, const String& resourceURL, CallbackID);
     1588    void getContentsAsMHTMLData(CompletionHandler<void(const IPC::SharedBufferDataReference&)>&& callback);
     1589#endif
     1590    void getMainResourceDataOfFrame(WebCore::FrameIdentifier, CompletionHandler<void(const IPC::SharedBufferDataReference&)>&&);
     1591    void getResourceDataFromFrame(WebCore::FrameIdentifier, const String& resourceURL, CompletionHandler<void(const IPC::SharedBufferDataReference&)>&&);
    15921592    void getRenderTreeExternalRepresentation(CallbackID);
    15931593    void getSelectionOrContentsAsString(CallbackID);
    1594     void getSelectionAsWebArchiveData(CallbackID);
     1594    void getSelectionAsWebArchiveData(CompletionHandler<void(const IPC::DataReference&)>&&);
    15951595    void getSourceForFrame(WebCore::FrameIdentifier, CallbackID);
    1596     void getWebArchiveOfFrame(WebCore::FrameIdentifier, CallbackID);
     1596    void getWebArchiveOfFrame(WebCore::FrameIdentifier, CompletionHandler<void(const IPC::DataReference&)>&&);
    15971597    void runJavaScript(WebFrame*, WebCore::RunJavaScriptParameters&&, ContentWorldIdentifier, CompletionHandler<void(const IPC::DataReference&, const Optional<WebCore::ExceptionDetails>&)>&&);
    15981598    void runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters&&, Optional<WebCore::FrameIdentifier>, const std::pair<ContentWorldIdentifier, String>& worldData, CompletionHandler<void(const IPC::DataReference&, const Optional<WebCore::ExceptionDetails>&)>&&);
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r272635 r272636  
    211211#endif
    212212#if ENABLE(MHTML)
    213     GetContentsAsMHTMLData(WebKit::CallbackID callbackID)
    214 #endif
    215     GetMainResourceDataOfFrame(WebCore::FrameIdentifier frameID, WebKit::CallbackID callbackID)
    216     GetResourceDataFromFrame(WebCore::FrameIdentifier frameID, String resourceURL, WebKit::CallbackID callbackID)
     213    GetContentsAsMHTMLData() -> (IPC::SharedBufferDataReference data) Async
     214#endif
     215    GetMainResourceDataOfFrame(WebCore::FrameIdentifier frameID) -> (IPC::SharedBufferDataReference dataReference) Async
     216    GetResourceDataFromFrame(WebCore::FrameIdentifier frameID, String resourceURL) -> (IPC::SharedBufferDataReference dataReference) Async
    217217    GetRenderTreeExternalRepresentation(WebKit::CallbackID callbackID)
    218218    GetSelectionOrContentsAsString(WebKit::CallbackID callbackID)
    219     GetSelectionAsWebArchiveData(WebKit::CallbackID callbackID)
     219    GetSelectionAsWebArchiveData() -> (IPC::DataReference data) Async
    220220    GetSourceForFrame(WebCore::FrameIdentifier frameID, WebKit::CallbackID callbackID)
    221     GetWebArchiveOfFrame(WebCore::FrameIdentifier frameID, WebKit::CallbackID callbackID)
     221    GetWebArchiveOfFrame(WebCore::FrameIdentifier frameID) -> (IPC::DataReference dataReference) Async
    222222
    223223    RunJavaScriptInFrameInScriptWorld(struct WebCore::RunJavaScriptParameters parameters, Optional<WebCore::FrameIdentifier> frameID, std::pair<WebKit::ContentWorldIdentifier, String> world) -> (IPC::DataReference resultData, Optional<WebCore::ExceptionDetails> details) Async
     
    401401#if PLATFORM(COCOA)
    402402    DrawRectToImage(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, WebCore::IntRect rect, WebCore::IntSize imageSize) -> (WebKit::ShareableBitmap::Handle image) Async
    403     DrawPagesToPDF(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, uint32_t first, uint32_t count, WebKit::CallbackID callbackID)
     403    DrawPagesToPDF(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, uint32_t first, uint32_t count) -> (IPC::DataReference data) Async
    404404#if PLATFORM(IOS_FAMILY)
    405405    ComputePagesForPrintingiOS(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo) -> (size_t pageCount) Synchronous
Note: See TracChangeset for help on using the changeset viewer.