Commit 463ea5fc authored by jam@chromium.org's avatar jam@chromium.org

Simplify BrowserChildProcessHost in preparation for refactoring it so that...

Simplify BrowserChildProcessHost in preparation for refactoring it so that consumers embed it in their class instead of deriving from it. The GetChildTerminationStatus override in NaclProcessHost seemed unnecessary since that's what the default implementation does. NaClProcessHost::OnChildDied can be done in the destructor.

BUG=98716
Review URL: http://codereview.chromium.org/8771041

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112877 0039d316-1c4b-4281-b951-d872f2087c98
parent ac198a50
...@@ -149,6 +149,10 @@ NaClProcessHost::~NaClProcessHost() { ...@@ -149,6 +149,10 @@ NaClProcessHost::~NaClProcessHost() {
reply_msg_->set_reply_error(); reply_msg_->set_reply_error();
chrome_render_message_filter_->Send(reply_msg_); chrome_render_message_filter_->Send(reply_msg_);
} }
#if defined(OS_WIN)
NaClBrokerService::GetInstance()->OnLoaderDied();
#endif
} }
// Attempt to ensure the IRT will be available when we need it, but don't wait. // Attempt to ensure the IRT will be available when we need it, but don't wait.
...@@ -293,11 +297,10 @@ void NaClProcessHost::OnProcessLaunchedByBroker(base::ProcessHandle handle) { ...@@ -293,11 +297,10 @@ void NaClProcessHost::OnProcessLaunchedByBroker(base::ProcessHandle handle) {
OnProcessLaunched(); OnProcessLaunched();
} }
base::TerminationStatus NaClProcessHost::GetChildTerminationStatus( void NaClProcessHost::OnProcessCrashed(int exit_code) {
int* exit_code) { std::string message = base::StringPrintf(
if (RunningOnWOW64()) "NaCl process exited with status %i (0x%x)", exit_code, exit_code);
return base::GetTerminationStatus(handle(), exit_code); LOG(ERROR) << message;
return BrowserChildProcessHost::GetChildTerminationStatus(exit_code);
} }
// This only ever runs on the BrowserThread::FILE thread. // This only ever runs on the BrowserThread::FILE thread.
......
...@@ -41,8 +41,7 @@ class NaClProcessHost : public BrowserChildProcessHost { ...@@ -41,8 +41,7 @@ class NaClProcessHost : public BrowserChildProcessHost {
void OnProcessLaunchedByBroker(base::ProcessHandle handle); void OnProcessLaunchedByBroker(base::ProcessHandle handle);
protected: protected:
virtual base::TerminationStatus GetChildTerminationStatus( virtual void OnProcessCrashed(int exit_code) OVERRIDE;
int* exit_code) OVERRIDE;
private: private:
// Internal class that holds the nacl::Handle objecs so that // Internal class that holds the nacl::Handle objecs so that
......
...@@ -131,6 +131,8 @@ void BrowserChildProcessHost::Notify(int type) { ...@@ -131,6 +131,8 @@ void BrowserChildProcessHost::Notify(int type) {
base::TerminationStatus BrowserChildProcessHost::GetChildTerminationStatus( base::TerminationStatus BrowserChildProcessHost::GetChildTerminationStatus(
int* exit_code) { int* exit_code) {
if (!child_process_.get()) // If the delegate doesn't use Launch() helper.
return base::GetTerminationStatus(handle(), exit_code);
return child_process_->GetChildTerminationStatus(exit_code); return child_process_->GetChildTerminationStatus(exit_code);
} }
...@@ -174,9 +176,7 @@ void BrowserChildProcessHost::OnChildDisconnected() { ...@@ -174,9 +176,7 @@ void BrowserChildProcessHost::OnChildDisconnected() {
break; break;
} }
case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: { case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: {
OnProcessWasKilled(exit_code);
// Report that this child process was killed. // Report that this child process was killed.
Notify(content::NOTIFICATION_CHILD_PROCESS_WAS_KILLED);
UMA_HISTOGRAM_ENUMERATION("ChildProcess.Killed", UMA_HISTOGRAM_ENUMERATION("ChildProcess.Killed",
this->type(), this->type(),
content::PROCESS_TYPE_MAX); content::PROCESS_TYPE_MAX);
......
...@@ -99,19 +99,13 @@ class CONTENT_EXPORT BrowserChildProcessHost : ...@@ -99,19 +99,13 @@ class CONTENT_EXPORT BrowserChildProcessHost :
// GetExitCodeProcess()). // GetExitCodeProcess()).
virtual void OnProcessCrashed(int exit_code) {} virtual void OnProcessCrashed(int exit_code) {}
// Derived classes can override this to know if the process was
// killed. |exit_code| is the status returned when the process
// was killed (for posix, as returned from waitpid(), for Windows,
// as returned from GetExitCodeProcess()).
virtual void OnProcessWasKilled(int exit_code) {}
// Returns the termination status of a child. |exit_code| is the // Returns the termination status of a child. |exit_code| is the
// status returned when the process exited (for posix, as returned // status returned when the process exited (for posix, as returned
// from waitpid(), for Windows, as returned from // from waitpid(), for Windows, as returned from
// GetExitCodeProcess()). |exit_code| may be NULL. // GetExitCodeProcess()). |exit_code| may be NULL.
virtual base::TerminationStatus GetChildTerminationStatus(int* exit_code); base::TerminationStatus GetChildTerminationStatus(int* exit_code);
// ChildProcessHostDelegate implementation: // Overrides from ChildProcessHost
virtual bool CanShutdown() OVERRIDE; virtual bool CanShutdown() OVERRIDE;
virtual void OnChildDisconnected() OVERRIDE; virtual void OnChildDisconnected() OVERRIDE;
virtual void ShutdownStarted() OVERRIDE; virtual void ShutdownStarted() OVERRIDE;
......
...@@ -391,13 +391,6 @@ enum NotificationType { ...@@ -391,13 +391,6 @@ enum NotificationType {
// a Details<content::ChildProcessData>. // a Details<content::ChildProcessData>.
NOTIFICATION_CHILD_PROCESS_CRASHED, NOTIFICATION_CHILD_PROCESS_CRASHED,
// This message is sent when a child process disappears
// unexpectedly as a result of a termination signal. There is no
// usable source, since it is sent from an ephemeral task;
// register for AllSources() to receive this notification. The
// details are in a Details<content::ChildProcessData>.
NOTIFICATION_CHILD_PROCESS_WAS_KILLED,
// This message indicates that an instance of a particular child was // This message indicates that an instance of a particular child was
// created in a page. (If one page contains several regions rendered by // created in a page. (If one page contains several regions rendered by
// the same child, this notification will occur once for each region // the same child, this notification will occur once for each region
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment