X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fbase%2Ftime%2Ftime_win.cc;h=5fa899d1f97f69be69d1df65ba854565d7240b53;hb=4a1a0bdd01eef90b0826a0e761d3379d3715c10f;hp=93f0c25e2c4e2227c86d156cefd716a96fe3a4ff;hpb=b1be5ca53587d23e7aeb77b26861fdc0a181ffd8;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/base/time/time_win.cc b/src/base/time/time_win.cc index 93f0c25..5fa899d 100644 --- a/src/base/time/time_win.cc +++ b/src/base/time/time_win.cc @@ -251,7 +251,7 @@ void Time::Explode(bool is_local, Exploded* exploded) const { // FILETIME in local time if necessary. bool success = true; // FILETIME in SYSTEMTIME (exploded). - SYSTEMTIME st; + SYSTEMTIME st = {0}; if (is_local) { SYSTEMTIME utc_st; // We don't use FileTimeToLocalFileTime here, since it uses the current @@ -393,11 +393,14 @@ class HighResNowSingleton { int64 QPCValueToMicroseconds(LONGLONG qpc_value) { if (!ticks_per_second_) return 0; - - // Intentionally calculate microseconds in a round about manner to avoid - // overflow and precision issues. Think twice before simplifying! + // If the QPC Value is below the overflow threshold, we proceed with + // simple multiply and divide. + if (qpc_value < Time::kQPCOverflowThreshold) + return qpc_value * Time::kMicrosecondsPerSecond / ticks_per_second_; + // Otherwise, calculate microseconds in a round about manner to avoid + // overflow and precision issues. int64 whole_seconds = qpc_value / ticks_per_second_; - int64 leftover_ticks = qpc_value % ticks_per_second_; + int64 leftover_ticks = qpc_value - (whole_seconds * ticks_per_second_); int64 microseconds = (whole_seconds * Time::kMicrosecondsPerSecond) + ((leftover_ticks * Time::kMicrosecondsPerSecond) / ticks_per_second_); @@ -447,7 +450,8 @@ NowFunction now_function = RolloverProtectedNow; bool CPUReliablySupportsHighResTime() { base::CPU cpu; - if (!cpu.has_non_stop_time_stamp_counter()) + if (!cpu.has_non_stop_time_stamp_counter() || + !GetHighResNowSingleton()->IsUsingHighResClock()) return false; if (IsBuggyAthlon(cpu))