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

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

Issue 1947263004: Introduces a new MHTML generation parameter specifying different behvaior for cache-control headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work on compile. Created 4 years, 7 months 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 09fab010910923bea9bed94a704d40d0052a75d2..5349d4f5b1e1dd6e13837621961f6cdd748b3a67 100644
--- a/third_party/WebKit/Source/web/WebFrameSerializer.cpp
+++ b/third_party/WebKit/Source/web/WebFrameSerializer.cpp
@@ -47,10 +47,13 @@
#include "platform/SharedBuffer.h"
#include "platform/mhtml/MHTMLArchive.h"
#include "platform/mhtml/MHTMLParser.h"
+#include "platform/network/ResourceResponse.h"
#include "platform/weborigin/KURL.h"
#include "public/platform/WebString.h"
#include "public/platform/WebURL.h"
+#include "public/platform/WebURLResponse.h"
#include "public/platform/WebVector.h"
+#include "public/web/WebDataSource.h"
#include "public/web/WebDocument.h"
#include "public/web/WebFrame.h"
#include "public/web/WebFrameSerializerClient.h"
@@ -136,18 +139,37 @@ bool MHTMLFrameSerializerDelegate::shouldSkipResource(const KURL& url)
return m_webDelegate.shouldSkipResource(url);
}
+bool resourceResponseContainsNoStore(const ResourceResponse& response)
+{
+ DEFINE_STATIC_LOCAL(const AtomicString, cacheControlHeader, ("cache-control"));
+ DEFINE_STATIC_LOCAL(const AtomicString, pragmaHeader, ("pragma"));
+
+ return parseCacheControlDirectives(
+ response.httpHeaderField(cacheControlHeader),
+ response.httpHeaderField(pragmaHeader)).containsNoStore;
Łukasz Anforowicz 2016/05/12 18:56:49 Could this be written as: return response.cacheCon
dewittj 2016/05/12 22:58:01 No, that method is not const, since it caches the
Łukasz Anforowicz 2016/05/12 23:56:27 Oh, indeed - thanks for the explanation. And I se
dcheng 2016/05/13 17:48:33 +toyoshim, +hiroshige: any ideas on how to improve
hiroshige 2016/05/13 18:01:52 How about making ResourceResponse::cacheControlCon
+}
+
} // namespace
-WebData WebFrameSerializer::generateMHTMLHeader(
- const WebString& boundary, WebLocalFrame* frame)
+bool WebFrameSerializer::generateMHTMLHeader(
+ const WebString& boundary, CacheControlPolicy cacheControlPolicy,
+ WebLocalFrame* frame, WebData* data)
{
- Document* document = toWebLocalFrameImpl(frame)->frame()->document();
+ WebLocalFrameImpl* webLocalFrameImpl = toWebLocalFrameImpl(frame);
+ DCHECK(webLocalFrameImpl);
+
+ const ResourceResponse& response = webLocalFrameImpl->dataSource()->response().toResourceResponse();
+ if (cacheControlPolicy == CacheControlPolicyFailForNoStoreMainFrame && resourceResponseContainsNoStore(response))
+ return false;
+
+ Document* document = webLocalFrameImpl->frame()->document();
RefPtr<SharedBuffer> buffer = SharedBuffer::create();
MHTMLArchive::generateMHTMLHeader(
boundary, document->title(), document->suggestedMIMEType(),
*buffer);
- return buffer.release();
+ *data = buffer.release();
+ return true;
}
WebData WebFrameSerializer::generateMHTMLParts(

Powered by Google App Engine
This is Rietveld 408576698