diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-19 17:08:12 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-19 17:08:12 +0000 |
commit | 2ce26c438a2cd219348eefa324a64c15d1bf8cf2 (patch) | |
tree | 8b17944db4ef181365a7a29d4c86bb96f9a29754 /chrome/browser/automation/automation_provider_observers.cc | |
parent | 334b47007cdd108b8e0b0566bd29f952f5ad71f8 (diff) | |
download | chromium_src-2ce26c438a2cd219348eefa324a64c15d1bf8cf2.zip chromium_src-2ce26c438a2cd219348eefa324a64c15d1bf8cf2.tar.gz chromium_src-2ce26c438a2cd219348eefa324a64c15d1bf8cf2.tar.bz2 |
Wait properly for renderer crashes
This replaces a Sleep in automation with a wait for renderer crash. It turns out that our IPC on POSIX had one loophole that caused it not to notice very early crashes, so I also fixed that.
The problem was that when the child process died before connecting to the parent's IPC channel, the parent wouldn't notice the crash because the child end of the IPC pipe was kept open for too long. This change makes the code close the child end of the pipe right after forking the child.
This might also help with automation not noticing the browser crash during initial launch, or at least should be a good step toward fixing that problem.
BUG=38497,90489
Review URL: http://codereview.chromium.org/7870008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101760 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation/automation_provider_observers.cc')
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.cc | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index b5b058a..8377cc8 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -100,6 +100,7 @@ class InitialLoadObserver::TabTime { InitialLoadObserver::InitialLoadObserver(size_t tab_count, AutomationProvider* automation) : automation_(automation->AsWeakPtr()), + crashed_tab_count_(0), outstanding_tab_count_(tab_count), init_time_(base::TimeTicks::Now()) { if (outstanding_tab_count_ > 0) { @@ -107,6 +108,8 @@ InitialLoadObserver::InitialLoadObserver(size_t tab_count, NotificationService::AllSources()); registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); + registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, + NotificationService::AllSources()); } } @@ -128,12 +131,37 @@ void InitialLoadObserver::Observe(int type, finished_tabs_.insert(source.map_key()); iter->second.set_stop_time(base::TimeTicks::Now()); } - if (outstanding_tab_count_ == finished_tabs_.size()) - ConditionMet(); + } + } else if (type == content::NOTIFICATION_RENDERER_PROCESS_CLOSED) { + base::TerminationStatus status = + Details<RenderProcessHost::RendererClosedDetails>(details)->status; + switch (status) { + case base::TERMINATION_STATUS_NORMAL_TERMINATION: + break; + + case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: + case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: + case base::TERMINATION_STATUS_PROCESS_CRASHED: + crashed_tab_count_++; + break; + + case base::TERMINATION_STATUS_STILL_RUNNING: + LOG(ERROR) << "Got RENDERER_PROCESS_CLOSED notification, " + << "but the process is still running. We may miss further " + << "crash notification, resulting in hangs."; + break; + + default: + LOG(ERROR) << "Unhandled termination status " << status; + NOTREACHED(); + break; } } else { NOTREACHED(); } + + if (finished_tabs_.size() + crashed_tab_count_ >= outstanding_tab_count_) + ConditionMet(); } DictionaryValue* InitialLoadObserver::GetTimingInformation() const { |