Commit 3fba6c35 authored by erikchen's avatar erikchen Committed by Commit Bot

Perform some renames in task_manager code.

This CL is a refactor and has no intended behavior change.

* Rename REFRESH_TYPE_MEMORY_DETAILS to REFRESH_TYPE_SWAPPED_MEM.
* Remove MemoryUsageStats and replace with int64_t.

Change-Id: I75276508cbdbc67cb6b2d6642e0285733ebcca01
Reviewed-on: https://chromium-review.googlesource.com/965104
Commit-Queue: Erik Chen <erikchen@chromium.org>
Reviewed-by: default avatarNick Carter <nick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544080}
parent b355c7d6
......@@ -28,7 +28,7 @@ namespace {
// A mask for the refresh types that are done in the background thread.
const int kBackgroundRefreshTypesMask =
REFRESH_TYPE_CPU | REFRESH_TYPE_MEMORY_DETAILS | REFRESH_TYPE_IDLE_WAKEUPS |
REFRESH_TYPE_CPU | REFRESH_TYPE_SWAPPED_MEM | REFRESH_TYPE_IDLE_WAKEUPS |
#if defined(OS_WIN)
REFRESH_TYPE_START_TIME | REFRESH_TYPE_CPU_TIME |
#endif // defined(OS_WIN)
......@@ -93,6 +93,7 @@ TaskGroup::TaskGroup(
expected_on_bg_done_flags_(kBackgroundRefreshTypesMask),
current_on_bg_done_flags_(0),
platform_independent_cpu_usage_(0.0),
swapped_mem_bytes_(-1),
memory_footprint_(-1),
gpu_memory_(-1),
memory_state_(base::MemoryState::UNKNOWN),
......@@ -120,7 +121,7 @@ TaskGroup::TaskGroup(
base::Process::Open(process_id_), blocking_pool_runner,
base::Bind(&TaskGroup::OnCpuRefreshDone,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&TaskGroup::OnMemoryUsageRefreshDone,
base::Bind(&TaskGroup::OnSwappedMemRefreshDone,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&TaskGroup::OnIdleWakeupsRefreshDone,
weak_ptr_factory_.GetWeakPtr()),
......@@ -303,11 +304,11 @@ void TaskGroup::OnCpuRefreshDone(double cpu_usage) {
OnBackgroundRefreshTypeFinished(REFRESH_TYPE_CPU);
}
void TaskGroup::OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage) {
void TaskGroup::OnSwappedMemRefreshDone(int64_t swapped_mem_bytes) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
memory_usage_ = memory_usage;
OnBackgroundRefreshTypeFinished(REFRESH_TYPE_MEMORY_DETAILS);
swapped_mem_bytes_ = swapped_mem_bytes;
OnBackgroundRefreshTypeFinished(REFRESH_TYPE_SWAPPED_MEM);
}
void TaskGroup::OnProcessPriorityDone(bool is_backgrounded) {
......
......@@ -78,7 +78,7 @@ class TaskGroup {
void set_footprint_bytes(int64_t footprint) { memory_footprint_ = footprint; }
int64_t footprint_bytes() const { return memory_footprint_; }
#if defined(OS_CHROMEOS)
int64_t swapped_bytes() const { return memory_usage_.swapped_bytes; }
int64_t swapped_bytes() const { return swapped_mem_bytes_; }
#endif
int64_t gpu_memory() const { return gpu_memory_; }
bool gpu_memory_has_duplicates() const { return gpu_memory_has_duplicates_; }
......@@ -124,7 +124,7 @@ class TaskGroup {
#endif // defined(OS_LINUX)
void OnCpuRefreshDone(double cpu_usage);
void OnMemoryUsageRefreshDone(MemoryUsageStats memory_usage);
void OnSwappedMemRefreshDone(int64_t swapped_mem_bytes);
void OnProcessPriorityDone(bool is_backgrounded);
void OnIdleWakeupsRefreshDone(int idle_wakeups_per_second);
......@@ -158,7 +158,7 @@ class TaskGroup {
double platform_independent_cpu_usage_;
base::Time start_time_; // Only calculated On Windows now.
base::TimeDelta cpu_time_; // Only calculated On Windows now.
MemoryUsageStats memory_usage_;
int64_t swapped_mem_bytes_;
int64_t memory_footprint_;
int64_t gpu_memory_;
base::MemoryState memory_state_;
......
......@@ -40,7 +40,7 @@ TaskGroupSampler::TaskGroupSampler(
base::Process process,
const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner,
const OnCpuRefreshCallback& on_cpu_refresh,
const OnMemoryRefreshCallback& on_memory_refresh,
const OnSwappedMemRefreshCallback& on_swapped_mem_refresh,
const OnIdleWakeupsCallback& on_idle_wakeups,
#if defined(OS_LINUX)
const OnOpenFdCountCallback& on_open_fd_count,
......@@ -50,7 +50,7 @@ TaskGroupSampler::TaskGroupSampler(
process_metrics_(CreateProcessMetrics(process_.Handle())),
blocking_pool_runner_(blocking_pool_runner),
on_cpu_refresh_callback_(on_cpu_refresh),
on_memory_refresh_callback_(on_memory_refresh),
on_swapped_mem_refresh_callback_(on_swapped_mem_refresh),
on_idle_wakeups_callback_(on_idle_wakeups),
#if defined(OS_LINUX)
on_open_fd_count_callback_(on_open_fd_count),
......@@ -77,13 +77,12 @@ void TaskGroupSampler::Refresh(int64_t refresh_flags) {
on_cpu_refresh_callback_);
}
if (TaskManagerObserver::IsResourceRefreshEnabled(REFRESH_TYPE_MEMORY_DETAILS,
if (TaskManagerObserver::IsResourceRefreshEnabled(REFRESH_TYPE_SWAPPED_MEM,
refresh_flags)) {
base::PostTaskAndReplyWithResult(
blocking_pool_runner_.get(),
FROM_HERE,
base::Bind(&TaskGroupSampler::RefreshMemoryUsage, this),
on_memory_refresh_callback_);
blocking_pool_runner_.get(), FROM_HERE,
base::Bind(&TaskGroupSampler::RefreshSwappedMem, this),
on_swapped_mem_refresh_callback_);
}
#if defined(OS_MACOSX) || defined(OS_LINUX)
......@@ -127,19 +126,17 @@ double TaskGroupSampler::RefreshCpuUsage() {
return process_metrics_->GetPlatformIndependentCPUUsage();
}
MemoryUsageStats TaskGroupSampler::RefreshMemoryUsage() {
int64_t TaskGroupSampler::RefreshSwappedMem() {
DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence());
MemoryUsageStats memory_usage;
#if defined(OS_CHROMEOS)
base::WorkingSetKBytes ws_usage;
if (process_metrics_->GetWorkingSetKBytes(&ws_usage)) {
memory_usage.swapped_bytes = ws_usage.swapped * 1024;
return ws_usage.swapped * 1024;
}
#endif // defined(OS_CHROMEOS)
return memory_usage;
return 0;
}
int TaskGroupSampler::RefreshIdleWakeupsPerSecond() {
......
......@@ -21,16 +21,6 @@
namespace task_manager {
// Wraps the memory usage stats values together so that it can be sent between
// the UI and the worker threads.
struct MemoryUsageStats {
#if defined(OS_CHROMEOS)
int64_t swapped_bytes = -1;
#endif
MemoryUsageStats() {}
};
// Defines the expensive process' stats sampler that will calculate these
// resources on the worker thread. Objects of this class are created by the
// TaskGroups on the UI thread, however it will be used mainly on a blocking
......@@ -40,7 +30,7 @@ class TaskGroupSampler : public base::RefCountedThreadSafe<TaskGroupSampler> {
// Below are the types of callbacks that are invoked on the UI thread upon
// completion of corresponding refresh tasks on the worker thread.
using OnCpuRefreshCallback = base::Callback<void(double)>;
using OnMemoryRefreshCallback = base::Callback<void(MemoryUsageStats)>;
using OnSwappedMemRefreshCallback = base::Callback<void(int64_t)>;
using OnIdleWakeupsCallback = base::Callback<void(int)>;
#if defined(OS_LINUX)
using OnOpenFdCountCallback = base::Callback<void(int)>;
......@@ -51,7 +41,7 @@ class TaskGroupSampler : public base::RefCountedThreadSafe<TaskGroupSampler> {
base::Process process,
const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner,
const OnCpuRefreshCallback& on_cpu_refresh,
const OnMemoryRefreshCallback& on_memory_refresh,
const OnSwappedMemRefreshCallback& on_memory_refresh,
const OnIdleWakeupsCallback& on_idle_wakeups,
#if defined(OS_LINUX)
const OnOpenFdCountCallback& on_open_fd_count,
......@@ -68,7 +58,7 @@ class TaskGroupSampler : public base::RefCountedThreadSafe<TaskGroupSampler> {
// The refresh calls that will be done on the worker thread.
double RefreshCpuUsage();
MemoryUsageStats RefreshMemoryUsage();
int64_t RefreshSwappedMem();
int RefreshIdleWakeupsPerSecond();
#if defined(OS_LINUX)
int RefreshOpenFdCount();
......@@ -88,7 +78,7 @@ class TaskGroupSampler : public base::RefCountedThreadSafe<TaskGroupSampler> {
// The UI-thread callbacks in TaskGroup to be called when their corresponding
// refreshes on the worker thread are done.
const OnCpuRefreshCallback on_cpu_refresh_callback_;
const OnMemoryRefreshCallback on_memory_refresh_callback_;
const OnSwappedMemRefreshCallback on_swapped_mem_refresh_callback_;
const OnIdleWakeupsCallback on_idle_wakeups_callback_;
#if defined(OS_LINUX)
const OnOpenFdCountCallback on_open_fd_count_callback_;
......
......@@ -26,8 +26,8 @@ enum RefreshType {
REFRESH_TYPE_NONE = 0,
REFRESH_TYPE_CPU = 1,
// Memory details currently only includes "swapped memory" on CrOS.
REFRESH_TYPE_MEMORY_DETAILS = 1 << 2,
// Only available on CrOS.
REFRESH_TYPE_SWAPPED_MEM = 1 << 2,
REFRESH_TYPE_GPU_MEMORY = 1 << 3,
REFRESH_TYPE_V8_MEMORY = 1 << 4,
REFRESH_TYPE_SQLITE_MEMORY = 1 << 5,
......
......@@ -728,7 +728,7 @@ void TaskManagerTableModel::UpdateRefreshTypes(int column_id, bool visibility) {
break;
case IDS_TASK_MANAGER_SWAPPED_MEM_COLUMN:
type = REFRESH_TYPE_MEMORY_DETAILS;
type = REFRESH_TYPE_SWAPPED_MEM;
if (table_view_delegate_->IsColumnVisible(
IDS_TASK_MANAGER_SWAPPED_MEM_COLUMN)) {
needs_refresh = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment