| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // The main point of this class is to cache ARC proc nspid<->pid mapping | 5 // The main point of this class is to cache ARC proc nspid<->pid mapping |
| 6 // globally. Since the calculation is costly, a dedicated worker thread is | 6 // globally. Since the calculation is costly, a dedicated worker thread is |
| 7 // used. All read/write of its internal data structure (i.e., the mapping) | 7 // used. All read/write of its internal data structure (i.e., the mapping) |
| 8 // should be on this thread. | 8 // should be on this thread. |
| 9 | 9 |
| 10 #include "chrome/browser/chromeos/arc/arc_process_service.h" | 10 #include "chrome/browser/chromeos/arc/arc_process_service.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 void ArcProcessService::PopulateProcessList( | 165 void ArcProcessService::PopulateProcessList( |
| 166 const vector<arc::mojom::RunningAppProcessInfoPtr>* raw_processes, | 166 const vector<arc::mojom::RunningAppProcessInfoPtr>* raw_processes, |
| 167 vector<ArcProcess>* ret_processes) { | 167 vector<ArcProcess>* ret_processes) { |
| 168 DCHECK(thread_checker_.CalledOnValidThread()); | 168 DCHECK(thread_checker_.CalledOnValidThread()); |
| 169 | 169 |
| 170 for (const auto& entry : *raw_processes) { | 170 for (const auto& entry : *raw_processes) { |
| 171 const auto it = nspid_to_pid_.find(entry->pid); | 171 const auto it = nspid_to_pid_.find(entry->pid); |
| 172 // In case the process already dies so couldn't find corresponding pid. | 172 // In case the process already dies so couldn't find corresponding pid. |
| 173 if (it != nspid_to_pid_.end() && it->second != kNullProcessId) { | 173 if (it != nspid_to_pid_.end() && it->second != kNullProcessId) { |
| 174 ArcProcess arc_process(entry->pid, it->second, entry->process_name, | 174 ArcProcess arc_process(entry->pid, it->second, entry->process_name, |
| 175 entry->process_state); | 175 entry->process_state, entry->is_focused, |
| 176 entry->last_activity_time); |
| 176 // |entry->packages| is provided only when process.mojom's verion is >=4. | 177 // |entry->packages| is provided only when process.mojom's verion is >=4. |
| 177 if (entry->packages) { | 178 if (entry->packages) { |
| 178 for (const auto& package : entry->packages) { | 179 for (const auto& package : entry->packages) { |
| 179 arc_process.packages().push_back(package.get()); | 180 arc_process.packages().push_back(package.get()); |
| 180 } | 181 } |
| 181 } | 182 } |
| 182 ret_processes->push_back(std::move(arc_process)); | 183 ret_processes->push_back(std::move(arc_process)); |
| 183 } | 184 } |
| 184 } | 185 } |
| 185 } | 186 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 nspid_to_pid_.find(nspid) != nspid_to_pid_.end()) | 243 nspid_to_pid_.find(nspid) != nspid_to_pid_.end()) |
| 243 nspid_to_pid_[nspid] = pid; | 244 nspid_to_pid_[nspid] = pid; |
| 244 | 245 |
| 245 for (ProcessId child_pid : process_tree[pid]) | 246 for (ProcessId child_pid : process_tree[pid]) |
| 246 queue.push(child_pid); | 247 queue.push(child_pid); |
| 247 } | 248 } |
| 248 } | 249 } |
| 249 } | 250 } |
| 250 | 251 |
| 251 } // namespace arc | 252 } // namespace arc |
| OLD | NEW |