Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Unified Diff: third_party/WebKit/Source/web/WebPageSerializer.cpp

Issue 1417323006: OOPIFs: Deduplicating MHTML parts across frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mhtml-serialization-per-frame
Patch Set: Rebasing... Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/WebPageSerializer.cpp
diff --git a/third_party/WebKit/Source/web/WebPageSerializer.cpp b/third_party/WebKit/Source/web/WebPageSerializer.cpp
index 5e0e3fec455dbc5cec720af033f99c25a4b4ca0e..f9a3421ebde664b04d632785409aa68421a32d52 100644
--- a/third_party/WebKit/Source/web/WebPageSerializer.cpp
+++ b/third_party/WebKit/Source/web/WebPageSerializer.cpp
@@ -173,9 +173,26 @@ WebData WebPageSerializer::generateMHTMLHeader(
return PassRefPtr<SharedBuffer>(buffer);
}
+WebVector<WebURL> WebPageSerializer::enumerateMHTMLResources(WebLocalFrame* webFrame)
+{
+ Vector<SerializedResource> resources;
+ PageSerializer serializer(resources, nullptr);
+ serializer.serializeFrame(*toWebLocalFrameImpl(webFrame)->frame());
+
+ Vector<WebURL> result;
+ for (size_t i = 0; i < resources.size(); i++) {
+ const SerializedResource& resource = resources[i];
+ if (i != 0) // Report only resources, not the frame.
+ result.append(resource.url);
+ }
+
+ return result;
+}
+
WebData WebPageSerializer::generateMHTMLParts(
const WebString& boundary, WebLocalFrame* webFrame, bool useBinaryEncoding,
- const WebVector<std::pair<WebFrame*, WebString>>& webFrameToContentID)
+ const WebVector<std::pair<WebFrame*, WebString>>& webFrameToContentID,
+ const WebVector<WebURL>& resourcesToSkip)
{
// Translate arguments from public to internal blink APIs.
LocalFrame* frame = toWebLocalFrameImpl(webFrame)->frame();
@@ -199,6 +216,10 @@ WebData WebPageSerializer::generateMHTMLParts(
// comment). Frames need a Content-ID header.
String contentID = isFirstResource ? frameToContentID.get(frame) : String();
+ // Resources don't yet get a Content ID and are deduped based on URI.
+ if (contentID.isEmpty() && resourcesToSkip.contains(resource.url))
+ continue;
+
MHTMLArchive::generateMHTMLPart(
boundary, contentID, encodingPolicy, resource, *output);

Powered by Google App Engine
This is Rietveld 408576698