OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/time/time.h" | 5 #include "base/time/time.h" |
6 | 6 |
7 #include <CoreFoundation/CFDate.h> | 7 #include <CoreFoundation/CFDate.h> |
8 #include <CoreFoundation/CFTimeZone.h> | 8 #include <CoreFoundation/CFTimeZone.h> |
9 #include <mach/mach.h> | 9 #include <mach/mach.h> |
10 #include <mach/mach_time.h> | 10 #include <mach/mach_time.h> |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 kern_return_t kr = thread_info( | 87 kern_return_t kr = thread_info( |
88 thread.get(), | 88 thread.get(), |
89 THREAD_BASIC_INFO, | 89 THREAD_BASIC_INFO, |
90 reinterpret_cast<thread_info_t>(&thread_info_data), | 90 reinterpret_cast<thread_info_t>(&thread_info_data), |
91 &thread_info_count); | 91 &thread_info_count); |
92 MACH_DCHECK(kr == KERN_SUCCESS, kr) << "thread_info"; | 92 MACH_DCHECK(kr == KERN_SUCCESS, kr) << "thread_info"; |
93 | 93 |
94 base::CheckedNumeric<int64_t> absolute_micros( | 94 base::CheckedNumeric<int64_t> absolute_micros( |
95 thread_info_data.user_time.seconds); | 95 thread_info_data.user_time.seconds + |
| 96 thread_info_data.system_time.seconds); |
96 absolute_micros *= base::Time::kMicrosecondsPerSecond; | 97 absolute_micros *= base::Time::kMicrosecondsPerSecond; |
97 absolute_micros += thread_info_data.user_time.microseconds; | 98 absolute_micros += (thread_info_data.user_time.microseconds + |
| 99 thread_info_data.system_time.microseconds); |
98 return absolute_micros.ValueOrDie(); | 100 return absolute_micros.ValueOrDie(); |
99 #endif // defined(OS_IOS) | 101 #endif // defined(OS_IOS) |
100 } | 102 } |
101 | 103 |
102 } // namespace | 104 } // namespace |
103 | 105 |
104 namespace base { | 106 namespace base { |
105 | 107 |
106 // The Time routines in this file use Mach and CoreFoundation APIs, since the | 108 // The Time routines in this file use Mach and CoreFoundation APIs, since the |
107 // POSIX definition of time_t in Mac OS X wraps around after 2038--and | 109 // POSIX definition of time_t in Mac OS X wraps around after 2038--and |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 return Clock::MAC_MACH_ABSOLUTE_TIME; | 246 return Clock::MAC_MACH_ABSOLUTE_TIME; |
245 #endif // defined(OS_IOS) | 247 #endif // defined(OS_IOS) |
246 } | 248 } |
247 | 249 |
248 // static | 250 // static |
249 ThreadTicks ThreadTicks::Now() { | 251 ThreadTicks ThreadTicks::Now() { |
250 return ThreadTicks(ComputeThreadTicks()); | 252 return ThreadTicks(ComputeThreadTicks()); |
251 } | 253 } |
252 | 254 |
253 } // namespace base | 255 } // namespace base |
OLD | NEW |