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

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

Issue 2605413002: MHTML generation: discard serialized resources by the measure they are encoded. (Closed)
Patch Set: Created 4 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/WebFrameSerializer.cpp
diff --git a/third_party/WebKit/Source/web/WebFrameSerializer.cpp b/third_party/WebKit/Source/web/WebFrameSerializer.cpp
index 7b5b8b7b0964efb233eeb50d294f1f7704b4962e..5fdf086b987a4235d190e22fae7cf7de62f0db1f 100644
--- a/third_party/WebKit/Source/web/WebFrameSerializer.cpp
+++ b/third_party/WebKit/Source/web/WebFrameSerializer.cpp
@@ -65,6 +65,7 @@
#include "web/WebLocalFrameImpl.h"
#include "web/WebRemoteFrameImpl.h"
#include "wtf/Assertions.h"
+#include "wtf/Deque.h"
#include "wtf/HashMap.h"
#include "wtf/HashSet.h"
#include "wtf/Noncopyable.h"
@@ -285,7 +286,7 @@ WebThreadSafeData WebFrameSerializer::generateMHTMLParts(
// Serialize.
TRACE_EVENT_BEGIN0("page-serialization",
"WebFrameSerializer::generateMHTMLParts serializing");
- Vector<SerializedResource> resources;
+ Deque<SerializedResource> resources;
{
SCOPED_BLINK_UMA_HISTOGRAM_TIMER(
"PageSerialization.MhtmlGeneration.SerializationTime.SingleFrame");
@@ -298,26 +299,23 @@ WebThreadSafeData WebFrameSerializer::generateMHTMLParts(
"resource count",
static_cast<unsigned long long>(resources.size()));
- // Get Content-ID for the frame being serialized.
- String frameContentID = webDelegate->getContentID(webFrame);
-
- // Encode serializer's output as MHTML.
+ // Encode serialized resources as MHTML.
RefPtr<RawData> output = RawData::create();
{
+ DCHECK(!resources.isEmpty());
SCOPED_BLINK_UMA_HISTOGRAM_TIMER(
"PageSerialization.MhtmlGeneration.EncodingTime.SingleFrame");
- bool isFirstResource = true;
- for (const SerializedResource& resource : resources) {
+ // Frame is the 1st resource (see FrameSerializer::serializeFrame doc
+ // comment). Frames get a Content-ID header.
+ MHTMLArchive::generateMHTMLPart(
+ boundary, webDelegate->getContentID(webFrame), encodingPolicy,
+ resources.takeFirst(), *output->mutableData());
carlosk 2016/12/30 03:08:47 To make this clear: my assumption is that these 2
Łukasz Anforowicz 2016/12/30 17:39:16 I think that because SerializedResource doesn't de
dcheng 2017/01/03 22:31:16 SerializedResource will probably have a compiler g
carlosk 2017/01/05 01:34:57 I also think it should have an auto-generated move
+ while (!resources.isEmpty()) {
TRACE_EVENT0("page-serialization",
"WebFrameSerializer::generateMHTMLParts encoding");
- // Frame is the 1st resource (see FrameSerializer::serializeFrame doc
- // comment). Frames get a Content-ID header.
- String contentID = isFirstResource ? frameContentID : String();
-
- MHTMLArchive::generateMHTMLPart(boundary, contentID, encodingPolicy,
- resource, *output->mutableData());
-
- isFirstResource = false;
+ MHTMLArchive::generateMHTMLPart(boundary, String(), encodingPolicy,
+ resources.takeFirst(),
+ *output->mutableData());
}
}
return output.release();
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameSerializer.cpp ('k') | third_party/WebKit/Source/web/tests/FrameSerializerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698