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

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

Issue 1543293004: Switch to standard integer types in base/process/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ssize_t Created 5 years 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 | « base/process/process_metrics.h ('k') | base/process/process_metrics_freebsd.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "build/build_config.h"
11 12
12 namespace base { 13 namespace base {
13 14
14 SystemMetrics::SystemMetrics() { 15 SystemMetrics::SystemMetrics() {
15 committed_memory_ = 0; 16 committed_memory_ = 0;
16 } 17 }
17 18
18 SystemMetrics SystemMetrics::Sample() { 19 SystemMetrics SystemMetrics::Sample() {
19 SystemMetrics system_metrics; 20 SystemMetrics system_metrics;
20 21
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 double ProcessMetrics::GetPlatformIndependentCPUUsage() { 57 double ProcessMetrics::GetPlatformIndependentCPUUsage() {
57 #if defined(OS_WIN) 58 #if defined(OS_WIN)
58 return GetCPUUsage() * processor_count_; 59 return GetCPUUsage() * processor_count_;
59 #else 60 #else
60 return GetCPUUsage(); 61 return GetCPUUsage();
61 #endif 62 #endif
62 } 63 }
63 64
64 #if defined(OS_MACOSX) || defined(OS_LINUX) 65 #if defined(OS_MACOSX) || defined(OS_LINUX)
65 int ProcessMetrics::CalculateIdleWakeupsPerSecond( 66 int ProcessMetrics::CalculateIdleWakeupsPerSecond(
66 uint64 absolute_idle_wakeups) { 67 uint64_t absolute_idle_wakeups) {
67 TimeTicks time = TimeTicks::Now(); 68 TimeTicks time = TimeTicks::Now();
68 69
69 if (last_absolute_idle_wakeups_ == 0) { 70 if (last_absolute_idle_wakeups_ == 0) {
70 // First call, just set the last values. 71 // First call, just set the last values.
71 last_idle_wakeups_time_ = time; 72 last_idle_wakeups_time_ = time;
72 last_absolute_idle_wakeups_ = absolute_idle_wakeups; 73 last_absolute_idle_wakeups_ = absolute_idle_wakeups;
73 return 0; 74 return 0;
74 } 75 }
75 76
76 int64 wakeups_delta = absolute_idle_wakeups - last_absolute_idle_wakeups_; 77 int64_t wakeups_delta = absolute_idle_wakeups - last_absolute_idle_wakeups_;
77 int64 time_delta = (time - last_idle_wakeups_time_).InMicroseconds(); 78 int64_t time_delta = (time - last_idle_wakeups_time_).InMicroseconds();
78 if (time_delta == 0) { 79 if (time_delta == 0) {
79 NOTREACHED(); 80 NOTREACHED();
80 return 0; 81 return 0;
81 } 82 }
82 83
83 last_idle_wakeups_time_ = time; 84 last_idle_wakeups_time_ = time;
84 last_absolute_idle_wakeups_ = absolute_idle_wakeups; 85 last_absolute_idle_wakeups_ = absolute_idle_wakeups;
85 86
86 // Round to average wakeups per second. 87 // Round to average wakeups per second.
87 int64 wakeups_delta_for_ms = wakeups_delta * Time::kMicrosecondsPerSecond; 88 int64_t wakeups_delta_for_ms = wakeups_delta * Time::kMicrosecondsPerSecond;
88 return (wakeups_delta_for_ms + time_delta / 2) / time_delta; 89 return (wakeups_delta_for_ms + time_delta / 2) / time_delta;
89 } 90 }
90 #else 91 #else
91 int ProcessMetrics::GetIdleWakeupsPerSecond() { 92 int ProcessMetrics::GetIdleWakeupsPerSecond() {
92 NOTIMPLEMENTED(); // http://crbug.com/120488 93 NOTIMPLEMENTED(); // http://crbug.com/120488
93 return 0; 94 return 0;
94 } 95 }
95 #endif // defined(OS_MACOSX) || defined(OS_LINUX) 96 #endif // defined(OS_MACOSX) || defined(OS_LINUX)
96 97
97 } // namespace base 98 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_metrics.h ('k') | base/process/process_metrics_freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698