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

Side by Side Diff: base/process/process_metrics.h

Issue 23155002: Implement ToValue() for SystemMetrics, SystemMemoryInfoKB, DiskInfo, and SwapInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@meminfo
Patch Set: change Value* AsValue() to scoped_ptr<Value> ToValue() Created 7 years, 3 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
« no previous file with comments | « no previous file | base/process/process_metrics.cc » ('j') | base/process/process_metrics.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 // This file contains routines for gathering resource statistics for processes 5 // This file contains routines for gathering resource statistics for processes
6 // running on the system. 6 // running on the system.
7 7
8 #ifndef BASE_PROCESS_PROCESS_METRICS_H_ 8 #ifndef BASE_PROCESS_PROCESS_METRICS_H_
9 #define BASE_PROCESS_PROCESS_METRICS_H_ 9 #define BASE_PROCESS_PROCESS_METRICS_H_
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/base_export.h" 13 #include "base/base_export.h"
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/process/process_handle.h" 16 #include "base/process/process_handle.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "base/values.h"
18 19
19 #if defined(OS_MACOSX) 20 #if defined(OS_MACOSX)
20 #include <mach/mach.h> 21 #include <mach/mach.h>
21 #endif 22 #endif
22 23
23 namespace base { 24 namespace base {
24 25
25 #if defined(OS_WIN) 26 #if defined(OS_WIN)
26 struct IoCounters : public IO_COUNTERS { 27 struct IoCounters : public IO_COUNTERS {
27 }; 28 };
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 BASE_EXPORT int GetNumberOfThreads(ProcessHandle process); 237 BASE_EXPORT int GetNumberOfThreads(ProcessHandle process);
237 238
238 // /proc/self/exe refers to the current executable. 239 // /proc/self/exe refers to the current executable.
239 BASE_EXPORT extern const char kProcSelfExe[]; 240 BASE_EXPORT extern const char kProcSelfExe[];
240 241
241 // Data from /proc/meminfo about system-wide memory consumption. 242 // Data from /proc/meminfo about system-wide memory consumption.
242 // Values are in KB. 243 // Values are in KB.
243 struct BASE_EXPORT SystemMemoryInfoKB { 244 struct BASE_EXPORT SystemMemoryInfoKB {
244 SystemMemoryInfoKB(); 245 SystemMemoryInfoKB();
245 246
247 // Serializes the platform specific fields to value.
248 scoped_ptr<Value> ToValue() const;
249
246 int total; 250 int total;
247 int free; 251 int free;
248 int buffers; 252 int buffers;
249 int cached; 253 int cached;
250 int active_anon; 254 int active_anon;
251 int inactive_anon; 255 int inactive_anon;
252 int active_file; 256 int active_file;
253 int inactive_file; 257 int inactive_file;
254 int swap_total; 258 int swap_total;
255 int swap_free; 259 int swap_free;
(...skipping 16 matching lines...) Expand all
272 // Retrieves data from /proc/meminfo and /proc/vmstat 276 // Retrieves data from /proc/meminfo and /proc/vmstat
273 // about system-wide memory consumption. 277 // about system-wide memory consumption.
274 // Fills in the provided |meminfo| structure. Returns true on success. 278 // Fills in the provided |meminfo| structure. Returns true on success.
275 // Exposed for memory debugging widget. 279 // Exposed for memory debugging widget.
276 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo); 280 BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo);
277 281
278 // Data from /proc/diskstats about system-wide disk I/O. 282 // Data from /proc/diskstats about system-wide disk I/O.
279 struct BASE_EXPORT SystemDiskInfo { 283 struct BASE_EXPORT SystemDiskInfo {
280 SystemDiskInfo(); 284 SystemDiskInfo();
281 285
286 // Serializes the platform specific fields to value.
287 scoped_ptr<Value> ToValue() const;
288
282 uint64 reads; 289 uint64 reads;
283 uint64 reads_merged; 290 uint64 reads_merged;
284 uint64 sectors_read; 291 uint64 sectors_read;
285 uint64 read_time; 292 uint64 read_time;
286 uint64 writes; 293 uint64 writes;
287 uint64 writes_merged; 294 uint64 writes_merged;
288 uint64 sectors_written; 295 uint64 sectors_written;
289 uint64 write_time; 296 uint64 write_time;
290 uint64 io; 297 uint64 io;
291 uint64 io_time; 298 uint64 io_time;
(...skipping 14 matching lines...) Expand all
306 // Data from files in directory /sys/block/zram0 about ZRAM usage. 313 // Data from files in directory /sys/block/zram0 about ZRAM usage.
307 struct BASE_EXPORT SwapInfo { 314 struct BASE_EXPORT SwapInfo {
308 SwapInfo() 315 SwapInfo()
309 : num_reads(0), 316 : num_reads(0),
310 num_writes(0), 317 num_writes(0),
311 compr_data_size(0), 318 compr_data_size(0),
312 orig_data_size(0), 319 orig_data_size(0),
313 mem_used_total(0) { 320 mem_used_total(0) {
314 } 321 }
315 322
323 // Serializes the platform specific fields to value.
324 scoped_ptr<Value> ToValue() const;
325
316 uint64 num_reads; 326 uint64 num_reads;
317 uint64 num_writes; 327 uint64 num_writes;
318 uint64 compr_data_size; 328 uint64 compr_data_size;
319 uint64 orig_data_size; 329 uint64 orig_data_size;
320 uint64 mem_used_total; 330 uint64 mem_used_total;
321 }; 331 };
322 332
323 // In ChromeOS, reads files from /sys/block/zram0 that contain ZRAM usage data. 333 // In ChromeOS, reads files from /sys/block/zram0 that contain ZRAM usage data.
324 // Fills in the provided |swap_data| structure. 334 // Fills in the provided |swap_data| structure.
325 BASE_EXPORT void GetSwapInfo(SwapInfo* swap_info); 335 BASE_EXPORT void GetSwapInfo(SwapInfo* swap_info);
326 #endif // defined(OS_CHROMEOS) 336 #endif // defined(OS_CHROMEOS)
327 337
328 // Collects and holds performance metrics for system memory and disk. 338 // Collects and holds performance metrics for system memory and disk.
329 // Provides functionality to retrieve the data on various platforms and 339 // Provides functionality to retrieve the data on various platforms and
330 // to serialize the stored data. 340 // to serialize the stored data.
331 class SystemMetrics { 341 class SystemMetrics {
332 public: 342 public:
333 SystemMetrics(); 343 SystemMetrics();
334 344
335 static SystemMetrics Sample(); 345 static SystemMetrics Sample();
336 346
347 // Serializes the system metrics to value.
348 scoped_ptr<Value> ToValue() const;
349
337 private: 350 private:
338 FRIEND_TEST_ALL_PREFIXES(SystemMetricsTest, SystemMetrics); 351 FRIEND_TEST_ALL_PREFIXES(SystemMetricsTest, SystemMetrics);
339 352
340 size_t committed_memory_; 353 size_t committed_memory_;
341 #if defined(OS_LINUX) || defined(OS_ANDROID) 354 #if defined(OS_LINUX) || defined(OS_ANDROID)
342 SystemMemoryInfoKB memory_info_; 355 SystemMemoryInfoKB memory_info_;
343 SystemDiskInfo disk_info_; 356 SystemDiskInfo disk_info_;
344 #endif 357 #endif
345 #if defined(OS_CHROMEOS) 358 #if defined(OS_CHROMEOS)
346 SwapInfo swap_info_; 359 SwapInfo swap_info_;
347 #endif 360 #endif
348 }; 361 };
349 362
350 } // namespace base 363 } // namespace base
351 364
352 #endif // BASE_PROCESS_PROCESS_METRICS_H_ 365 #endif // BASE_PROCESS_PROCESS_METRICS_H_
OLDNEW
« no previous file with comments | « no previous file | base/process/process_metrics.cc » ('j') | base/process/process_metrics.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698