diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-11 23:07:12 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-11 23:07:12 +0000 |
commit | 116dd0ac9189763c959932c1dd24f411d5ab80d6 (patch) | |
tree | 47d40d23b32a65955e20218174c35b50c99f79cc | |
parent | 1d43341ce3d90141fc9e118ae6b204d3893897e8 (diff) | |
download | chromium_src-116dd0ac9189763c959932c1dd24f411d5ab80d6.zip chromium_src-116dd0ac9189763c959932c1dd24f411d5ab80d6.tar.gz chromium_src-116dd0ac9189763c959932c1dd24f411d5ab80d6.tar.bz2 |
GTTF: Replace usage of Time::Now with TimeTicks::Now
in cases where a clock change can really screw up things,
e.g. shorten timeouts.
BUG=none
Review URL: https://codereview.chromium.org/11881004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176462 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/process_util_mac.mm | 4 | ||||
-rw-r--r-- | base/process_util_posix.cc | 14 | ||||
-rw-r--r-- | content/public/test/test_launcher.cc | 16 |
3 files changed, 18 insertions, 16 deletions
diff --git a/base/process_util_mac.mm b/base/process_util_mac.mm index cf1e7a8..8b8c14a 100644 --- a/base/process_util_mac.mm +++ b/base/process_util_mac.mm @@ -1207,14 +1207,14 @@ void WaitForChildToDie(pid_t child, int timeout) { // Keep track of the elapsed time to be able to restart kevent if it's // interrupted. TimeDelta remaining_delta = TimeDelta::FromSeconds(timeout); - Time deadline = Time::Now() + remaining_delta; + TimeTicks deadline = TimeTicks::Now() + remaining_delta; result = -1; struct kevent event = {0}; while (remaining_delta.InMilliseconds() > 0) { const struct timespec remaining_timespec = remaining_delta.ToTimeSpec(); result = kevent(kq, NULL, 0, &event, 1, &remaining_timespec); if (result == -1 && errno == EINTR) { - remaining_delta = deadline - Time::Now(); + remaining_delta = deadline - TimeTicks::Now(); result = 0; } else { break; diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index 284d00f..5ee1ae4 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -106,10 +106,10 @@ int WaitpidWithTimeout(ProcessHandle handle, int64 wait_milliseconds, int64 double_sleep_time = 0; // If the process hasn't exited yet, then sleep and try again. - Time wakeup_time = Time::Now() + + TimeTicks wakeup_time = TimeTicks::Now() + TimeDelta::FromMilliseconds(wait_milliseconds); while (ret_pid == 0) { - Time now = Time::Now(); + TimeTicks now = TimeTicks::Now(); if (now > wakeup_time) break; // Guaranteed to be non-negative! @@ -876,10 +876,10 @@ static bool WaitForSingleNonChildProcess(ProcessHandle handle, // interrupted. bool wait_forever = wait.InMilliseconds() == base::kNoTimeout; base::TimeDelta remaining_delta; - base::Time deadline; + base::TimeTicks deadline; if (!wait_forever) { remaining_delta = wait; - deadline = base::Time::Now() + remaining_delta; + deadline = base::TimeTicks::Now() + remaining_delta; } result = -1; @@ -899,7 +899,7 @@ static bool WaitForSingleNonChildProcess(ProcessHandle handle, if (result == -1 && errno == EINTR) { if (!wait_forever) { - remaining_delta = deadline - base::Time::Now(); + remaining_delta = deadline - base::TimeTicks::Now(); } result = 0; } else { @@ -1156,7 +1156,7 @@ bool WaitForProcessesToExit(const FilePath::StringType& executable_name, // TODO(port): This is inefficient, but works if there are multiple procs. // TODO(port): use waitpid to avoid leaving zombies around - base::Time end_time = base::Time::Now() + wait; + base::TimeTicks end_time = base::TimeTicks::Now() + wait; do { NamedProcessIterator iter(executable_name, filter); if (!iter.NextProcessEntry()) { @@ -1164,7 +1164,7 @@ bool WaitForProcessesToExit(const FilePath::StringType& executable_name, break; } base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); - } while ((end_time - base::Time::Now()) > base::TimeDelta()); + } while ((end_time - base::TimeTicks::Now()) > base::TimeDelta()); return result; } diff --git a/content/public/test/test_launcher.cc b/content/public/test/test_launcher.cc index e572086..178366d9 100644 --- a/content/public/test/test_launcher.cc +++ b/content/public/test/test_launcher.cc @@ -519,7 +519,7 @@ bool RunTests(TestLauncherDelegate* launcher_delegate, continue; } - base::Time start_time = base::Time::Now(); + base::TimeTicks start_time = base::TimeTicks::Now(); ++test_run_count; bool was_timeout = false; int exit_code = RunTest(launcher_delegate, @@ -529,16 +529,18 @@ bool RunTests(TestLauncherDelegate* launcher_delegate, &was_timeout); if (exit_code == 0) { // Test passed. - printer.OnTestEnd(test_info->name(), test_case->name(), true, false, - false, - (base::Time::Now() - start_time).InMillisecondsF()); + printer.OnTestEnd( + test_info->name(), test_case->name(), true, false, + false, + (base::TimeTicks::Now() - start_time).InMillisecondsF()); } else { failed_tests.push_back(test_name); bool ignore_failure = false; - printer.OnTestEnd(test_info->name(), test_case->name(), true, true, - ignore_failure, - (base::Time::Now() - start_time).InMillisecondsF()); + printer.OnTestEnd( + test_info->name(), test_case->name(), true, true, + ignore_failure, + (base::TimeTicks::Now() - start_time).InMillisecondsF()); if (ignore_failure) ignored_tests.insert(test_name); |