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

Unified Diff: base/time/time_logging.cc

Issue 665023002: Post-commit fixes for "stale-while-revalidate..." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make DCHECK_EQ work for TimeDelta objects. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: base/time/time_logging.cc
diff --git a/base/time/time_logging.cc b/base/time/time_logging.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7574eabc3709b29c991edcd569f970d3a0884def
--- /dev/null
+++ b/base/time/time_logging.cc
@@ -0,0 +1,42 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Resist the urge to make the output of these fancy. They are just for
+// debugging.
+
+#include "base/time/time_logging.h"
+
+#include <iostream>
+
+#include "base/strings/stringprintf.h"
+#include "base/time/time.h"
+
+namespace base {
+
+std::ostream& operator<<(std::ostream& os, const TimeDelta& time_delta) {
+ return os << time_delta.InSecondsF() << "s";
+}
+
+std::ostream& operator<<(std::ostream& os, const Time& time) {
+ Time::Exploded e;
mmenke 2014/10/21 14:20:09 nit: Google style guide strong discourages using
Adam Rice 2014/10/23 01:13:02 Done.
+ time.UTCExplode(&e);
+ // Use StringPrintf because iostreams formatting is painful.
+ return os << StringPrintf("%04d-%02d-%02d %02d:%02d:%02d.%03d UTC",
+ e.year,
+ e.month,
+ e.day_of_month,
+ e.hour,
+ e.minute,
+ e.second,
+ e.millisecond);
+}
+
+std::ostream& operator<<(std::ostream& os, const TimeTicks& time_ticks) {
+ // This function formats a TimeTicks object as if it was a Time object.
+ const Time as_time =
+ Time::UnixEpoch() + (time_ticks - TimeTicks::UnixEpoch());
+ return os << as_time;
+}
+
+} // namespace base

Powered by Google App Engine
This is Rietveld 408576698