OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/process_info_snapshot.h" | 5 #include "chrome/browser/process_info_snapshot.h" |
6 | 6 |
7 #include <sys/sysctl.h> | 7 #include <sys/sysctl.h> |
8 | 8 |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } | 392 } |
393 | 393 |
394 return memory_info_success; | 394 return memory_info_success; |
395 } | 395 } |
396 | 396 |
397 // Clear all the stored information. | 397 // Clear all the stored information. |
398 void ProcessInfoSnapshot::Reset() { | 398 void ProcessInfoSnapshot::Reset() { |
399 proc_info_entries_.clear(); | 399 proc_info_entries_.clear(); |
400 } | 400 } |
401 | 401 |
| 402 ProcessInfoSnapshot::ProcInfoEntry::ProcInfoEntry() |
| 403 : pid(0), |
| 404 ppid(0), |
| 405 uid(0), |
| 406 euid(0), |
| 407 rss(0), |
| 408 rshrd(0), |
| 409 rprvt(0), |
| 410 vsize(0) { |
| 411 } |
| 412 |
402 bool ProcessInfoSnapshot::GetProcInfo(int pid, | 413 bool ProcessInfoSnapshot::GetProcInfo(int pid, |
403 ProcInfoEntry* proc_info) const { | 414 ProcInfoEntry* proc_info) const { |
404 std::map<int,ProcInfoEntry>::const_iterator it = proc_info_entries_.find(pid); | 415 std::map<int,ProcInfoEntry>::const_iterator it = proc_info_entries_.find(pid); |
405 if (it == proc_info_entries_.end()) | 416 if (it == proc_info_entries_.end()) |
406 return false; | 417 return false; |
407 | 418 |
408 *proc_info = it->second; | 419 *proc_info = it->second; |
409 return true; | 420 return true; |
410 } | 421 } |
411 | 422 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 ws_usage->shareable = 0; | 460 ws_usage->shareable = 0; |
450 ws_usage->shared = 0; | 461 ws_usage->shared = 0; |
451 return false; | 462 return false; |
452 } | 463 } |
453 | 464 |
454 ws_usage->priv = proc_info.rprvt / 1024; | 465 ws_usage->priv = proc_info.rprvt / 1024; |
455 ws_usage->shareable = proc_info.rss / 1024; | 466 ws_usage->shareable = proc_info.rss / 1024; |
456 ws_usage->shared = proc_info.rshrd / 1024; | 467 ws_usage->shared = proc_info.rshrd / 1024; |
457 return true; | 468 return true; |
458 } | 469 } |
OLD | NEW |