| OLD | NEW |
| 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 #include "base/process/process_metrics.h" | 5 #include "base/process/process_metrics.h" |
| 6 | 6 |
| 7 #include <dirent.h> | 7 #include <dirent.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 const size_t kDiskWriteTime = 10; | 527 const size_t kDiskWriteTime = 10; |
| 528 const size_t kDiskIO = 11; | 528 const size_t kDiskIO = 11; |
| 529 const size_t kDiskIOTime = 12; | 529 const size_t kDiskIOTime = 12; |
| 530 const size_t kDiskWeightedIOTime = 13; | 530 const size_t kDiskWeightedIOTime = 13; |
| 531 | 531 |
| 532 } // namespace | 532 } // namespace |
| 533 | 533 |
| 534 SystemMemoryInfoKB::SystemMemoryInfoKB() { | 534 SystemMemoryInfoKB::SystemMemoryInfoKB() { |
| 535 total = 0; | 535 total = 0; |
| 536 free = 0; | 536 free = 0; |
| 537 #if defined(OS_LINUX) |
| 538 available = 0; |
| 539 #endif |
| 537 buffers = 0; | 540 buffers = 0; |
| 538 cached = 0; | 541 cached = 0; |
| 539 active_anon = 0; | 542 active_anon = 0; |
| 540 inactive_anon = 0; | 543 inactive_anon = 0; |
| 541 active_file = 0; | 544 active_file = 0; |
| 542 inactive_file = 0; | 545 inactive_file = 0; |
| 543 swap_total = 0; | 546 swap_total = 0; |
| 544 swap_free = 0; | 547 swap_free = 0; |
| 545 dirty = 0; | 548 dirty = 0; |
| 546 | 549 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 557 } | 560 } |
| 558 | 561 |
| 559 SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB& other) = | 562 SystemMemoryInfoKB::SystemMemoryInfoKB(const SystemMemoryInfoKB& other) = |
| 560 default; | 563 default; |
| 561 | 564 |
| 562 std::unique_ptr<Value> SystemMemoryInfoKB::ToValue() const { | 565 std::unique_ptr<Value> SystemMemoryInfoKB::ToValue() const { |
| 563 std::unique_ptr<DictionaryValue> res(new DictionaryValue()); | 566 std::unique_ptr<DictionaryValue> res(new DictionaryValue()); |
| 564 | 567 |
| 565 res->SetInteger("total", total); | 568 res->SetInteger("total", total); |
| 566 res->SetInteger("free", free); | 569 res->SetInteger("free", free); |
| 570 #if defined(OS_LINUX) |
| 571 res->SetInteger("available", available); |
| 572 #endif |
| 567 res->SetInteger("buffers", buffers); | 573 res->SetInteger("buffers", buffers); |
| 568 res->SetInteger("cached", cached); | 574 res->SetInteger("cached", cached); |
| 569 res->SetInteger("active_anon", active_anon); | 575 res->SetInteger("active_anon", active_anon); |
| 570 res->SetInteger("inactive_anon", inactive_anon); | 576 res->SetInteger("inactive_anon", inactive_anon); |
| 571 res->SetInteger("active_file", active_file); | 577 res->SetInteger("active_file", active_file); |
| 572 res->SetInteger("inactive_file", inactive_file); | 578 res->SetInteger("inactive_file", inactive_file); |
| 573 res->SetInteger("swap_total", swap_total); | 579 res->SetInteger("swap_total", swap_total); |
| 574 res->SetInteger("swap_free", swap_free); | 580 res->SetInteger("swap_free", swap_free); |
| 575 res->SetInteger("swap_used", swap_total - swap_free); | 581 res->SetInteger("swap_used", swap_total - swap_free); |
| 576 res->SetInteger("dirty", dirty); | 582 res->SetInteger("dirty", dirty); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 DLOG(WARNING) << "meminfo: tokens: " << tokens.size() | 620 DLOG(WARNING) << "meminfo: tokens: " << tokens.size() |
| 615 << " malformed line: " << line.as_string(); | 621 << " malformed line: " << line.as_string(); |
| 616 continue; | 622 continue; |
| 617 } | 623 } |
| 618 | 624 |
| 619 int* target = NULL; | 625 int* target = NULL; |
| 620 if (tokens[0] == "MemTotal:") | 626 if (tokens[0] == "MemTotal:") |
| 621 target = &meminfo->total; | 627 target = &meminfo->total; |
| 622 else if (tokens[0] == "MemFree:") | 628 else if (tokens[0] == "MemFree:") |
| 623 target = &meminfo->free; | 629 target = &meminfo->free; |
| 630 #if defined(OS_LINUX) |
| 631 else if (tokens[0] == "MemAvailable:") |
| 632 target = &meminfo->available; |
| 633 #endif |
| 624 else if (tokens[0] == "Buffers:") | 634 else if (tokens[0] == "Buffers:") |
| 625 target = &meminfo->buffers; | 635 target = &meminfo->buffers; |
| 626 else if (tokens[0] == "Cached:") | 636 else if (tokens[0] == "Cached:") |
| 627 target = &meminfo->cached; | 637 target = &meminfo->cached; |
| 628 else if (tokens[0] == "Active(anon):") | 638 else if (tokens[0] == "Active(anon):") |
| 629 target = &meminfo->active_anon; | 639 target = &meminfo->active_anon; |
| 630 else if (tokens[0] == "Inactive(anon):") | 640 else if (tokens[0] == "Inactive(anon):") |
| 631 target = &meminfo->inactive_anon; | 641 target = &meminfo->inactive_anon; |
| 632 else if (tokens[0] == "Active(file):") | 642 else if (tokens[0] == "Active(file):") |
| 633 target = &meminfo->active_file; | 643 target = &meminfo->active_file; |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 #if defined(OS_LINUX) | 957 #if defined(OS_LINUX) |
| 948 int ProcessMetrics::GetIdleWakeupsPerSecond() { | 958 int ProcessMetrics::GetIdleWakeupsPerSecond() { |
| 949 uint64_t wake_ups; | 959 uint64_t wake_ups; |
| 950 const char kWakeupStat[] = "se.statistics.nr_wakeups"; | 960 const char kWakeupStat[] = "se.statistics.nr_wakeups"; |
| 951 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? | 961 return ReadProcSchedAndGetFieldAsUint64(process_, kWakeupStat, &wake_ups) ? |
| 952 CalculateIdleWakeupsPerSecond(wake_ups) : 0; | 962 CalculateIdleWakeupsPerSecond(wake_ups) : 0; |
| 953 } | 963 } |
| 954 #endif // defined(OS_LINUX) | 964 #endif // defined(OS_LINUX) |
| 955 | 965 |
| 956 } // namespace base | 966 } // namespace base |
| OLD | NEW |