1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
|
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_TASK_MANAGER_TASK_MANAGER_COLUMNS_H_
#define CHROME_BROWSER_UI_TASK_MANAGER_TASK_MANAGER_COLUMNS_H_
#include <stddef.h>
#include <array>
#include <string_view>
#include "build/build_config.h"
#include "chrome/grit/generated_resources.h"
#include "components/nacl/common/buildflags.h"
#include "ui/base/models/table_model.h"
namespace task_manager {
// A collection of data to be used in the construction of a task manager table
// column.
struct TableColumnData {
// The generated ID of the column. These can change from one build to another.
// Their values are controlled by the generation from generated_resources.grd.
int id;
// The alignment of the text displayed in this column.
ui::TableColumn::Alignment align;
// |width| and |percent| used to define the size of the column. See
// ui::TableColumn::width and ui::TableColumn::percent for details.
int width;
float percent;
// min and max widths used for Mac's implementation and are ignored on Views.
// If |max_width| is -1, a value of 1.5 * |min_width| will be used.
int min_width;
int max_width;
// Is the column sortable.
bool sortable;
// Is the initial sort order ascending?
bool initial_sort_is_ascending;
// The default visibility of this column at startup of the table if no
// visibility is stored for it in the prefs.
bool default_visibility;
};
// On Mac: Width of "a" and most other letters/digits in "small" table views.
inline constexpr int kCharWidth = 6;
// The task manager table columns and their properties.
//
// IMPORTANT: Do NOT change the below list without updating
// `GetColumnIdAsString()`, whose switch statement cannot be made
// exhaustive (given pure-integral inputs).
inline constexpr std::array kColumns = {
TableColumnData{.id = IDS_TASK_MANAGER_TASK_COLUMN,
.align = ui::TableColumn::LEFT,
.width = -1,
.percent = 1,
.min_width = 120,
.max_width = 600,
.sortable = true,
.initial_sort_is_ascending = true,
.default_visibility = true},
TableColumnData{.id = IDS_TASK_MANAGER_PROFILE_NAME_COLUMN,
.align = ui::TableColumn::LEFT,
.width = -1,
.percent = 0,
.min_width = 60,
.max_width = 200,
.sortable = true,
.initial_sort_is_ascending = true,
.default_visibility = false},
TableColumnData{
.id = IDS_TASK_MANAGER_MEM_FOOTPRINT_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("800 MiB") * kCharWidth,
.max_width = std::size("Memory Footprint") * kCharWidth * 3 / 2,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = true},
#if BUILDFLAG(IS_CHROMEOS)
TableColumnData{.id = IDS_TASK_MANAGER_SWAPPED_MEM_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("800 MiB") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
#endif
// Make the CPU column min width a bit wider on macOS. When you click a column
// to make it the primary sort column a caret appears to the right of the
// column's label. Without a little extra space, the tableview squeezes the
// caret in by tail-truncating the label, which looks terrible.
#if BUILDFLAG(IS_MAC)
TableColumnData{.id = IDS_TASK_MANAGER_CPU_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("0099.9") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = true},
#else
TableColumnData{.id = IDS_TASK_MANAGER_CPU_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("99.9") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = true},
#endif // BUILDFLAG(IS_MAC)
#if BUILDFLAG(IS_WIN)
TableColumnData{.id = IDS_TASK_MANAGER_CPU_TIME_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("1234h 42m 30s") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
TableColumnData{.id = IDS_TASK_MANAGER_START_TIME_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("12/13/14 11:44:30 PM") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = true,
.default_visibility = false},
#endif
TableColumnData{.id = IDS_TASK_MANAGER_NET_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("150 kiB/s") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = true},
TableColumnData{.id = IDS_TASK_MANAGER_PROCESS_ID_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("73099 ") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = true,
.default_visibility = true},
#if BUILDFLAG(IS_WIN)
TableColumnData{.id = IDS_TASK_MANAGER_GDI_HANDLES_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = 0,
.max_width = 0,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
TableColumnData{.id = IDS_TASK_MANAGER_USER_HANDLES_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = 0,
.max_width = 0,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
#endif
TableColumnData{
.id = IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("2000.0K (2000.0 live)") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
TableColumnData{
.id = IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("2000.0K (2000.0 live)") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
TableColumnData{
.id = IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("2000.0K (2000.0 live)") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
TableColumnData{.id = IDS_TASK_MANAGER_VIDEO_MEMORY_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("2000.0K") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
TableColumnData{.id = IDS_TASK_MANAGER_SQLITE_MEMORY_USED_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("800 kB") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
#if BUILDFLAG(ENABLE_NACL)
TableColumnData{.id = IDS_TASK_MANAGER_NACL_DEBUG_STUB_PORT_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("32767") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = true,
.default_visibility = false},
#endif // BUILDFLAG(ENABLE_NACL)
TableColumnData{
.id = IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("2000.0K (2000.0 live)") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
TableColumnData{.id = IDS_TASK_MANAGER_IDLE_WAKEUPS_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("idlewakeups") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
#if BUILDFLAG(IS_WIN)
TableColumnData{.id = IDS_TASK_MANAGER_HARD_FAULTS_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("100000") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_MAC)
TableColumnData{.id = IDS_TASK_MANAGER_OPEN_FD_COUNT_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("999") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_MAC)
TableColumnData{.id = IDS_TASK_MANAGER_PROCESS_PRIORITY_COLUMN,
.align = ui::TableColumn::LEFT,
.width = -1,
.percent = 0,
.min_width = std::size("background") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = true,
.default_visibility = false},
TableColumnData{.id = IDS_TASK_MANAGER_KEEPALIVE_COUNT_COLUMN,
.align = ui::TableColumn::RIGHT,
.width = -1,
.percent = 0,
.min_width = std::size("999") * kCharWidth,
.max_width = -1,
.sortable = true,
.initial_sort_is_ascending = false,
.default_visibility = false},
};
inline constexpr size_t kColumnsSize = std::size(kColumns);
// Session Restore Keys.
extern const char kSortColumnIdKey[];
extern const char kSortIsAscendingKey[];
// Returns the |column_id| as a string value to be used as keys in the user
// preferences.
std::string_view GetColumnIdAsString(int column_id);
} // namespace task_manager
#endif // CHROME_BROWSER_UI_TASK_MANAGER_TASK_MANAGER_COLUMNS_H_
|