| 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 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_PROCESS_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_PROCESS_SERVICE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_PROCESS_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_PROCESS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 // Returns true if ARC IPC is ready for process list request, | 52 // Returns true if ARC IPC is ready for process list request, |
| 53 // otherwise false. | 53 // otherwise false. |
| 54 bool RequestProcessList(RequestProcessListCallback callback); | 54 bool RequestProcessList(RequestProcessListCallback callback); |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 void Reset(); | 57 void Reset(); |
| 58 | 58 |
| 59 void OnReceiveProcessList( | 59 void OnReceiveProcessList( |
| 60 const RequestProcessListCallback& callback, | 60 const RequestProcessListCallback& callback, |
| 61 mojo::Array<arc::RunningAppProcessInfoPtr> mojo_processes); | 61 mojo::Array<arc::mojom::RunningAppProcessInfoPtr> mojo_processes); |
| 62 | 62 |
| 63 void CallbackRelay( | 63 void CallbackRelay( |
| 64 const RequestProcessListCallback& callback, | 64 const RequestProcessListCallback& callback, |
| 65 const std::vector<ArcProcess>* ret_processes); | 65 const std::vector<ArcProcess>* ret_processes); |
| 66 | 66 |
| 67 void UpdateAndReturnProcessList( | 67 void UpdateAndReturnProcessList( |
| 68 const std::vector<arc::RunningAppProcessInfoPtr>* raw_processes, | 68 const std::vector<arc::mojom::RunningAppProcessInfoPtr>* raw_processes, |
| 69 std::vector<ArcProcess>* ret_processes); | 69 std::vector<ArcProcess>* ret_processes); |
| 70 | 70 |
| 71 void PopulateProcessList( | 71 void PopulateProcessList( |
| 72 const std::vector<arc::RunningAppProcessInfoPtr>* raw_processes, | 72 const std::vector<arc::mojom::RunningAppProcessInfoPtr>* raw_processes, |
| 73 std::vector<ArcProcess>* ret_processes); | 73 std::vector<ArcProcess>* ret_processes); |
| 74 | 74 |
| 75 void UpdateNspidToPidMap(); | 75 void UpdateNspidToPidMap(); |
| 76 | 76 |
| 77 // Keep a cache pid mapping of all arc processes so to minimize the number of | 77 // Keep a cache pid mapping of all arc processes so to minimize the number of |
| 78 // nspid lookup from /proc/<PID>/status. | 78 // nspid lookup from /proc/<PID>/status. |
| 79 // To play safe, always modify |nspid_to_pid_| on the worker thread. | 79 // To play safe, always modify |nspid_to_pid_| on the worker thread. |
| 80 std::map<base::ProcessId, base::ProcessId> nspid_to_pid_; | 80 std::map<base::ProcessId, base::ProcessId> nspid_to_pid_; |
| 81 | 81 |
| 82 scoped_refptr<base::SequencedWorkerPool> worker_pool_; | 82 scoped_refptr<base::SequencedWorkerPool> worker_pool_; |
| 83 | 83 |
| 84 // To ensure internal state changes are done on the same worker thread. | 84 // To ensure internal state changes are done on the same worker thread. |
| 85 base::ThreadChecker thread_checker_; | 85 base::ThreadChecker thread_checker_; |
| 86 | 86 |
| 87 // Always keep this the last member of this class to make sure it's the | 87 // Always keep this the last member of this class to make sure it's the |
| 88 // first thing to be destructed. | 88 // first thing to be destructed. |
| 89 base::WeakPtrFactory<ArcProcessService> weak_ptr_factory_; | 89 base::WeakPtrFactory<ArcProcessService> weak_ptr_factory_; |
| 90 | 90 |
| 91 DISALLOW_COPY_AND_ASSIGN(ArcProcessService); | 91 DISALLOW_COPY_AND_ASSIGN(ArcProcessService); |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 } // namespace arc | 94 } // namespace arc |
| 95 | 95 |
| 96 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_PROCESS_SERVICE_H_ | 96 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_PROCESS_SERVICE_H_ |
| OLD | NEW |