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

Unified Diff: base/time/time.h

Issue 669083002: Add logging support for base::Time* types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change output for TimeTicks to bogo-microseconds. 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
« no previous file with comments | « no previous file | base/time/time.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time/time.h
diff --git a/base/time/time.h b/base/time/time.h
index 3cf3746166ed8dc16cc937945d0918cfe6ef8ede..641f465af3e471afc3b4833b2c6b2a9faf122d8e 100644
--- a/base/time/time.h
+++ b/base/time/time.h
@@ -19,12 +19,18 @@
//
// These classes are represented as only a 64-bit value, so they can be
// efficiently passed by value.
+//
+// Definitions of operator<< are provided to make these types work with
+// DCHECK_EQ() and other log macros. For human-readable formatting, see
+// "base/i18n/time_formatting.h".
#ifndef BASE_TIME_TIME_H_
#define BASE_TIME_TIME_H_
#include <time.h>
+#include <iosfwd>
+
#include "base/base_export.h"
#include "base/basictypes.h"
#include "build/build_config.h"
@@ -206,6 +212,9 @@ inline TimeDelta operator*(int64 a, TimeDelta td) {
return TimeDelta(a * td.delta_);
}
+// For logging use only.
+BASE_EXPORT std::ostream& operator<<(std::ostream& os, TimeDelta time_delta);
+
// Time -----------------------------------------------------------------------
// Represents a wall clock time in UTC.
@@ -561,6 +570,9 @@ inline Time TimeDelta::operator+(Time t) const {
return Time(t.us_ + delta_);
}
+// For logging use only.
+BASE_EXPORT std::ostream& operator<<(std::ostream& os, Time time);
+
// TimeTicks ------------------------------------------------------------------
class BASE_EXPORT TimeTicks {
@@ -723,6 +735,9 @@ inline TimeTicks TimeDelta::operator+(TimeTicks t) const {
return TimeTicks(t.ticks_ + delta_);
}
+// For logging use only.
+BASE_EXPORT std::ostream& operator<<(std::ostream& os, TimeTicks time_ticks);
+
} // namespace base
#endif // BASE_TIME_TIME_H_
« no previous file with comments | « no previous file | base/time/time.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698