Chromium Code Reviews| Index: content/browser/download/mhtml_generation_manager.cc |
| diff --git a/content/browser/download/mhtml_generation_manager.cc b/content/browser/download/mhtml_generation_manager.cc |
| index d6a0d474b3861cd1e909094d0f5a98d9e18ca8ae..1685a71e3011abd2ab923a302c4c4ab2ca8c652b 100644 |
| --- a/content/browser/download/mhtml_generation_manager.cc |
| +++ b/content/browser/download/mhtml_generation_manager.cc |
| @@ -50,6 +50,15 @@ void MHTMLGenerationManager::GenerateMHTML( |
| job.routing_id = web_contents->GetRenderViewHost()->GetRoutingID(); |
| job.callback = callback; |
| id_to_job_[job_id] = job; |
| + if (!registrar_.IsRegistered( |
| + this, |
| + NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| + Source<RenderProcessHost>(web_contents->GetRenderProcessHost()))) { |
| + registrar_.Add( |
| + this, |
| + NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| + Source<RenderProcessHost>(web_contents->GetRenderProcessHost())); |
| + } |
| base::ProcessHandle renderer_process = |
| web_contents->GetRenderProcessHost()->GetHandle(); |
| @@ -62,6 +71,24 @@ void MHTMLGenerationManager::MHTMLGenerated(int job_id, int64 mhtml_data_size) { |
| JobFinished(job_id, mhtml_data_size); |
| } |
| +void MHTMLGenerationManager::Observe(int type, |
| + const NotificationSource& source, |
| + const NotificationDetails& details) { |
| + DCHECK(type == NOTIFICATION_RENDERER_PROCESS_TERMINATED); |
| + RenderProcessHost* host = Source<RenderProcessHost>(source).ptr(); |
| + std::set<int> job_to_delete; |
| + for (IDToJobMap::iterator it = id_to_job_.begin(); it != id_to_job_.end(); |
| + ++it) { |
| + if (it->second.process_id == host->GetID()) |
| + job_to_delete.insert(it->first); |
| + } |
| + for (std::set<int>::iterator it = job_to_delete.begin(); |
| + it != job_to_delete.end(); |
| + ++it) { |
| + JobFinished(*it, -1); |
| + } |
| +} |
|
Jay Civelli
2013/08/01 17:57:00
Shouldn't we unregister for notifications for that
qsr
2013/08/02 14:22:24
Done.
|
| + |
| void MHTMLGenerationManager::CreateFile( |
| int job_id, const base::FilePath& file_path, |
| base::ProcessHandle renderer_process) { |