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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 197 |
198 result[routing_id] = content_id; | 198 result[routing_id] = content_id; |
199 } | 199 } |
200 return result; | 200 return result; |
201 } | 201 } |
202 | 202 |
203 MhtmlSaveStatus MHTMLGenerationManager::Job::SendToNextRenderFrame() { | 203 MhtmlSaveStatus MHTMLGenerationManager::Job::SendToNextRenderFrame() { |
204 DCHECK(browser_file_.IsValid()); | 204 DCHECK(browser_file_.IsValid()); |
205 DCHECK(!pending_frame_tree_node_ids_.empty()); | 205 DCHECK(!pending_frame_tree_node_ids_.empty()); |
206 | 206 |
| 207 int frame_tree_node_id = pending_frame_tree_node_ids_.front(); |
| 208 pending_frame_tree_node_ids_.pop(); |
| 209 FrameTreeNode* ftn = FrameTreeNode::GloballyFindByID(frame_tree_node_id); |
| 210 if (!ftn) { // A previously existing frame went away. |
| 211 if (!params_.ignore_missing_frames) |
| 212 return MhtmlSaveStatus::FRAME_NO_LONGER_EXISTS; |
| 213 else if (pending_frame_tree_node_ids_.empty()) |
| 214 return MhtmlSaveStatus::SUCCESS; |
| 215 else |
| 216 return SendToNextRenderFrame(); |
| 217 } |
| 218 |
207 FrameMsg_SerializeAsMHTML_Params ipc_params; | 219 FrameMsg_SerializeAsMHTML_Params ipc_params; |
208 ipc_params.job_id = job_id_; | 220 ipc_params.job_id = job_id_; |
209 ipc_params.mhtml_boundary_marker = mhtml_boundary_marker_; | 221 ipc_params.mhtml_boundary_marker = mhtml_boundary_marker_; |
210 ipc_params.mhtml_binary_encoding = params_.use_binary_encoding; | 222 ipc_params.mhtml_binary_encoding = params_.use_binary_encoding; |
211 ipc_params.mhtml_cache_control_policy = params_.cache_control_policy; | 223 ipc_params.mhtml_cache_control_policy = params_.cache_control_policy; |
212 | |
213 int frame_tree_node_id = pending_frame_tree_node_ids_.front(); | |
214 pending_frame_tree_node_ids_.pop(); | |
215 ipc_params.is_last_frame = pending_frame_tree_node_ids_.empty(); | 224 ipc_params.is_last_frame = pending_frame_tree_node_ids_.empty(); |
216 | 225 |
217 FrameTreeNode* ftn = FrameTreeNode::GloballyFindByID(frame_tree_node_id); | |
218 if (!ftn) // The contents went away. | |
219 return MhtmlSaveStatus::FRAME_NO_LONGER_EXISTS; | |
220 RenderFrameHost* rfh = ftn->current_frame_host(); | 226 RenderFrameHost* rfh = ftn->current_frame_host(); |
221 | 227 |
222 // Get notified if the target of the IPC message dies between responding. | 228 // Get notified if the target of the IPC message dies between responding. |
223 observed_renderer_process_host_.RemoveAll(); | 229 observed_renderer_process_host_.RemoveAll(); |
224 observed_renderer_process_host_.Add(rfh->GetProcess()); | 230 observed_renderer_process_host_.Add(rfh->GetProcess()); |
225 | 231 |
226 // Tell the renderer to skip (= deduplicate) already covered MHTML parts. | 232 // Tell the renderer to skip (= deduplicate) already covered MHTML parts. |
227 ipc_params.salt = salt_; | 233 ipc_params.salt = salt_; |
228 ipc_params.digests_of_uris_to_skip = digests_of_already_serialized_uris_; | 234 ipc_params.digests_of_uris_to_skip = digests_of_already_serialized_uris_; |
229 | 235 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 return iter->second.get(); | 550 return iter->second.get(); |
545 } | 551 } |
546 | 552 |
547 void MHTMLGenerationManager::RenderProcessExited(Job* job) { | 553 void MHTMLGenerationManager::RenderProcessExited(Job* job) { |
548 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 554 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
549 DCHECK(job); | 555 DCHECK(job); |
550 JobFinished(job, MhtmlSaveStatus::RENDER_PROCESS_EXITED); | 556 JobFinished(job, MhtmlSaveStatus::RENDER_PROCESS_EXITED); |
551 } | 557 } |
552 | 558 |
553 } // namespace content | 559 } // namespace content |
OLD | NEW |