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

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 48441a08048fc1b8d2bdb290acef211b75a00590..7e9c76be809169ae0af4406036e28583d522581b 100644
--- a/third_party/WebKit/Source/web/WebPageSerializer.cpp
+++ b/third_party/WebKit/Source/web/WebPageSerializer.cpp
@@ -166,16 +166,34 @@ WebData WebPageSerializer::generateMHTMLHeader(
return buffer.release();
}
+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();
MHTMLArchive::EncodingPolicy encodingPolicy = useBinaryEncoding
? MHTMLArchive::EncodingPolicy::UseBinaryEncoding
: MHTMLArchive::EncodingPolicy::UseDefaultEncoding;
- ContentIDMap frameToContentID = createFrameToContentIDMap(webFrameToContentID);
+ ContentIDMap frameToContentID =
+ createFrameToContentIDMap(webFrameToContentID);
// Serialize.
Vector<SerializedResource> resources;
@@ -191,6 +209,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