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

Unified Diff: chrome/browser/process_singleton_posix.cc

Issue 2871793003: Added histograms on process singleton create when remote process exists and we cannot notify it (Closed)
Patch Set: Some fixes basing on review comments Created 3 years, 7 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: chrome/browser/process_singleton_posix.cc
diff --git a/chrome/browser/process_singleton_posix.cc b/chrome/browser/process_singleton_posix.cc
index f8786c67e6404c2678b65f8c0b16da815ce02d74..cf234d0a71e0aeb79d1f8dec98195eb2e65baf98 100644
--- a/chrome/browser/process_singleton_posix.cc
+++ b/chrome/browser/process_singleton_posix.cc
@@ -464,6 +464,20 @@ bool ReplaceOldSingletonLock(const base::FilePath& symlink_content,
}
#endif // defined(OS_MACOSX)
+void SendRemoteProcessInteractionResultHistogram(
+ ProcessSingleton::RemoteProcessInteractionResult result) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "Chrome.ProcessSingleton.RemoteProcessInteractionResult", result,
+ ProcessSingleton::REMOTE_PROCESS_INTERACTION_RESULT_COUNT);
+}
+
+void SendRemoteHungProcessTerminateReasonHistogram(
+ ProcessSingleton::RemoteHungProcessTerminateReason reason) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "Chrome.ProcessSingleton.RemoteHungProcessTerminateReason", reason,
+ ProcessSingleton::REMOTE_HUNG_PROCESS_TERMINATE_REASON_COUNT);
+}
+
} // namespace
///////////////////////////////////////////////////////////////////////////////
@@ -776,6 +790,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
if (hostname.empty()) {
// Invalid lockfile.
UnlinkPath(lock_path_);
+ SendRemoteProcessInteractionResultHistogram(INVALID_LOCK_FILE);
return PROCESS_NONE;
}
@@ -784,6 +799,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
// the profile, try to continue; otherwise quit.
if (DisplayProfileInUseError(lock_path_, hostname, pid)) {
UnlinkPath(lock_path_);
+ SendRemoteProcessInteractionResultHistogram(PROFILE_UNLOCKED);
return PROCESS_NONE;
}
return PROFILE_IN_USE;
@@ -792,6 +808,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
if (!IsChromeProcess(pid)) {
// Orphaned lockfile (no process with pid, or non-chrome process.)
UnlinkPath(lock_path_);
+ SendRemoteProcessInteractionResultHistogram(ORPHANED_LOCK_FILE);
return PROCESS_NONE;
}
@@ -799,6 +816,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
// Orphaned lockfile (pid is part of same chrome instance we are, even
// though we haven't tried to create a lockfile yet).
UnlinkPath(lock_path_);
+ SendRemoteProcessInteractionResultHistogram(SAME_BROWSER_INSTANCE);
return PROCESS_NONE;
}
@@ -806,6 +824,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
// Retries failed. Kill the unresponsive chrome process and continue.
if (!kill_unresponsive || !KillProcessByLockPath())
return PROFILE_IN_USE;
+ SendRemoteHungProcessTerminateReasonHistogram(NOTIFY_ATTEMPTS_EXCEEDED);
return PROCESS_NONE;
}
@@ -841,6 +860,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
// Try to kill the other process, because it might have been dead.
if (!kill_unresponsive || !KillProcessByLockPath())
return PROFILE_IN_USE;
+ SendRemoteHungProcessTerminateReasonHistogram(SOCKET_WRITE_FAILED);
return PROCESS_NONE;
}
@@ -856,12 +876,14 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
if (len <= 0) {
if (!kill_unresponsive || !KillProcessByLockPath())
return PROFILE_IN_USE;
+ SendRemoteHungProcessTerminateReasonHistogram(SOCKET_READ_FAILED);
return PROCESS_NONE;
}
buf[len] = '\0';
if (strncmp(buf, kShutdownToken, arraysize(kShutdownToken) - 1) == 0) {
// The other process is shutting down, it's safe to start a new process.
+ SendRemoteProcessInteractionResultHistogram(REMOTE_PROCESS_SHUTTING_DOWN);
return PROCESS_NONE;
} else if (strncmp(buf, kACKToken, arraysize(kACKToken) - 1) == 0) {
#if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
@@ -1057,18 +1079,25 @@ bool ProcessSingleton::KillProcessByLockPath() {
ParseLockPath(lock_path_, &hostname, &pid);
if (!hostname.empty() && hostname != net::GetHostName()) {
- return DisplayProfileInUseError(lock_path_, hostname, pid);
+ bool res = DisplayProfileInUseError(lock_path_, hostname, pid);
+ if (res)
+ SendRemoteProcessInteractionResultHistogram(PROFILE_UNLOCKED);
+ return res;
}
UnlinkPath(lock_path_);
- if (IsSameChromeInstance(pid))
+ if (IsSameChromeInstance(pid)) {
+ SendRemoteProcessInteractionResultHistogram(SAME_BROWSER_INSTANCE);
return true;
+ }
if (pid > 0) {
kill_callback_.Run(pid);
return true;
}
+ SendRemoteProcessInteractionResultHistogram(FAILED_TO_EXTRACT_PID);
+
LOG(ERROR) << "Failed to extract pid from path: " << lock_path_.value();
return true;
}
@@ -1080,4 +1109,24 @@ void ProcessSingleton::KillProcess(int pid) {
// progress of shutting down and finishes before we try to kill it).
DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: "
<< base::safe_strerror(errno);
+
+ int error_code = (rv == 0) ? 0 : errno;
+ UMA_HISTOGRAM_SPARSE_SLOWLY(
+ "Chrome.ProcessSingleton.TerminateProcessErrorCode.Posix", error_code);
+
+ RemoteProcessInteractionResult action = TERMINATE_SUCCEEDED;
+ if (rv != 0) {
+ switch (error_code) {
+ case ESRCH:
+ action = REMOTE_PROCESS_NOT_FOUND;
+ break;
+ case EPERM:
+ action = TERMINATE_NOT_ENOUGH_PERMISSIONS;
+ break;
+ default:
+ action = TERMINATE_FAILED;
+ break;
+ }
+ }
+ SendRemoteProcessInteractionResultHistogram(action);
}

Powered by Google App Engine
This is Rietveld 408576698