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 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/mac/mac_util.h" |
13 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/sys_info.h" | |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 | 17 |
18 // Default constructor. | 18 // Default constructor. |
19 ProcessInfoSnapshot::ProcessInfoSnapshot() { } | 19 ProcessInfoSnapshot::ProcessInfoSnapshot() { } |
20 | 20 |
21 // Destructor: just call |Reset()| to release everything. | 21 // Destructor: just call |Reset()| to release everything. |
22 ProcessInfoSnapshot::~ProcessInfoSnapshot() { | 22 ProcessInfoSnapshot::~ProcessInfoSnapshot() { |
23 Reset(); | 23 Reset(); |
24 } | 24 } |
25 | 25 |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 it != pid_list.end(); ++it) { | 373 it != pid_list.end(); ++it) { |
374 std::string exectuable_name; | 374 std::string exectuable_name; |
375 if (GetExecutableNameForProcessID(*it, &exectuable_name)) { | 375 if (GetExecutableNameForProcessID(*it, &exectuable_name)) { |
376 ProcInfoEntry proc_info = proc_info_entries_[*it]; | 376 ProcInfoEntry proc_info = proc_info_entries_[*it]; |
377 proc_info.command = exectuable_name; | 377 proc_info.command = exectuable_name; |
378 } | 378 } |
379 } | 379 } |
380 | 380 |
381 // Get memory information using top. | 381 // Get memory information using top. |
382 bool memory_info_success = false; | 382 bool memory_info_success = false; |
383 int32 major, minor, bugfix; | 383 if (base::mac::IsOSLeopardOrEarlier()) |
384 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix); | |
385 if (major == 10 && minor == 5) | |
386 memory_info_success = GetProcessMemoryInfoUsingTop_10_5(proc_info_entries_); | 384 memory_info_success = GetProcessMemoryInfoUsingTop_10_5(proc_info_entries_); |
387 else if ((major == 10 && minor >= 6) || major > 10) | 385 else |
388 memory_info_success = GetProcessMemoryInfoUsingTop(proc_info_entries_); | 386 memory_info_success = GetProcessMemoryInfoUsingTop(proc_info_entries_); |
389 | 387 |
390 // If top didn't work then fall back to ps. | 388 // If top didn't work then fall back to ps. |
391 if (!memory_info_success) { | 389 if (!memory_info_success) { |
392 memory_info_success = GetProcessMemoryInfoUsingPS(pid_list, | 390 memory_info_success = GetProcessMemoryInfoUsingPS(pid_list, |
393 proc_info_entries_); | 391 proc_info_entries_); |
394 } | 392 } |
395 | 393 |
396 return memory_info_success; | 394 return memory_info_success; |
397 } | 395 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 ws_usage->shareable = 0; | 449 ws_usage->shareable = 0; |
452 ws_usage->shared = 0; | 450 ws_usage->shared = 0; |
453 return false; | 451 return false; |
454 } | 452 } |
455 | 453 |
456 ws_usage->priv = proc_info.rprvt / 1024; | 454 ws_usage->priv = proc_info.rprvt / 1024; |
457 ws_usage->shareable = proc_info.rss / 1024; | 455 ws_usage->shareable = proc_info.rss / 1024; |
458 ws_usage->shared = proc_info.rshrd / 1024; | 456 ws_usage->shared = proc_info.rshrd / 1024; |
459 return true; | 457 return true; |
460 } | 458 } |
OLD | NEW |