OLD | NEW |
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_SAMPLING_TASK_GROUP_SAMPLER_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_SAMPLER_H_ |
6 #define CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_SAMPLER_H_ | 6 #define CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_SAMPLER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
10 #include "base/process/process.h" | 13 #include "base/process/process.h" |
11 #include "base/process/process_handle.h" | 14 #include "base/process/process_handle.h" |
12 #include "base/process/process_metrics.h" | 15 #include "base/process/process_metrics.h" |
13 #include "base/sequence_checker.h" | 16 #include "base/sequence_checker.h" |
14 #include "base/sequenced_task_runner.h" | 17 #include "base/sequenced_task_runner.h" |
| 18 #include "build/build_config.h" |
15 | 19 |
16 namespace task_management { | 20 namespace task_management { |
17 | 21 |
18 // Wraps the memory usage stats values together so that it can be sent between | 22 // Wraps the memory usage stats values together so that it can be sent between |
19 // the UI and the worker threads. | 23 // the UI and the worker threads. |
20 struct MemoryUsageStats { | 24 struct MemoryUsageStats { |
21 int64 private_bytes; | 25 int64_t private_bytes; |
22 int64 shared_bytes; | 26 int64_t shared_bytes; |
23 int64 physical_bytes; | 27 int64_t physical_bytes; |
24 | 28 |
25 MemoryUsageStats() | 29 MemoryUsageStats() |
26 : private_bytes(-1), | 30 : private_bytes(-1), |
27 shared_bytes(-1), | 31 shared_bytes(-1), |
28 physical_bytes(-1) { | 32 physical_bytes(-1) { |
29 } | 33 } |
30 }; | 34 }; |
31 | 35 |
32 // Defines the expensive process' stats sampler that will calculate these | 36 // Defines the expensive process' stats sampler that will calculate these |
33 // resources on the worker thread. Objects of this class are created by the | 37 // resources on the worker thread. Objects of this class are created by the |
(...skipping 17 matching lines...) Expand all Loading... |
51 const OnCpuRefreshCallback& on_cpu_refresh, | 55 const OnCpuRefreshCallback& on_cpu_refresh, |
52 const OnMemoryRefreshCallback& on_memory_refresh, | 56 const OnMemoryRefreshCallback& on_memory_refresh, |
53 const OnIdleWakeupsCallback& on_idle_wakeups, | 57 const OnIdleWakeupsCallback& on_idle_wakeups, |
54 #if defined(OS_LINUX) | 58 #if defined(OS_LINUX) |
55 const OnOpenFdCountCallback& on_open_fd_count, | 59 const OnOpenFdCountCallback& on_open_fd_count, |
56 #endif // defined(OS_LINUX) | 60 #endif // defined(OS_LINUX) |
57 const OnProcessPriorityCallback& on_process_priority); | 61 const OnProcessPriorityCallback& on_process_priority); |
58 | 62 |
59 // Refreshes the expensive process' stats (CPU usage, memory usage, and idle | 63 // Refreshes the expensive process' stats (CPU usage, memory usage, and idle |
60 // wakeups per second) on the worker thread. | 64 // wakeups per second) on the worker thread. |
61 void Refresh(int64 refresh_flags); | 65 void Refresh(int64_t refresh_flags); |
62 | 66 |
63 private: | 67 private: |
64 friend class base::RefCountedThreadSafe<TaskGroupSampler>; | 68 friend class base::RefCountedThreadSafe<TaskGroupSampler>; |
65 ~TaskGroupSampler(); | 69 ~TaskGroupSampler(); |
66 | 70 |
67 // The refresh calls that will be done on the worker thread. | 71 // The refresh calls that will be done on the worker thread. |
68 double RefreshCpuUsage(); | 72 double RefreshCpuUsage(); |
69 MemoryUsageStats RefreshMemoryUsage(); | 73 MemoryUsageStats RefreshMemoryUsage(); |
70 int RefreshIdleWakeupsPerSecond(); | 74 int RefreshIdleWakeupsPerSecond(); |
71 #if defined(OS_LINUX) | 75 #if defined(OS_LINUX) |
(...skipping 24 matching lines...) Expand all Loading... |
96 // To assert we're running on the correct thread. | 100 // To assert we're running on the correct thread. |
97 base::SequenceChecker worker_pool_sequenced_checker_; | 101 base::SequenceChecker worker_pool_sequenced_checker_; |
98 | 102 |
99 DISALLOW_COPY_AND_ASSIGN(TaskGroupSampler); | 103 DISALLOW_COPY_AND_ASSIGN(TaskGroupSampler); |
100 }; | 104 }; |
101 | 105 |
102 } // namespace task_management | 106 } // namespace task_management |
103 | 107 |
104 | 108 |
105 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_SAMPLER_H_ | 109 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_SAMPLER_H_ |
OLD | NEW |