| 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> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/process/process.h" | 13 #include "base/process/process.h" |
| 14 #include "base/process/process_handle.h" | 14 #include "base/process/process_handle.h" |
| 15 #include "base/process/process_metrics.h" | 15 #include "base/process/process_metrics.h" |
| 16 #include "base/sequence_checker.h" | 16 #include "base/sequence_checker.h" |
| 17 #include "base/sequenced_task_runner.h" | 17 #include "base/sequenced_task_runner.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 | 19 |
| 20 namespace task_management { | 20 namespace task_management { |
| 21 | 21 |
| 22 // 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 |
| 23 // the UI and the worker threads. | 23 // the UI and the worker threads. |
| 24 struct MemoryUsageStats { | 24 struct MemoryUsageStats { |
| 25 int64_t private_bytes; | 25 int64_t private_bytes = -1; |
| 26 int64_t shared_bytes; | 26 int64_t shared_bytes = -1; |
| 27 int64_t physical_bytes; | 27 int64_t physical_bytes = -1; |
| 28 #if defined(OS_CHROMEOS) |
| 29 int64_t swapped_bytes = -1; |
| 30 #endif |
| 28 | 31 |
| 29 MemoryUsageStats() | 32 MemoryUsageStats() {} |
| 30 : private_bytes(-1), | |
| 31 shared_bytes(-1), | |
| 32 physical_bytes(-1) { | |
| 33 } | |
| 34 }; | 33 }; |
| 35 | 34 |
| 36 // Defines the expensive process' stats sampler that will calculate these | 35 // Defines the expensive process' stats sampler that will calculate these |
| 37 // resources on the worker thread. Objects of this class are created by the | 36 // resources on the worker thread. Objects of this class are created by the |
| 38 // TaskGroups on the UI thread, however it will be used mainly on a blocking | 37 // TaskGroups on the UI thread, however it will be used mainly on a blocking |
| 39 // pool thread. | 38 // pool thread. |
| 40 class TaskGroupSampler : public base::RefCountedThreadSafe<TaskGroupSampler> { | 39 class TaskGroupSampler : public base::RefCountedThreadSafe<TaskGroupSampler> { |
| 41 public: | 40 public: |
| 42 // The below are the types of the callbacks to the UI thread upon their | 41 // The below are the types of the callbacks to the UI thread upon their |
| 43 // corresponding refresh are done on the worker thread. | 42 // corresponding refresh are done on the worker thread. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // To assert we're running on the correct thread. | 99 // To assert we're running on the correct thread. |
| 101 base::SequenceChecker worker_pool_sequenced_checker_; | 100 base::SequenceChecker worker_pool_sequenced_checker_; |
| 102 | 101 |
| 103 DISALLOW_COPY_AND_ASSIGN(TaskGroupSampler); | 102 DISALLOW_COPY_AND_ASSIGN(TaskGroupSampler); |
| 104 }; | 103 }; |
| 105 | 104 |
| 106 } // namespace task_management | 105 } // namespace task_management |
| 107 | 106 |
| 108 | 107 |
| 109 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_SAMPLER_H_ | 108 #endif // CHROME_BROWSER_TASK_MANAGEMENT_SAMPLING_TASK_GROUP_SAMPLER_H_ |
| OLD | NEW |