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

Unified Diff: content/renderer/render_frame_impl.cc

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: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 087cd75e2a4adf3622d2a000c478cc7cb4e8a640..74de5229d9d9e15c2c264713bda39788601ec6cd 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -69,6 +69,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/context_menu_params.h"
#include "content/public/common/isolated_world_ids.h"
+#include "content/public/common/mhtml_generation.h"
#include "content/public/common/page_state.h"
#include "content/public/common/resource_response.h"
#include "content/public/common/url_constants.h"
@@ -4899,43 +4900,45 @@ void RenderFrameImpl::OnSerializeAsMHTML(
DCHECK(!mhtml_boundary.isEmpty());
WebData data;
- bool success = true;
+ MHTMLSerializationResult result = MHTMLSerializationResult::OK;
std::set<std::string> digests_of_uris_of_serialized_resources;
MHTMLPartsGenerationDelegate delegate(
params, &digests_of_uris_of_serialized_resources);
// Generate MHTML header if needed.
if (IsMainFrame()) {
- data =
- WebFrameSerializer::generateMHTMLHeader(mhtml_boundary, GetWebFrame());
- if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) {
- success = false;
+ bool success = WebFrameSerializer::generateMHTMLHeader(
Łukasz Anforowicz 2016/05/12 18:56:49 Hmmm... conveying MHTMLSerializationResult::NO_STO
dewittj 2016/05/12 22:58:01 Since I don't expose more granular errors any more
Łukasz Anforowicz 2016/05/12 23:56:27 Yes - looks good. Thanks.
+ mhtml_boundary,
+ mhtml::toCacheControlPolicy(params.mhtml_cache_control_policy),
+ GetWebFrame(), &data);
+ if (!success) {
+ result = MHTMLSerializationResult::NO_STORE_MAIN_FRAME;
+ } else if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) {
+ result = MHTMLSerializationResult::FILE_WRITE_FAILED_IN_HEADER;
}
}
// Generate MHTML parts.
- if (success) {
+ if (result == MHTMLSerializationResult::OK) {
data = WebFrameSerializer::generateMHTMLParts(
mhtml_boundary, GetWebFrame(), params.mhtml_binary_encoding, &delegate);
// TODO(jcivelli): write the chunks in deferred tasks to give a chance to
// the message loop to process other events.
- if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) {
- success = false;
- }
+ if (file.WriteAtCurrentPos(data.data(), data.size()) < 0)
+ result = MHTMLSerializationResult::FILE_WRITE_FAILED_IN_PARTS_GEN;
}
// Generate MHTML footer if needed.
- if (success && params.is_last_frame) {
+ if (result == MHTMLSerializationResult::OK && params.is_last_frame) {
data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary);
- if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) {
- success = false;
- }
+ if (file.WriteAtCurrentPos(data.data(), data.size()) < 0)
+ result = MHTMLSerializationResult::FILE_WRITE_FAILED_IN_FOOTER;
}
// Cleanup and notify the browser process about completion.
file.Close(); // Need to flush file contents before sending IPC response.
Send(new FrameHostMsg_SerializeAsMHTMLResponse(
- routing_id_, params.job_id, success,
+ routing_id_, params.job_id, result,
digests_of_uris_of_serialized_resources));
}

Powered by Google App Engine
This is Rietveld 408576698