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

Side by Side Diff: chrome/browser/task_management/providers/arc/arc_process_task_provider.h

Issue 2025593003: Show all system process in the task_manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change NsPidToPidMap to composite. Move static functions to anonymous namespace. Some style change. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDER_H _ 5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDER_H _
6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDER_H _ 6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDER_H _
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
16 #include "base/process/process.h" 17 #include "base/process/process.h"
17 #include "chrome/browser/chromeos/arc/arc_process.h" 18 #include "chrome/browser/chromeos/arc/arc_process.h"
18 #include "chrome/browser/task_management/providers/arc/arc_process_task.h" 19 #include "chrome/browser/task_management/providers/arc/arc_process_task.h"
19 #include "chrome/browser/task_management/providers/task_provider.h" 20 #include "chrome/browser/task_management/providers/task_provider.h"
20 21
21 namespace task_management { 22 namespace task_management {
22 23
23 // This provides the ARC process tasks. 24 // This provides the ARC process tasks.
24 // 25 //
25 // Since this provider obtains ARC process information via IPC and procfs, 26 // Since this provider obtains ARC process information via IPC and procfs,
26 // it can never avoid race conditions. For example, in an extreme case such as 27 // it can never avoid race conditions. For example, in an extreme case such as
27 // fork(2) is called millions of times in a second, this provider can return 28 // fork(2) is called millions of times in a second, this provider can return
28 // wrong results. However, its chance is very low, and even if we hit the case, 29 // wrong results. However, its chance is very low, and even if we hit the case,
29 // the worst outcome is just that an app (non-system) process which 30 // the worst outcome is just that an app (non-system) process which
30 // the user did not intend to choose is killed. Since apps are designed 31 // the user did not intend to choose is killed. Since apps are designed
31 // to be killed at any time, it sounds acceptable. 32 // to be killed at any time, it sounds acceptable.
32 class ArcProcessTaskProvider : public TaskProvider { 33 class ArcProcessTaskProvider : public TaskProvider {
33 public: 34 public:
34 ArcProcessTaskProvider(); 35 ArcProcessTaskProvider();
35 ~ArcProcessTaskProvider() override; 36 ~ArcProcessTaskProvider() override;
36 37
37 // task_management::TaskProvider: 38 // task_management::TaskProvider:
38 Task* GetTaskOfUrlRequest(int origin_pid, 39 Task* GetTaskOfUrlRequest(int origin_pid,
39 int child_id, 40 int child_id,
40 int route_id) override; 41 int route_id) override;
41 42
42 private: 43 private:
44 using ArcTaskMap =
45 std::unordered_map<base::ProcessId, std::unique_ptr<ArcProcessTask>>;
46 void ScheduleNextRequest(const base::Closure& task, const int delaySeconds);
47
43 // Auto-retry if ARC bridge service is not ready. 48 // Auto-retry if ARC bridge service is not ready.
44 void RequestProcessList(); 49 void RequestAppProcessList();
50 void RequestSystemProcessList();
45 51
46 void OnUpdateProcessList(const std::vector<arc::ArcProcess>& processes); 52 void UpdateProcessList(
53 ArcTaskMap* pid_to_task,
54 const std::vector<arc::ArcProcess>& processes);
55 void OnUpdateAppProcessList(const std::vector<arc::ArcProcess>& processes);
56 void OnUpdateSystemProcessList(const std::vector<arc::ArcProcess>& processes);
47 57
48 // task_management::TaskProvider: 58 // task_management::TaskProvider:
49 void StartUpdating() override; 59 void StartUpdating() override;
50 void StopUpdating() override; 60 void StopUpdating() override;
51 61
52 void ScheduleNextRequest(); 62 void ScheduleNextAppRequest();
63 void ScheduleNextSystemRequest();
53 64
54 std::map<base::ProcessId, std::unique_ptr<ArcProcessTask>> nspid_to_task_; 65 ArcTaskMap nspid_to_task_;
66 ArcTaskMap nspid_to_sys_task_;
55 67
56 // Whether to continue the periodical polling. 68 // Whether to continue the periodical polling.
57 bool is_updating_; 69 bool is_updating_;
58 70
59 // Always keep this the last member of this class to make sure it's the 71 // Always keep this the last member of this class to make sure it's the
60 // first thing to be destructed. 72 // first thing to be destructed.
61 base::WeakPtrFactory<ArcProcessTaskProvider> weak_ptr_factory_; 73 base::WeakPtrFactory<ArcProcessTaskProvider> weak_ptr_factory_;
62 74
63 DISALLOW_COPY_AND_ASSIGN(ArcProcessTaskProvider); 75 DISALLOW_COPY_AND_ASSIGN(ArcProcessTaskProvider);
64 }; 76 };
65 77
66 } // namespace task_management 78 } // namespace task_management
67 79
68 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDE R_H_ 80 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_ARC_ARC_PROCESS_TASK_PROVIDE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698