| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/download/mhtml_generation_manager.h" | 5 #include "content/browser/download/mhtml_generation_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 // Id used to map renderer responses to jobs. | 100 // Id used to map renderer responses to jobs. |
| 101 // See also MHTMLGenerationManager::id_to_job_ map. | 101 // See also MHTMLGenerationManager::id_to_job_ map. |
| 102 const int job_id_; | 102 const int job_id_; |
| 103 | 103 |
| 104 // Time tracking for performance metrics reporting. | 104 // Time tracking for performance metrics reporting. |
| 105 const base::TimeTicks creation_time_; | 105 const base::TimeTicks creation_time_; |
| 106 base::TimeTicks wait_on_renderer_start_time_; | 106 base::TimeTicks wait_on_renderer_start_time_; |
| 107 base::TimeDelta all_renderers_wait_time_; | 107 base::TimeDelta all_renderers_wait_time_; |
| 108 base::TimeDelta all_renderers_main_thread_time_; | 108 base::TimeDelta all_renderers_main_thread_time_; |
| 109 base::TimeDelta longest_renderer_main_thread_time_; |
| 109 | 110 |
| 110 // User-configurable parameters. Includes the file location, binary encoding | 111 // User-configurable parameters. Includes the file location, binary encoding |
| 111 // choices, and whether to skip storing resources marked | 112 // choices, and whether to skip storing resources marked |
| 112 // Cache-Control: no-store. | 113 // Cache-Control: no-store. |
| 113 MHTMLGenerationParams params_; | 114 MHTMLGenerationParams params_; |
| 114 | 115 |
| 115 // The IDs of frames that still need to be processed. | 116 // The IDs of frames that still need to be processed. |
| 116 std::queue<int> pending_frame_tree_node_ids_; | 117 std::queue<int> pending_frame_tree_node_ids_; |
| 117 | 118 |
| 118 // Identifies a frame to which we've sent FrameMsg_SerializeAsMHTML but for | 119 // Identifies a frame to which we've sent FrameMsg_SerializeAsMHTML but for |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 UMA_HISTOGRAM_TIMES( | 276 UMA_HISTOGRAM_TIMES( |
| 276 "PageSerialization.MhtmlGeneration.BrowserWaitForRendererTime." | 277 "PageSerialization.MhtmlGeneration.BrowserWaitForRendererTime." |
| 277 "FrameTree", | 278 "FrameTree", |
| 278 all_renderers_wait_time_); | 279 all_renderers_wait_time_); |
| 279 } | 280 } |
| 280 if (!all_renderers_main_thread_time_.is_zero()) { | 281 if (!all_renderers_main_thread_time_.is_zero()) { |
| 281 UMA_HISTOGRAM_TIMES( | 282 UMA_HISTOGRAM_TIMES( |
| 282 "PageSerialization.MhtmlGeneration.RendererMainThreadTime.FrameTree", | 283 "PageSerialization.MhtmlGeneration.RendererMainThreadTime.FrameTree", |
| 283 all_renderers_main_thread_time_); | 284 all_renderers_main_thread_time_); |
| 284 } | 285 } |
| 286 if (!longest_renderer_main_thread_time_.is_zero()) { |
| 287 UMA_HISTOGRAM_TIMES( |
| 288 "PageSerialization.MhtmlGeneration.RendererMainThreadTime.SlowestFrame", |
| 289 longest_renderer_main_thread_time_); |
| 290 } |
| 285 | 291 |
| 286 // Stopping RenderProcessExited notifications is needed to avoid calling | 292 // Stopping RenderProcessExited notifications is needed to avoid calling |
| 287 // JobFinished twice. See also https://crbug.com/612098. | 293 // JobFinished twice. See also https://crbug.com/612098. |
| 288 observed_renderer_process_host_.RemoveAll(); | 294 observed_renderer_process_host_.RemoveAll(); |
| 289 } | 295 } |
| 290 | 296 |
| 291 void MHTMLGenerationManager::Job::ReportRendererMainThreadTime( | 297 void MHTMLGenerationManager::Job::ReportRendererMainThreadTime( |
| 292 base::TimeDelta renderer_main_thread_time) { | 298 base::TimeDelta renderer_main_thread_time) { |
| 293 DCHECK(renderer_main_thread_time > base::TimeDelta()); | 299 DCHECK(renderer_main_thread_time > base::TimeDelta()); |
| 294 if (renderer_main_thread_time > base::TimeDelta()) | 300 if (renderer_main_thread_time > base::TimeDelta()) |
| 295 all_renderers_main_thread_time_ += renderer_main_thread_time; | 301 all_renderers_main_thread_time_ += renderer_main_thread_time; |
| 302 if (renderer_main_thread_time > longest_renderer_main_thread_time_) |
| 303 longest_renderer_main_thread_time_ = renderer_main_thread_time; |
| 296 } | 304 } |
| 297 | 305 |
| 298 void MHTMLGenerationManager::Job::AddFrame(RenderFrameHost* render_frame_host) { | 306 void MHTMLGenerationManager::Job::AddFrame(RenderFrameHost* render_frame_host) { |
| 299 auto* rfhi = static_cast<RenderFrameHostImpl*>(render_frame_host); | 307 auto* rfhi = static_cast<RenderFrameHostImpl*>(render_frame_host); |
| 300 int frame_tree_node_id = rfhi->frame_tree_node()->frame_tree_node_id(); | 308 int frame_tree_node_id = rfhi->frame_tree_node()->frame_tree_node_id(); |
| 301 pending_frame_tree_node_ids_.push(frame_tree_node_id); | 309 pending_frame_tree_node_ids_.push(frame_tree_node_id); |
| 302 | 310 |
| 303 std::string guid = base::GenerateGUID(); | 311 std::string guid = base::GenerateGUID(); |
| 304 std::string content_id = base::StringPrintf("<frame-%d-%s@mhtml.blink>", | 312 std::string content_id = base::StringPrintf("<frame-%d-%s@mhtml.blink>", |
| 305 frame_tree_node_id, guid.c_str()); | 313 frame_tree_node_id, guid.c_str()); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 return iter->second; | 538 return iter->second; |
| 531 } | 539 } |
| 532 | 540 |
| 533 void MHTMLGenerationManager::RenderProcessExited(Job* job) { | 541 void MHTMLGenerationManager::RenderProcessExited(Job* job) { |
| 534 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 542 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 535 DCHECK(job); | 543 DCHECK(job); |
| 536 JobFinished(job, JobStatus::FAILURE); | 544 JobFinished(job, JobStatus::FAILURE); |
| 537 } | 545 } |
| 538 | 546 |
| 539 } // namespace content | 547 } // namespace content |
| OLD | NEW |