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

Unified Diff: visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/ProcessSearcher.cs

Issue 10831030: NaCl settings and completed install scripts. (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 8 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: visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/ProcessSearcher.cs
diff --git a/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/ProcessSearcher.cs b/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/ProcessSearcher.cs
index b76882878d97e5490cc88f716f061d0acc4b9630..ceb3b0dab1660332b39dad7e3497eb7e8ff831db 100644
--- a/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/ProcessSearcher.cs
+++ b/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/ProcessSearcher.cs
@@ -48,6 +48,30 @@ namespace NativeClientVSAddIn
}
/// <summary>
+ /// Returns a list of all descendant processes of a process.
+ /// </summary>
+ /// <param name="root">Process ID of the process to get all descendants from.</param>
+ /// <returns>All descendants of the given root process.</returns>
+ public List<ProcessInfo> GetDescendants(uint root)
+ {
+ List<ProcessInfo> processes = GetSystemProcesses();
+ HashSet<ProcessInfo> descendants = new HashSet<ProcessInfo>();
+ descendants.UnionWith(processes.Where(p => p.ID == root));
+ int lastCount = 0;
+ while (descendants.Count > lastCount)
+ {
+ lastCount = descendants.Count;
+
+ // Add any processes who have a parent that is in the descendant list already.
+ // Note we check the creation date to prevent cycles caused by recycled process IDs.
+ descendants.UnionWith(processes.Where(p => descendants.Any(
+ parent => parent.ID == p.ParentID && parent.CreationDate <= p.CreationDate)));
+ }
+
+ return descendants.ToList();
+ }
+
+ /// <summary>
/// Queries the system for the full list of processes.
/// </summary>
/// <returns>List of processes on the system.</returns>

Powered by Google App Engine
This is Rietveld 408576698