Changeset 272636 in webkit
- Timestamp:
- Feb 9, 2021, 9:21:11 PM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r272635 r272636 1 2021-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 1 46 2021-02-09 Alex Christensen <achristensen@webkit.org> 2 47 -
trunk/Source/WebKit/UIProcess/API/C/WKFrame.cpp
r261586 r272636 140 140 void WKFrameGetMainResourceData(WKFrameRef frameRef, WKFrameGetResourceDataFunction callback, void* context) 141 141 { 142 toImpl(frameRef)->getMainResourceData(toGenericCallbackFunction(context, callback)); 142 toImpl(frameRef)->getMainResourceData([context, callback] (API::Data* data) { 143 callback(toAPI(data), nullptr, context); 144 }); 143 145 } 144 146 145 147 void WKFrameGetResourceData(WKFrameRef frameRef, WKURLRef resourceURL, WKFrameGetResourceDataFunction callback, void* context) 146 148 { 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 }); 148 152 } 149 153 150 154 void WKFrameGetWebArchive(WKFrameRef frameRef, WKFrameGetWebArchiveFunction callback, void* context) 151 155 { 152 toImpl(frameRef)->getWebArchive(toGenericCallbackFunction(context, callback)); 156 toImpl(frameRef)->getWebArchive([context, callback] (API::Data* data) { 157 callback(toAPI(data), nullptr, context); 158 }); 153 159 } -
trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp
r272606 r272636 2569 2569 void WKPageGetSelectionAsWebArchiveData(WKPageRef pageRef, void* context, WKPageGetSelectionAsWebArchiveDataFunction callback) 2570 2570 { 2571 toImpl(pageRef)->getSelectionAsWebArchiveData(toGenericCallbackFunction(context, callback)); 2571 toImpl(pageRef)->getSelectionAsWebArchiveData([context, callback] (API::Data* data) { 2572 callback(toAPI(data), nullptr, context); 2573 }); 2572 2574 } 2573 2575 … … 2575 2577 { 2576 2578 #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 }); 2578 2582 #else 2579 2583 UNUSED_PARAM(pageRef); … … 2655 2659 void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context) 2656 2660 { 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 }); 2658 2664 } 2659 2665 #endif -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
r272629 r272636 1479 1479 - (void)createWebArchiveDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler 1480 1480 { 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); 1490 1483 }); 1491 1484 } … … 2527 2520 - (void)_getMainResourceDataWithCompletionHandler:(void (^)(NSData *, NSError *))completionHandler 2528 2521 { 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); 2538 2524 }); 2539 2525 } -
trunk/Source/WebKit/UIProcess/API/glib/WebKitWebResource.cpp
r247510 r272636 343 343 WEBKIT_DEFINE_ASYNC_DATA_STRUCT(ResourceGetDataAsyncData) 344 344 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 } 345 static void resourceDataCallback(API::Data* wkData, GTask* task) 346 { 352 347 ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task)); 353 348 data->webData = wkData; … … 376 371 g_task_set_task_data(task.get(), createResourceGetDataAsyncData(), reinterpret_cast<GDestroyNotify>(destroyResourceGetDataAsyncData)); 377 372 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()); 380 375 }); 381 376 else { 382 377 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()); 385 380 }); 386 381 } -
trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
r272301 r272636 4168 4168 g_task_set_source_tag(task, reinterpret_cast<gpointer>(webkit_web_view_save)); 4169 4169 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) { 4171 4171 getContentsAsMHTMLDataCallback(data, task); 4172 4172 }); … … 4233 4233 g_task_set_task_data(task, data, reinterpret_cast<GDestroyNotify>(destroyViewSaveAsyncData)); 4234 4234 4235 getPage(webView).getContentsAsMHTMLData([task](API::Data* data , WebKit::CallbackBase::Error) {4235 getPage(webView).getContentsAsMHTMLData([task](API::Data* data) { 4236 4236 getContentsAsMHTMLDataCallback(data, task); 4237 4237 }); -
trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp
r261586 r272636 204 204 } 205 205 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)); 206 void 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 213 void 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 220 void 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)); 234 225 } 235 226 -
trunk/Source/WebKit/UIProcess/WebFrameProxy.h
r261586 r272636 104 104 bool isDisplayingPDFDocument() const; 105 105 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*)>&&); 109 109 110 110 void didStartProvisionalLoad(const URL&); -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r272635 r272636 4154 4154 } 4155 4155 4156 static 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 4156 4163 #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)); 4164 void WebPageProxy::getContentsAsMHTMLData(CompletionHandler<void(API::Data*)>&& callback) 4165 { 4166 sendWithAsyncReply(Messages::WebPage::GetContentsAsMHTMLData(), toAPIDataCallback(WTFMove(callback))); 4166 4167 } 4167 4168 #endif … … 4178 4179 } 4179 4180 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)); 4181 void WebPageProxy::getSelectionAsWebArchiveData(CompletionHandler<void(API::Data*)>&& callback) 4182 { 4183 sendWithAsyncReply(Messages::WebPage::GetSelectionAsWebArchiveData(), toAPIDataCallback(WTFMove(callback))); 4184 } 4185 4186 void 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 4193 void 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 4198 void 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))); 4222 4203 } 4223 4204 … … 7143 7124 7144 7125 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());7154 7126 } 7155 7127 … … 8552 8524 } 8553 8525 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)); 8526 uint64_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)); 8564 8529 } 8565 8530 #elif PLATFORM(GTK) -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r272635 r272636 381 381 enum class WebContentMode : uint8_t; 382 382 383 typedef GenericCallback<API::Data*> DataCallback;384 383 typedef GenericCallback<const String&> StringCallback; 385 384 … … 1128 1127 1129 1128 #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*)>&&); 1134 1133 void getRenderTreeExternalRepresentation(WTF::Function<void (const String&, CallbackBase::Error)>&&); 1135 1134 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*)>&&); 1137 1136 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*)>&&); 1139 1138 void runJavaScriptInMainFrame(WebCore::RunJavaScriptParameters&&, CompletionHandler<void(Expected<RefPtr<API::SerializedScriptValue>, WebCore::ExceptionDetails>&&)>&&); 1140 1139 void runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters&&, Optional<WebCore::FrameIdentifier>, API::ContentWorld&, CompletionHandler<void(Expected<RefPtr<API::SerializedScriptValue>, WebCore::ExceptionDetails>&&)>&&); … … 1293 1292 #if PLATFORM(COCOA) 1294 1293 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*)>&&); 1296 1295 void drawToPDF(WebCore::FrameIdentifier, const Optional<WebCore::FloatRect>&, CompletionHandler<void(const IPC::DataReference&)>&&); 1297 1296 #if PLATFORM(IOS_FAMILY) … … 2161 2160 2162 2161 void voidCallback(CallbackID); 2163 void dataCallback(const IPC::DataReference&, CallbackID);2164 2162 void stringCallback(const String&, CallbackID); 2165 2163 void invalidateStringCallback(CallbackID); -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r272635 r272636 165 165 # Callback messages 166 166 VoidCallback(WebKit::CallbackID callbackID) 167 DataCallback(IPC::SharedBufferDataReference resultData, WebKit::CallbackID callbackID)168 167 StringCallback(String resultString, WebKit::CallbackID callbackID) 169 168 InvalidateStringCallback(WebKit::CallbackID callbackID) -
trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm
r272628 r272636 279 279 280 280 IPCCallbackContext* context = new IPCCallbackContext; 281 auto callback = WebKit::DataCallback::create([context](API::Data* data, WebKit::CallbackBase::Error) {281 auto callback = [context](API::Data* data) { 282 282 ASSERT(RunLoop::isMain()); 283 283 … … 294 294 view->_printingCallbackCondition.notifyOne(); 295 295 } 296 }); 297 _expectedPrintCallback = callback->callbackID().toInteger(); 298 296 }; 297 _expectedPrintCallback = _webFrame->page()->drawPagesToPDF(_webFrame.get(), printInfo, firstPage - 1, lastPage - firstPage + 1, WTFMove(callback)); 299 298 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; 303 300 } 304 301 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r272635 r272636 3628 3628 3629 3629 #if ENABLE(MHTML) 3630 void WebPage::getContentsAsMHTMLData(C allbackID callbackID)3631 { 3632 send(Messages::WebPageProxy::DataCallback({ MHTMLArchive::generateMHTMLData(m_page.get()) }, callbackID));3630 void WebPage::getContentsAsMHTMLData(CompletionHandler<void(const IPC::SharedBufferDataReference&)>&& callback) 3631 { 3632 callback({ MHTMLArchive::generateMHTMLData(m_page.get()) }); 3633 3633 } 3634 3634 #endif … … 3650 3650 } 3651 3651 3652 void WebPage::getSelectionAsWebArchiveData(C allbackID callbackID)3652 void WebPage::getSelectionAsWebArchiveData(CompletionHandler<void(const IPC::DataReference&)>&& callback) 3653 3653 { 3654 3654 #if PLATFORM(COCOA) … … 3658 3658 #endif 3659 3659 3660 IPC:: SharedBufferDataReference dataReference;3660 IPC::DataReference dataReference; 3661 3661 #if PLATFORM(COCOA) 3662 3662 if (data) 3663 3663 dataReference = { CFDataGetBytePtr(data.get()), static_cast<size_t>(CFDataGetLength(data.get())) }; 3664 3664 #endif 3665 send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));3665 callback(dataReference); 3666 3666 } 3667 3667 … … 3684 3684 } 3685 3685 3686 void WebPage::getMainResourceDataOfFrame(FrameIdentifier frameID, C allbackID callbackID)3686 void WebPage::getMainResourceDataOfFrame(FrameIdentifier frameID, CompletionHandler<void(const IPC::SharedBufferDataReference&)>&& callback) 3687 3687 { 3688 3688 RefPtr<SharedBuffer> buffer; … … 3699 3699 if (buffer) 3700 3700 dataReference = { *buffer }; 3701 send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));3701 callback(dataReference); 3702 3702 } 3703 3703 … … 3715 3715 } 3716 3716 3717 void WebPage::getResourceDataFromFrame(FrameIdentifier frameID, const String& resourceURLString, C allbackID callbackID)3717 void WebPage::getResourceDataFromFrame(FrameIdentifier frameID, const String& resourceURLString, CompletionHandler<void(const IPC::SharedBufferDataReference&)>&& callback) 3718 3718 { 3719 3719 RefPtr<SharedBuffer> buffer; … … 3726 3726 if (buffer) 3727 3727 dataReference = { *buffer }; 3728 send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));3729 } 3730 3731 void WebPage::getWebArchiveOfFrame(FrameIdentifier frameID, C allbackID callbackID)3728 callback(dataReference); 3729 } 3730 3731 void WebPage::getWebArchiveOfFrame(FrameIdentifier frameID, CompletionHandler<void(const IPC::DataReference&)>&& callback) 3732 3732 { 3733 3733 #if PLATFORM(COCOA) … … 3739 3739 #endif 3740 3740 3741 IPC:: SharedBufferDataReference dataReference;3741 IPC::DataReference dataReference; 3742 3742 #if PLATFORM(COCOA) 3743 3743 if (data) 3744 3744 dataReference = { CFDataGetBytePtr(data.get()), static_cast<size_t>(CFDataGetLength(data.get())) }; 3745 3745 #endif 3746 send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));3746 callback(dataReference); 3747 3747 } 3748 3748 … … 5185 5185 } 5186 5186 5187 void WebPage::drawPagesToPDF(FrameIdentifier frameID, const PrintInfo& printInfo, uint32_t first, uint32_t count, C allbackID callbackID)5187 void WebPage::drawPagesToPDF(FrameIdentifier frameID, const PrintInfo& printInfo, uint32_t first, uint32_t count, CompletionHandler<void(const IPC::DataReference&)>&& callback) 5188 5188 { 5189 5189 RetainPtr<CFMutableDataRef> pdfPageData; 5190 5190 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())) }); 5192 5192 } 5193 5193 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r272635 r272636 970 970 #if PLATFORM(COCOA) 971 971 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, C allbackID);972 void drawPagesToPDF(WebCore::FrameIdentifier, const PrintInfo&, uint32_t first, uint32_t count, CompletionHandler<void(const IPC::DataReference&)>&&); 973 973 void drawPagesToPDFImpl(WebCore::FrameIdentifier, const PrintInfo&, uint32_t first, uint32_t count, RetainPtr<CFMutableDataRef>& pdfPageData); 974 974 #endif … … 1586 1586 #endif 1587 1587 #if ENABLE(MHTML) 1588 void getContentsAsMHTMLData(C allbackID);1589 #endif 1590 void getMainResourceDataOfFrame(WebCore::FrameIdentifier, C allbackID);1591 void getResourceDataFromFrame(WebCore::FrameIdentifier, const String& resourceURL, C allbackID);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&)>&&); 1592 1592 void getRenderTreeExternalRepresentation(CallbackID); 1593 1593 void getSelectionOrContentsAsString(CallbackID); 1594 void getSelectionAsWebArchiveData(C allbackID);1594 void getSelectionAsWebArchiveData(CompletionHandler<void(const IPC::DataReference&)>&&); 1595 1595 void getSourceForFrame(WebCore::FrameIdentifier, CallbackID); 1596 void getWebArchiveOfFrame(WebCore::FrameIdentifier, C allbackID);1596 void getWebArchiveOfFrame(WebCore::FrameIdentifier, CompletionHandler<void(const IPC::DataReference&)>&&); 1597 1597 void runJavaScript(WebFrame*, WebCore::RunJavaScriptParameters&&, ContentWorldIdentifier, CompletionHandler<void(const IPC::DataReference&, const Optional<WebCore::ExceptionDetails>&)>&&); 1598 1598 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 211 211 #endif 212 212 #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 217 217 GetRenderTreeExternalRepresentation(WebKit::CallbackID callbackID) 218 218 GetSelectionOrContentsAsString(WebKit::CallbackID callbackID) 219 GetSelectionAsWebArchiveData( WebKit::CallbackID callbackID)219 GetSelectionAsWebArchiveData() -> (IPC::DataReference data) Async 220 220 GetSourceForFrame(WebCore::FrameIdentifier frameID, WebKit::CallbackID callbackID) 221 GetWebArchiveOfFrame(WebCore::FrameIdentifier frameID , WebKit::CallbackID callbackID)221 GetWebArchiveOfFrame(WebCore::FrameIdentifier frameID) -> (IPC::DataReference dataReference) Async 222 222 223 223 RunJavaScriptInFrameInScriptWorld(struct WebCore::RunJavaScriptParameters parameters, Optional<WebCore::FrameIdentifier> frameID, std::pair<WebKit::ContentWorldIdentifier, String> world) -> (IPC::DataReference resultData, Optional<WebCore::ExceptionDetails> details) Async … … 401 401 #if PLATFORM(COCOA) 402 402 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 404 404 #if PLATFORM(IOS_FAMILY) 405 405 ComputePagesForPrintingiOS(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo) -> (size_t pageCount) Synchronous
Note:
See TracChangeset
for help on using the changeset viewer.