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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 2842653002: [Offline Pages] Generate MHTML header in the browser process. (Closed)
Patch Set: Update format string for gcc error. Created 3 years, 8 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 005ade583726e7001e4fd9ab0c3fb817992e2ccb..18cf95342384e56bd8f943810833b3d5f474e270 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -5621,36 +5621,20 @@ void RenderFrameImpl::OnSerializeAsMHTML(
std::set<std::string> serialized_resources_uri_digests;
MHTMLPartsGenerationDelegate delegate(params,
&serialized_resources_uri_digests);
-
MhtmlSaveStatus save_status = MhtmlSaveStatus::SUCCESS;
- bool has_some_data = false;
-
- // Generate MHTML header if needed.
- if (IsMainFrame()) {
- TRACE_EVENT0("page-serialization",
- "RenderFrameImpl::OnSerializeAsMHTML header");
carlosk 2017/04/25 01:28:08 Could you make this header serialization tracing s
- // The returned data can be empty if the main frame should be skipped. If
- // the main frame is skipped, then the whole archive is bad.
- mhtml_contents.emplace_back(WebFrameSerializer::GenerateMHTMLHeader(
- mhtml_boundary, GetWebFrame(), &delegate));
- if (mhtml_contents.back().IsEmpty())
- save_status = MhtmlSaveStatus::FRAME_SERIALIZATION_FORBIDDEN;
- else
- has_some_data = true;
- }
// Generate MHTML parts. Note that if this is not the main frame, then even
// skipping the whole parts generation step is not an error - it simply
// results in an omitted resource in the final file.
- if (save_status == MhtmlSaveStatus::SUCCESS) {
- TRACE_EVENT0("page-serialization",
- "RenderFrameImpl::OnSerializeAsMHTML parts serialization");
- // The returned data can be empty if the frame should be skipped, but this
- // is OK.
- mhtml_contents.emplace_back(WebFrameSerializer::GenerateMHTMLParts(
- mhtml_boundary, GetWebFrame(), &delegate));
- has_some_data |= !mhtml_contents.back().IsEmpty();
- }
+ TRACE_EVENT0("page-serialization",
+ "RenderFrameImpl::OnSerializeAsMHTML parts serialization");
+ // The returned data can be empty if the frame should be skipped, but this
+ // is OK.
+ mhtml_contents.emplace_back(WebFrameSerializer::GenerateMHTMLParts(
+ mhtml_boundary, GetWebFrame(), &delegate));
+ bool has_some_data = !mhtml_contents.back().IsEmpty();
+ if (IsMainFrame() && !has_some_data)
+ save_status = MhtmlSaveStatus::FRAME_SERIALIZATION_FORBIDDEN;
// Note: the MHTML footer is written by the browser process, after the last
// frame is serialized by a renderer process.
carlosk 2017/04/25 01:28:08 nit: we should either remove this comment above or
@@ -5663,7 +5647,7 @@ void RenderFrameImpl::OnSerializeAsMHTML(
"PageSerialization.MhtmlGeneration.RendererMainThreadTime.SingleFrame",
main_thread_use_time);
- if (save_status == MhtmlSaveStatus::SUCCESS && has_some_data) {
+ if (has_some_data) {
base::PostTaskAndReplyWithResult(
RenderThreadImpl::current()->GetFileThreadTaskRunner().get(), FROM_HERE,
base::Bind(&WriteMHTMLToDisk, base::Passed(&mhtml_contents),

Powered by Google App Engine
This is Rietveld 408576698