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

Side by Side Diff: base/time/time_posix.cc

Issue 1824673002: time: Add a static TimeTicks method that returns the underlying clock (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use IsHighResolution Created 4 years, 8 months 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/time/time_mac.cc ('k') | base/time/time_win.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 (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 <stdint.h> 7 #include <stdint.h>
8 #include <sys/time.h> 8 #include <sys/time.h>
9 #include <time.h> 9 #include <time.h>
10 #if defined(OS_ANDROID) && !defined(__LP64__) 10 #if defined(OS_ANDROID) && !defined(__LP64__)
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 kWindowsEpochDeltaMicroseconds); 305 kWindowsEpochDeltaMicroseconds);
306 } 306 }
307 307
308 // TimeTicks ------------------------------------------------------------------ 308 // TimeTicks ------------------------------------------------------------------
309 // static 309 // static
310 TimeTicks TimeTicks::Now() { 310 TimeTicks TimeTicks::Now() {
311 return TimeTicks(ClockNow(CLOCK_MONOTONIC)); 311 return TimeTicks(ClockNow(CLOCK_MONOTONIC));
312 } 312 }
313 313
314 // static 314 // static
315 TimeTicks::Clock TimeTicks::GetClock() {
316 return Clock::LINUX_CLOCK_MONOTONIC;
317 }
318
319 // static
315 bool TimeTicks::IsHighResolution() { 320 bool TimeTicks::IsHighResolution() {
316 return true; 321 return true;
317 } 322 }
318 323
319 // static 324 // static
320 ThreadTicks ThreadTicks::Now() { 325 ThreadTicks ThreadTicks::Now() {
321 #if (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ 326 #if (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \
322 defined(OS_ANDROID) 327 defined(OS_ANDROID)
323 return ThreadTicks(ClockNow(CLOCK_THREAD_CPUTIME_ID)); 328 return ThreadTicks(ClockNow(CLOCK_THREAD_CPUTIME_ID));
324 #else 329 #else
(...skipping 29 matching lines...) Expand all
354 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; 359 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1;
355 return result; 360 return result;
356 } 361 }
357 int64_t us = us_ - kTimeTToMicrosecondsOffset; 362 int64_t us = us_ - kTimeTToMicrosecondsOffset;
358 result.tv_sec = us / Time::kMicrosecondsPerSecond; 363 result.tv_sec = us / Time::kMicrosecondsPerSecond;
359 result.tv_usec = us % Time::kMicrosecondsPerSecond; 364 result.tv_usec = us % Time::kMicrosecondsPerSecond;
360 return result; 365 return result;
361 } 366 }
362 367
363 } // namespace base 368 } // namespace base
OLDNEW
« no previous file with comments | « base/time/time_mac.cc ('k') | base/time/time_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698