summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-15 20:10:51 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-15 20:10:51 +0000
commitcd8fb1ae6e12527b723596ec27d51e3774151eb5 (patch)
tree48c5894389b2b3566f67b2305b0dc4cea32bc1ff /base
parent9c8d0add41c7d0868f2f396940f6b595d3a432b0 (diff)
downloadchromium_src-cd8fb1ae6e12527b723596ec27d51e3774151eb5.zip
chromium_src-cd8fb1ae6e12527b723596ec27d51e3774151eb5.tar.gz
chromium_src-cd8fb1ae6e12527b723596ec27d51e3774151eb5.tar.bz2
[Mac] Enable message loop start UMA measurement on Mac
Turned out we were only recording this information on Windows. Bug=None TEST=All unit tests should pass BUG= Review URL: https://chromiumcodereview.appspot.com/10557007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142459 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/time.h1
-rw-r--r--base/time_posix.cc10
-rw-r--r--base/time_unittest.cc8
3 files changed, 19 insertions, 0 deletions
diff --git a/base/time.h b/base/time.h
index 1487276..b4a7632 100644
--- a/base/time.h
+++ b/base/time.h
@@ -273,6 +273,7 @@ class BASE_EXPORT Time {
double ToJsTime() const;
#if defined(OS_POSIX)
+ static Time FromTimeVal(struct timeval t);
struct timeval ToTimeVal() const;
#endif
diff --git a/base/time_posix.cc b/base/time_posix.cc
index 6f4423f..5fc2c5d 100644
--- a/base/time_posix.cc
+++ b/base/time_posix.cc
@@ -262,6 +262,16 @@ TimeTicks TimeTicks::NowFromSystemTraceTime() {
#endif // !OS_MACOSX
+// static
+Time Time::FromTimeVal(struct timeval t) {
+ DCHECK_LT(t.tv_usec, static_cast<int>(Time::kMicrosecondsPerSecond));
+ DCHECK_GE(t.tv_usec, 0);
+ return Time(
+ (static_cast<int64>(t.tv_sec) * Time::kMicrosecondsPerSecond) +
+ t.tv_usec +
+ kTimeTToMicrosecondsOffset);
+}
+
struct timeval Time::ToTimeVal() const {
struct timeval result;
int64 us = us_ - kTimeTToMicrosecondsOffset;
diff --git a/base/time_unittest.cc b/base/time_unittest.cc
index f89fc8b..43be492 100644
--- a/base/time_unittest.cc
+++ b/base/time_unittest.cc
@@ -98,6 +98,14 @@ TEST_F(TimeTest, JsTime) {
EXPECT_EQ(800730.0, t.ToJsTime());
}
+#if defined(OS_POSIX)
+TEST_F(TimeTest, FromTimeVal) {
+ Time now = Time::Now();
+ Time also_now = Time::FromTimeVal(now.ToTimeVal());
+ EXPECT_EQ(now, also_now);
+}
+#endif // OS_POSIX
+
TEST_F(TimeTest, FromExplodedWithMilliseconds) {
// Some platform implementations of FromExploded are liable to drop
// milliseconds if we aren't careful.