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

Unified Diff: content/browser/download/mhtml_generation_manager.cc

Issue 21512003: MHTMLGenerationManager handles the death of a render process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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/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) {

Powered by Google App Engine
This is Rietveld 408576698