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

Unified Diff: chrome/browser/chromeos/arc/arc_process_service.h

Issue 2025593003: Show all system process in the task_manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First step of refactor. Eliminate pointers and migrate to PostTaskAndReplyWithResult(). Need more w… Created 4 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: chrome/browser/chromeos/arc/arc_process_service.h
diff --git a/chrome/browser/chromeos/arc/arc_process_service.h b/chrome/browser/chromeos/arc/arc_process_service.h
index 231c58dd7389aca66b9f7f826c2bb68b58ad46e0..860ad874074a1b55b81ccde25e75abd02493bfa8 100644
--- a/chrome/browser/chromeos/arc/arc_process_service.h
+++ b/chrome/browser/chromeos/arc/arc_process_service.h
@@ -8,9 +8,11 @@
#include <map>
#include <vector>
-#include "base/callback.h"
+#include "base/callback_forward.h"
+#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
+#include "base/process/process_iterator.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_checker.h"
#include "chrome/browser/chromeos/arc/arc_process.h"
@@ -21,21 +23,29 @@ namespace arc {
// A single global entry to get a list of ARC processes.
//
-// Call RequestProcessList() on the main UI thread to get a list of all ARC
-// processes. It returns vector<arc::ArcProcess>, which includes pid <-> nspid
-// mapping.
+// Call RequestAppProcessList() / RequestSystemProcessList() on the main UI
+// thread to get a list of all ARC app / system processes. It returns
+// vector<arc::ArcProcess>, which includes pid <-> nspid mapping.
// Example:
// void OnUpdateProcessList(const vector<arc::ArcProcess>&) {...}
//
// arc::ArcProcessService* arc_process_service =
// arc::ArcProcessService::Get();
// if (!arc_process_service ||
-// !arc_process_service->RequestProcessList(
+// !arc_process_service->RequestAppProcessList(
// base::Bind(&OnUpdateProcessList)) {
// LOG(ERROR) << "ARC process instance not ready.";
// }
+//
+// [System Process]
+// The system process here is defined by the scope. If the process is produced
+// under system_server in Android, we regard it as one of Android app process.
+// Otherwise, the processes that are introduced by init would then be regarded
+// as System Process. RequestAppProcessList() is responsible for app processes
+// while RequestSystemProcessList() is responsible for System Processes.
class ArcProcessService : public ArcService,
- public ArcBridgeService::Observer {
+ public ArcBridgeService::Observer,
+ public base::RefCountedThreadSafe<ArcProcessService> {
Luis Héctor Chávez 2016/07/06 19:49:15 This is a bit problematic, since RefCounted needs
public:
using RequestProcessListCallback =
base::Callback<void(const std::vector<ArcProcess>&)>;
@@ -51,7 +61,8 @@ class ArcProcessService : public ArcService,
// Returns true if ARC IPC is ready for process list request,
// otherwise false.
- bool RequestProcessList(RequestProcessListCallback callback);
+ bool RequestAppProcessList(RequestProcessListCallback callback);
+ void RequestSystemProcessList(RequestProcessListCallback callback);
private:
void Reset();
@@ -60,20 +71,22 @@ class ArcProcessService : public ArcService,
const RequestProcessListCallback& callback,
mojo::Array<arc::mojom::RunningAppProcessInfoPtr> mojo_processes);
- void CallbackRelay(
- const RequestProcessListCallback& callback,
- const std::vector<ArcProcess>* ret_processes);
+ std::vector<ArcProcess> UpdateAndReturnProcessList(
+ const std::vector<ArcProcess>& raw_processes);
- void UpdateAndReturnProcessList(
- const std::vector<arc::mojom::RunningAppProcessInfoPtr>* raw_processes,
- std::vector<ArcProcess>* ret_processes);
+ std::vector<ArcProcess> PopulateProcessList(
+ const std::vector<ArcProcess>& raw_processes);
- void PopulateProcessList(
- const std::vector<arc::mojom::RunningAppProcessInfoPtr>* raw_processes,
- std::vector<ArcProcess>* ret_processes);
+ std::vector<ArcProcess> ConvertMojoProcess(
+ mojo::Array<arc::mojom::RunningAppProcessInfoPtr>& mojo_processes);
void UpdateNspidToPidMap();
+ static std::vector<ArcProcess> GetArcSystemProcessList();
Luis Héctor Chávez 2016/07/06 20:28:12 Prefer having these two in the anonymous namespace
+
+ static base::ProcessId GetArcInitProcessId(
+ const base::ProcessIterator::ProcessEntries& entry_list);
+
// Keep a cache pid mapping of all arc processes so to minimize the number of
// nspid lookup from /proc/<PID>/status.
// To play safe, always modify |nspid_to_pid_| on the worker thread.
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/arc_process_service.cc » ('j') | chrome/browser/chromeos/arc/arc_process_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698