RESOLVED FIXED 89872
[WK2] Add new C API to generate MHTML data from the UI process
https://bugs.webkit.org/show_bug.cgi?id=89872
Summary [WK2] Add new C API to generate MHTML data from the UI process
Mario Sanchez Prada
Reported 2012-06-25 05:51:44 PDT
It would be good to have a way in WK2 to generate MHTML date for a page from the UIProcess, by providing a new C API wrapping the following functions from WebCore::MHTMLArchive: class MHTMLArchive : public Archive { public: [...] static PassRefPtr<SharedBuffer> generateMHTMLData(Page*); // Binary encoding results in smaller MHTML files but they might not work in other browsers. static PassRefPtr<SharedBuffer> generateMHTMLDataUsingBinaryEncoding(Page*); [...] }; This bug is for that.
Attachments
Patch proposal (9.72 KB, patch)
2012-06-25 06:59 PDT, Mario Sanchez Prada
buildbot: commit-queue-
Patch proposal (9.73 KB, patch)
2012-06-25 07:33 PDT, Mario Sanchez Prada
cgarcia: review-
buildbot: commit-queue-
Patch proposal (9.81 KB, patch)
2012-06-26 00:36 PDT, Mario Sanchez Prada
andersca: review+
Mario Sanchez Prada
Comment 1 2012-06-25 06:58:10 PDT
Adding people that might be interested in this bug to CC
Mario Sanchez Prada
Comment 2 2012-06-25 06:59:38 PDT
Created attachment 149283 [details] Patch proposal Patch implemented this wrapping with just one function and a 'bool useBinaryEncoding' parameter.
Build Bot
Comment 3 2012-06-25 07:18:26 PDT
Comment on attachment 149283 [details] Patch proposal Attachment 149283 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/13087169
Mario Sanchez Prada
Comment 4 2012-06-25 07:33:13 PDT
Created attachment 149289 [details] Patch proposal Fixing issue in the mac EWS bot
Build Bot
Comment 5 2012-06-25 08:17:23 PDT
Comment on attachment 149289 [details] Patch proposal Attachment 149289 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/13089165
Carlos Garcia Campos
Comment 6 2012-06-25 23:34:50 PDT
Comment on attachment 149289 [details] Patch proposal View in context: https://bugs.webkit.org/attachment.cgi?id=149289&action=review > Source/WebKit2/UIProcess/API/C/WKPage.cpp:602 > + WKPageGetContentsAsMHTMLData(pageRef, callGetContentsAsMHTMLDataBlockAndDispose, Block_copy(block)); You are missing the bool useBinaryEncoding parameter here. And the order is context, callback, you are passing the callback before the context.
Mario Sanchez Prada
Comment 7 2012-06-26 00:36:39 PDT
Created attachment 149472 [details] Patch proposal (In reply to comment #6) > (From update of attachment 149289 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=149289&action=review > > > Source/WebKit2/UIProcess/API/C/WKPage.cpp:602 > > + WKPageGetContentsAsMHTMLData(pageRef, callGetContentsAsMHTMLDataBlockAndDispose, Block_copy(block)); > > You are missing the bool useBinaryEncoding parameter here. And the order is context, callback, you are passing the callback before the context. Ah! That explains things. Attaching a new patch
Mario Sanchez Prada
Comment 8 2012-07-18 03:36:44 PDT
Ping reviewers?
Carlos Garcia Campos
Comment 9 2012-07-18 03:50:20 PDT
Comment on attachment 149472 [details] Patch proposal View in context: https://bugs.webkit.org/attachment.cgi?id=149472&action=review Patch looks good to me in general, but since it adds new C API it would be great if Anders or Sam could take a look at it too. > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:1845 > + if (buffer) > + dataReference = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size()); I don't think buffer can be null
Mario Sanchez Prada
Comment 10 2012-07-19 04:09:01 PDT
(In reply to comment #9) > (From update of attachment 149472 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=149472&action=review > > Patch looks good to me in general, but since it adds new C API it would be > great if Anders or Sam could take a look at it too. I already pinged Anders in IRC, who already confirmed before me being on holidays that he would take a look to this.
Anders Carlsson
Comment 11 2012-08-07 17:09:17 PDT
Comment on attachment 149472 [details] Patch proposal View in context: https://bugs.webkit.org/attachment.cgi?id=149472&action=review > Source/WebKit2/UIProcess/API/C/WKPage.cpp:604 > +#ifdef __BLOCKS__ > +static void callGetContentsAsMHTMLDataBlockAndDispose(WKDataRef mhtmlData, WKErrorRef error, void* context) > +{ > + WKPageGetContentsAsMHTMLDataBlock block = (WKPageGetContentsAsMHTMLDataBlock)context; > + block(mhtmlData, error); > + Block_release(block); > +} > + > +void WKPageGetContentsAsMHTMLData_b(WKPageRef pageRef, bool useBinaryEncoding, WKPageGetContentsAsMHTMLDataBlock block) > +{ > + WKPageGetContentsAsMHTMLData(pageRef, useBinaryEncoding, Block_copy(block), callGetContentsAsMHTMLDataBlockAndDispose); > +} > +#endif We don't need this API, blocks don't work well with the C API since none of the WK objects are captured by value.
Mario Sanchez Prada
Comment 12 2012-08-08 00:09:06 PDT
(In reply to comment #11) > [...] > We don't need this API, blocks don't work well with the C API since none of > the WK objects are captured by value. Thanks for pointing out this issue (which I was not aware of). I'll remove that API when landing. Thanks for the review.
Mario Sanchez Prada
Comment 13 2012-08-08 00:12:45 PDT
Note You need to log in before you can comment on or make changes to this bug.