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

Side by Side Diff: chrome/browser/chromeos/arc/process/arc_process_service.h

Issue 2495913002: arc: Convert more Mojo types to STL (Closed)
Patch Set: Rebased to ToT Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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_PROCESS_ARC_PROCESS_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_PROCESS_ARC_PROCESS_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_PROCESS_ARC_PROCESS_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_ARC_PROCESS_ARC_PROCESS_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/process/process_iterator.h" 15 #include "base/process/process_iterator.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "chrome/browser/chromeos/arc/process/arc_process.h" 18 #include "chrome/browser/chromeos/arc/process/arc_process.h"
19 #include "components/arc/arc_service.h" 19 #include "components/arc/arc_service.h"
20 #include "components/arc/common/process.mojom.h" 20 #include "components/arc/common/process.mojom.h"
21 #include "components/arc/instance_holder.h" 21 #include "components/arc/instance_holder.h"
22 #include "mojo/public/cpp/bindings/array.h"
23 22
24 namespace arc { 23 namespace arc {
25 24
26 class ArcBridgeService; 25 class ArcBridgeService;
27 26
28 // A single global entry to get a list of ARC processes. 27 // A single global entry to get a list of ARC processes.
29 // 28 //
30 // Call RequestAppProcessList() / RequestSystemProcessList() on the main UI 29 // Call RequestAppProcessList() / RequestSystemProcessList() on the main UI
31 // thread to get a list of all ARC app / system processes. It returns 30 // thread to get a list of all ARC app / system processes. It returns
32 // vector<arc::ArcProcess>, which includes pid <-> nspid mapping. 31 // vector<arc::ArcProcess>, which includes pid <-> nspid mapping.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 friend base::RefCountedThreadSafe<NSPidToPidMap>; 92 friend base::RefCountedThreadSafe<NSPidToPidMap>;
94 ~NSPidToPidMap(); 93 ~NSPidToPidMap();
95 94
96 PidMap pidmap_; 95 PidMap pidmap_;
97 DISALLOW_COPY_AND_ASSIGN(NSPidToPidMap); 96 DISALLOW_COPY_AND_ASSIGN(NSPidToPidMap);
98 }; 97 };
99 98
100 private: 99 private:
101 void OnReceiveProcessList( 100 void OnReceiveProcessList(
102 const RequestProcessListCallback& callback, 101 const RequestProcessListCallback& callback,
103 const mojo::Array<mojom::RunningAppProcessInfoPtr> instance_processes); 102 std::vector<mojom::RunningAppProcessInfoPtr> instance_processes);
104 103
105 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner(); 104 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner();
106 105
107 // There are some expensive tasks such as traverse whole process tree that 106 // There are some expensive tasks such as traverse whole process tree that
108 // we can't do it on the UI thread. Thus we need an additional thread to 107 // we can't do it on the UI thread. Thus we need an additional thread to
109 // handle 108 // handle
110 // such tasks. 109 // such tasks.
111 base::Thread heavy_task_thread_; 110 base::Thread heavy_task_thread_;
112 111
113 // Keep a cache pid mapping of all arc processes so to minimize the number of 112 // Keep a cache pid mapping of all arc processes so to minimize the number of
114 // nspid lookup from /proc/<PID>/status. 113 // nspid lookup from /proc/<PID>/status.
115 // To play safe, always modify |nspid_to_pid_| on the |heavy_task_thread_|. 114 // To play safe, always modify |nspid_to_pid_| on the |heavy_task_thread_|.
116 scoped_refptr<NSPidToPidMap> nspid_to_pid_; 115 scoped_refptr<NSPidToPidMap> nspid_to_pid_;
117 116
118 // Always keep this the last member of this class to make sure it's the 117 // Always keep this the last member of this class to make sure it's the
119 // first thing to be destructed. 118 // first thing to be destructed.
120 base::WeakPtrFactory<ArcProcessService> weak_ptr_factory_; 119 base::WeakPtrFactory<ArcProcessService> weak_ptr_factory_;
121 120
122 DISALLOW_COPY_AND_ASSIGN(ArcProcessService); 121 DISALLOW_COPY_AND_ASSIGN(ArcProcessService);
123 }; 122 };
124 123
125 } // namespace arc 124 } // namespace arc
126 125
127 #endif // CHROME_BROWSER_CHROMEOS_ARC_PROCESS_ARC_PROCESS_SERVICE_H_ 126 #endif // CHROME_BROWSER_CHROMEOS_ARC_PROCESS_ARC_PROCESS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698