OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
(...skipping 25 matching lines...) Expand all Loading... |
36 res->Set("meminfo", memory_info_.ToValue()); | 36 res->Set("meminfo", memory_info_.ToValue()); |
37 res->Set("diskinfo", disk_info_.ToValue()); | 37 res->Set("diskinfo", disk_info_.ToValue()); |
38 #endif | 38 #endif |
39 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) |
40 res->Set("swapinfo", swap_info_.ToValue()); | 40 res->Set("swapinfo", swap_info_.ToValue()); |
41 #endif | 41 #endif |
42 | 42 |
43 return res.Pass(); | 43 return res.Pass(); |
44 } | 44 } |
45 | 45 |
| 46 ProcessMetrics* ProcessMetrics::CreateCurrentProcessMetrics() { |
| 47 #if !defined(OS_MACOSX) || defined(OS_IOS) |
| 48 return CreateProcessMetrics(base::GetCurrentProcessHandle()); |
| 49 #else |
| 50 return CreateProcessMetrics(base::GetCurrentProcessHandle(), nullptr); |
| 51 #endif // !defined(OS_MACOSX) || defined(OS_IOS) |
| 52 } |
| 53 |
46 double ProcessMetrics::GetPlatformIndependentCPUUsage() { | 54 double ProcessMetrics::GetPlatformIndependentCPUUsage() { |
47 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
48 return GetCPUUsage() * processor_count_; | 56 return GetCPUUsage() * processor_count_; |
49 #else | 57 #else |
50 return GetCPUUsage(); | 58 return GetCPUUsage(); |
51 #endif | 59 #endif |
52 } | 60 } |
53 | 61 |
54 #if defined(OS_MACOSX) || defined(OS_LINUX) | 62 #if defined(OS_MACOSX) || defined(OS_LINUX) |
55 int ProcessMetrics::CalculateIdleWakeupsPerSecond( | 63 int ProcessMetrics::CalculateIdleWakeupsPerSecond( |
(...skipping 22 matching lines...) Expand all Loading... |
78 return (wakeups_delta_for_ms + time_delta / 2) / time_delta; | 86 return (wakeups_delta_for_ms + time_delta / 2) / time_delta; |
79 } | 87 } |
80 #else | 88 #else |
81 int ProcessMetrics::GetIdleWakeupsPerSecond() { | 89 int ProcessMetrics::GetIdleWakeupsPerSecond() { |
82 NOTIMPLEMENTED(); // http://crbug.com/120488 | 90 NOTIMPLEMENTED(); // http://crbug.com/120488 |
83 return 0; | 91 return 0; |
84 } | 92 } |
85 #endif // defined(OS_MACOSX) || defined(OS_LINUX) | 93 #endif // defined(OS_MACOSX) || defined(OS_LINUX) |
86 | 94 |
87 } // namespace base | 95 } // namespace base |
OLD | NEW |