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

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

Issue 864943002: Replaces instances of the deprecated TimeTicks::HighResNow() with TimeTicks::Now(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More changes based on review comments. Created 5 years, 11 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_unittest.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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 331
332 // Use the Chrome OS specific system-wide clock. 332 // Use the Chrome OS specific system-wide clock.
333 #if defined(OS_CHROMEOS) 333 #if defined(OS_CHROMEOS)
334 // static 334 // static
335 TimeTicks TimeTicks::NowFromSystemTraceTime() { 335 TimeTicks TimeTicks::NowFromSystemTraceTime() {
336 uint64_t absolute_micro; 336 uint64_t absolute_micro;
337 337
338 struct timespec ts; 338 struct timespec ts;
339 if (clock_gettime(kClockSystemTrace, &ts) != 0) { 339 if (clock_gettime(kClockSystemTrace, &ts) != 0) {
340 // NB: fall-back for a chrome os build running on linux 340 // NB: fall-back for a chrome os build running on linux
341 return HighResNow(); 341 return Now();
342 } 342 }
343 343
344 absolute_micro = 344 absolute_micro =
345 (static_cast<int64>(ts.tv_sec) * Time::kMicrosecondsPerSecond) + 345 (static_cast<int64>(ts.tv_sec) * Time::kMicrosecondsPerSecond) +
346 (static_cast<int64>(ts.tv_nsec) / Time::kNanosecondsPerMicrosecond); 346 (static_cast<int64>(ts.tv_nsec) / Time::kNanosecondsPerMicrosecond);
347 347
348 return TimeTicks(absolute_micro); 348 return TimeTicks(absolute_micro);
349 } 349 }
350 350
351 #else // !defined(OS_CHROMEOS) 351 #else // !defined(OS_CHROMEOS)
352 352
353 // static 353 // static
354 TimeTicks TimeTicks::NowFromSystemTraceTime() { 354 TimeTicks TimeTicks::NowFromSystemTraceTime() {
355 return HighResNow(); 355 return Now();
356 } 356 }
357 357
358 #endif // defined(OS_CHROMEOS) 358 #endif // defined(OS_CHROMEOS)
359 359
360 #endif // !OS_MACOSX 360 #endif // !OS_MACOSX
361 361
362 // static 362 // static
363 Time Time::FromTimeVal(struct timeval t) { 363 Time Time::FromTimeVal(struct timeval t) {
364 DCHECK_LT(t.tv_usec, static_cast<int>(Time::kMicrosecondsPerSecond)); 364 DCHECK_LT(t.tv_usec, static_cast<int>(Time::kMicrosecondsPerSecond));
365 DCHECK_GE(t.tv_usec, 0); 365 DCHECK_GE(t.tv_usec, 0);
(...skipping 20 matching lines...) Expand all
386 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; 386 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1;
387 return result; 387 return result;
388 } 388 }
389 int64 us = us_ - kTimeTToMicrosecondsOffset; 389 int64 us = us_ - kTimeTToMicrosecondsOffset;
390 result.tv_sec = us / Time::kMicrosecondsPerSecond; 390 result.tv_sec = us / Time::kMicrosecondsPerSecond;
391 result.tv_usec = us % Time::kMicrosecondsPerSecond; 391 result.tv_usec = us % Time::kMicrosecondsPerSecond;
392 return result; 392 return result;
393 } 393 }
394 394
395 } // namespace base 395 } // namespace base
OLDNEW
« no previous file with comments | « base/time/time_mac.cc ('k') | base/time/time_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698