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

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

Issue 10758009: Native Client Visual Studio Add-in (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Style Fixed 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/IProcessSearcher.cs
diff --git a/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/IProcessSearcher.cs b/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/IProcessSearcher.cs
new file mode 100644
index 0000000000000000000000000000000000000000..8f6870832ce14d456591e49f3e28e48b57969153
--- /dev/null
+++ b/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/IProcessSearcher.cs
@@ -0,0 +1,105 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+
+namespace NativeClientVSAddIn
+{
+ /// <summary>
+ /// Represents the standardized utility for retrieving the list
elijahtaylor1 2012/07/11 20:56:18 I don't understand what "standardized utility" you
tysand 2012/07/12 23:56:15 Done.
+ /// of running processes on the system
noelallen1 2012/07/11 22:16:46 system.
tysand 2012/07/12 23:56:15 Done.
+ /// </summary>
+ public interface IProcessSearcher
+ {
+ /// <summary>
+ /// Returns results of a process search subject to given constraints
+ /// </summary>
+ /// <param name="constraints">Constraints in the form 'field=target'</param>
+ /// <returns>List of matching processes</returns>
+ List<ProcessInfo> GetResults(String constraints);
+
+ /// <summary>
+ /// Searches the system for all processes of a given name
+ /// </summary>
+ /// <param name="name">Name to search for</param>
+ /// <returns>List of matching processes</returns>
+ List<ProcessInfo> GetResultsByName(String name);
+
+ /// <summary>
+ /// Searches the system for all processes of a given process ID
+ /// </summary>
+ /// <param name="procID">ID to search for</param>
+ /// <returns>List of matching processes</returns>
+ List<ProcessInfo> GetResultsByID(uint procID);
+ }
+
+ /// <summary>
+ /// Holds information about a process for a IProcessSearcher
+ /// </summary>
+ public class ProcessInfo
+ {
+ /// <summary>
+ /// Constructs a process entry
+ /// </summary>
+ /// <param name="id">Process ID</param>
+ /// <param name="parentId">Process ID of the parent process</param>
+ /// <param name="creationDate">
+ /// String date in format 'yyyyMMddHHmmss.ffffff', or if empty then current time used.
+ /// </param>
+ /// <param name="commandLine">Command line arguments to the process</param>
+ /// <param name="name">Process name</param>
+ public ProcessInfo(uint id, uint parentId, String creationDate,
+ String commandLine, String name)
+ {
+ // Convert an empty creationDate string into the current timestamp
+ if (String.IsNullOrEmpty(creationDate))
+ {
+ int timezoneMinutes = (int)Math.Round((DateTime.Now - DateTime.UtcNow).TotalMinutes);
+ creationDate = String.Format("{0:yyyyMMddHHmmss.ffffff}{1}", DateTime.Now, timezoneMinutes);
+ }
+
+ //Example creationDate returned: "20120622150149.843021-420"
elijahtaylor1 2012/07/11 20:56:18 space between // and Example
tysand 2012/07/12 23:56:15 Done.
+ CreationDate = DateTime.ParseExact(
+ creationDate.Substring(0, 21),
+ "yyyyMMddHHmmss.ffffff",
+ CultureInfo.InvariantCulture);
+ long timeZoneMinutes = long.Parse(creationDate.Substring(21));
+ CreationDate = CreationDate.AddMinutes(-timeZoneMinutes);
+
+ ID = id;
+ ParentID = parentId;
+ CommandLine = commandLine;
+ Name = name;
+ }
+
+ /// <summary>
+ /// Process ID
+ /// </summary>
+ public uint ID { get; set; }
elijahtaylor1 2012/07/11 20:56:18 Not sure about the naming of these properties. My
tysand 2012/07/12 23:56:15 To stay consistent with standard C# style (as used
+
+ /// <summary>
+ /// Process ID of the parent process
+ /// </summary>
+ public uint ParentID { get; set; }
+
+ /// <summary>
+ /// DateTime of the process creation
+ /// </summary>
+ public DateTime CreationDate { get; set; }
+
+ /// <summary>
+ /// Command line arguments to the process
+ /// </summary>
+ public String CommandLine { get; set; }
+
+ /// <summary>
+ /// Name of the process
+ /// </summary>
+ public String Name { get; set; }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698