| 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 d96844881c72490c9aa961af1ed3f5712b36fe83..5244d1082348d54203c186a718979730032cb4c9 100644
|
| --- a/chrome/common/page_load_metrics/page_load_timing.cc
|
| +++ b/chrome/common/page_load_metrics/page_load_timing.cc
|
| @@ -12,6 +12,25 @@ PageLoadTiming::PageLoadTiming(const PageLoadTiming& other) = default;
|
|
|
| PageLoadTiming::~PageLoadTiming() {}
|
|
|
| +namespace {
|
| +
|
| +// The number of TimeDelta fields in PageLoadTiming.
|
| +const int kNumTimeDeltas = 13;
|
| +
|
| +constexpr size_t ComputePageLoadTimingSize() {
|
| + // This assumes that the members of PageLoadTiming are stored without any
|
| + // padding. This is true for base::Time and base::Optional<base::TimeDelta>.
|
| + return sizeof(base::Time) /* sizeof navigation_start */ +
|
| + sizeof(base::Optional<base::TimeDelta>) * kNumTimeDeltas;
|
| +}
|
| +
|
| +static_assert(
|
| + sizeof(PageLoadTiming) == ComputePageLoadTimingSize(),
|
| + "*** IMPORTANT ***: If you add new TimeDeltas to PageLoadTiming, update "
|
| + "operator==, IsEmpty, and kNumTimeDeltas to reflect your change.");
|
| +
|
| +} // namespace
|
| +
|
| bool PageLoadTiming::operator==(const PageLoadTiming& other) const {
|
| return navigation_start == other.navigation_start &&
|
| response_start == other.response_start &&
|
|
|