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

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

Issue 2025593003: Show all system process in the task_manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing member variable. Created 4 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/chromeos/arc/arc_process_service.cc
diff --git a/chrome/browser/chromeos/arc/arc_process_service.cc b/chrome/browser/chromeos/arc/arc_process_service.cc
index e8dc49b233a105ad26ed335c91a86db621210a8d..d8379157137c8aed62079549d956e59c752ecca1 100644
--- a/chrome/browser/chromeos/arc/arc_process_service.cc
+++ b/chrome/browser/chromeos/arc/arc_process_service.cc
@@ -77,7 +77,48 @@ void ArcProcessService::Reset() {
nspid_to_pid_.clear();
}
-bool ArcProcessService::RequestProcessList(
+bool ArcProcessService::RequestSystemProcessList(
cylee1 2016/06/02 20:58:45 nit: can you try to consolidate the logic here and
Hsu-Cheng 2016/06/29 10:33:57 Done.
+ RequestProcessListCallback callback) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ auto ret_processes = new vector<ArcProcess>();
+ auto runner = worker_pool_->GetSequencedTaskRunner(
Yusuke Sato 2016/06/02 21:50:11 Why does this have to be sequenced, btw?
Hsu-Cheng 2016/06/29 10:33:57 The pool size here is 1 and this is for avoid runn
+ worker_pool_->GetNamedSequenceToken(kSequenceToken));
+ runner->PostTaskAndReply(
+ FROM_HERE, base::Bind(&ArcProcessService::FetchAndReturnSystemProcessList,
+ weak_ptr_factory_.GetWeakPtr(),
+ base::Unretained(ret_processes)),
+ base::Bind(&ArcProcessService::CallbackRelay,
+ weak_ptr_factory_.GetWeakPtr(), callback,
+ base::Owned(ret_processes)));
+ return true;
cylee1 2016/06/02 20:58:45 Always return true?
Hsu-Cheng 2016/06/29 10:33:57 Done.
+}
+
+void ArcProcessService::FetchAndReturnSystemProcessList(
cylee1 2016/06/02 20:58:44 Maybe GetArcSystemProcessList
Hsu-Cheng 2016/06/29 10:33:57 Done.
+ vector<ArcProcess>* ret_processes) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ const base::ProcessIterator::ProcessEntries& entry_list =
+ base::ProcessIterator(nullptr).Snapshot();
+ ProcessId arc_init_pid = GetArcInitProcessId(entry_list);
cylee1 2016/06/02 20:58:45 You should check if it's kNullProcessId before doi
Hsu-Cheng 2016/06/29 10:33:56 Done.
+
+ // Enumerate the child processes of ARC init for gaterhing ARC system procces
cylee1 2016/06/02 20:58:44 nit: gathering nit: processes I think you should
Hsu-Cheng 2016/06/29 10:33:57 Added system process definition in arc_process_ser
+ for (const base::ProcessEntry& entry : entry_list) {
+ std::string process_name =
cylee1 2016/06/02 20:58:44 why not get process_name inside the if at line 109
Hsu-Cheng 2016/06/29 10:33:57 Done.
+ !entry.cmd_line_args().empty() ? entry.cmd_line_args()[0] : "";
+ if (entry.parent_pid() == arc_init_pid) {
Yusuke Sato 2016/06/02 21:50:11 This will only detect direct children of the init
Hsu-Cheng 2016/06/29 10:33:57 You are right. I miss the case. I will make a new
+ ProcessId child_pid = entry.pid();
+ ProcessId child_nspid = base::Process(child_pid).GetPidInNamespace();
+ if (child_nspid != kNullProcessId) {
+ ArcProcess arc_process = {child_nspid, child_pid, process_name,
Yusuke Sato 2016/06/02 21:50:11 This no longer compiles once you rebase your Chrom
Hsu-Cheng 2016/06/29 10:33:57 Done.
+ mojom::ProcessState::PERSISTENT};
+ ret_processes->push_back(arc_process);
+ }
+ }
+ }
+}
+
+bool ArcProcessService::RequestAppProcessList(
RequestProcessListCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -201,16 +242,7 @@ void ArcProcessService::UpdateNspidToPidMap() {
process_tree[entry.parent_pid()].push_back(entry.pid());
// Find the ARC init process.
- ProcessId arc_init_pid = kNullProcessId;
- for (const base::ProcessEntry& entry : entry_list) {
- // TODO(nya): Add more constraints to avoid mismatches.
- std::string process_name =
- !entry.cmd_line_args().empty() ? entry.cmd_line_args()[0] : "";
- if (process_name == "/init") {
- arc_init_pid = entry.pid();
- break;
- }
- }
+ ProcessId arc_init_pid = GetArcInitProcessId(entry_list);
// Enumerate all processes under ARC init and create nspid -> pid map.
if (arc_init_pid != kNullProcessId) {
@@ -241,4 +273,18 @@ void ArcProcessService::UpdateNspidToPidMap() {
}
}
+ProcessId ArcProcessService::GetArcInitProcessId(
+ const base::ProcessIterator::ProcessEntries& entry_list) {
+ // Find the ARC init process.
+ for (const base::ProcessEntry& entry : entry_list) {
+ // TODO(nya): Add more constraints to avoid mismatches.
+ std::string process_name =
+ !entry.cmd_line_args().empty() ? entry.cmd_line_args()[0] : "";
+ if (process_name == "/init") {
+ return entry.pid();
+ }
+ }
+ return kNullProcessId;
+}
+
} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698