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

Unified Diff: chrome/common/page_load_metrics/page_load_timing.cc

Issue 2191163003: Add compile time assert to help catch new fields (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fixequal
Patch Set: fix comment Created 4 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/page_load_metrics/page_load_timing.cc
diff --git a/chrome/common/page_load_metrics/page_load_timing.cc b/chrome/common/page_load_metrics/page_load_timing.cc
index b406334a5762d63f6899a269f0958afd61cff6d7..46628162ff23a4786ce9815a110397b9fd0bb5a3 100644
--- a/chrome/common/page_load_metrics/page_load_timing.cc
+++ b/chrome/common/page_load_metrics/page_load_timing.cc
@@ -12,6 +12,24 @@ PageLoadTiming::PageLoadTiming(const PageLoadTiming& other) = default;
PageLoadTiming::~PageLoadTiming() {}
+namespace {
+
+// *** IMPORTANT ***: If you change the number of TimeDeltas in PageLoadTiming,
+// also make sure to update the implementation of operator== and IsEmpty below
+// to reflect your changes (and update kNumTimeDeltas as well).
+const int kNumTimeDeltas = 13;
+
+const size_t kSizeOfTime = sizeof(base::Time);
+const size_t kSizeOfOptionalTimeDelta = sizeof(base::Optional<base::TimeDelta>);
+const size_t kSizeOfAllOptionalTimeDeltas =
+ kSizeOfOptionalTimeDelta * kNumTimeDeltas;
+static_assert(
+ sizeof(page_load_metrics::PageLoadTiming) ==
+ kSizeOfTime + kSizeOfAllOptionalTimeDeltas,
+ "Make sure to update IsEmpty and operator== to reflect your changes.");
kinuko 2016/08/01 15:38:00 Could we always be sure that we have no padding be
+
+} // namespace
+
bool PageLoadTiming::operator==(const PageLoadTiming& other) const {
return navigation_start == other.navigation_start &&
response_start == other.response_start &&
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698