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

Unified Diff: third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp

Issue 1441553002: Generating CIDs in Blink during MHTML serialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mhtml-per-frame-page-serializer-only
Patch Set: Replace list Replaced initializer lists with array initialization. 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/platform/mhtml/MHTMLArchive.cpp
diff --git a/third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp b/third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp
index 892fa6883c7b51e9612798778f136c261b1cf8d9..8aba4198698afbc9615466cd24be08a7029190ef 100644
--- a/third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp
+++ b/third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp
@@ -39,6 +39,7 @@
#include "platform/mhtml/MHTMLParser.h"
#include "platform/text/QuotedPrintable.h"
#include "platform/weborigin/SchemeRegistry.h"
+#include "wtf/Assertions.h"
#include "wtf/CryptographicallyRandomNumber.h"
#include "wtf/DateMath.h"
#include "wtf/text/Base64.h"
@@ -127,6 +128,9 @@ void MHTMLArchive::generateMHTMLHeader(
const String& boundary, const String& title, const String& mimeType,
SharedBuffer& outputBuffer)
{
+ ASSERT(!boundary.isEmpty());
+ ASSERT(!mimeType.isEmpty());
+
DateComponents now;
now.setMillisecondsSinceEpochForDateTime(currentTimeMS());
// TODO(lukasza): Passing individual date/time components seems fragile.
@@ -160,14 +164,26 @@ void MHTMLArchive::generateMHTMLHeader(
void MHTMLArchive::generateMHTMLPart(
const String& boundary,
+ const String& contentID,
EncodingPolicy encodingPolicy,
const SerializedResource& resource,
SharedBuffer& outputBuffer)
{
+ ASSERT(!boundary.isEmpty());
+ ASSERT(contentID.isEmpty() || contentID[0] == '<');
+
StringBuilder stringBuilder;
stringBuilder.append("--" + boundary + "\r\n");
+
stringBuilder.appendLiteral("Content-Type: ");
stringBuilder.append(resource.mimeType);
+ stringBuilder.appendLiteral("\r\n");
+
+ if (!contentID.isEmpty()) {
+ stringBuilder.appendLiteral("Content-ID: ");
+ stringBuilder.append(contentID);
+ stringBuilder.appendLiteral("\r\n");
+ }
const char* contentEncoding = 0;
if (encodingPolicy == UseBinaryEncoding)
@@ -177,11 +193,17 @@ void MHTMLArchive::generateMHTMLPart(
else
contentEncoding = base64;
- stringBuilder.appendLiteral("\r\nContent-Transfer-Encoding: ");
+ stringBuilder.appendLiteral("Content-Transfer-Encoding: ");
stringBuilder.append(contentEncoding);
- stringBuilder.appendLiteral("\r\nContent-Location: ");
- stringBuilder.append(resource.url);
- stringBuilder.appendLiteral("\r\n\r\n");
+ stringBuilder.appendLiteral("\r\n");
+
+ if (!resource.url.protocolIsAbout()) {
+ stringBuilder.appendLiteral("Content-Location: ");
+ stringBuilder.append(resource.url);
+ stringBuilder.appendLiteral("\r\n");
+ }
+
+ stringBuilder.appendLiteral("\r\n");
CString asciiString = stringBuilder.toString().utf8();
outputBuffer.append(asciiString.data(), asciiString.length());
@@ -223,6 +245,7 @@ void MHTMLArchive::generateMHTMLFooter(
const String& boundary,
SharedBuffer& outputBuffer)
{
+ ASSERT(!boundary.isEmpty());
CString asciiString = String("--" + boundary + "--\r\n").utf8();
outputBuffer.append(asciiString.data(), asciiString.length());
}
« no previous file with comments | « third_party/WebKit/Source/platform/mhtml/MHTMLArchive.h ('k') | third_party/WebKit/Source/platform/mhtml/MHTMLParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698