| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/common/page_load_metrics/page_load_timing.h" | 5 #include "chrome/common/page_load_metrics/page_load_timing.h" |
| 6 | 6 |
| 7 namespace page_load_metrics { | 7 namespace page_load_metrics { |
| 8 | 8 |
| 9 PageLoadTiming::PageLoadTiming() {} | 9 PageLoadTiming::PageLoadTiming() {} |
| 10 | 10 |
| 11 PageLoadTiming::PageLoadTiming(const PageLoadTiming& other) = default; | 11 PageLoadTiming::PageLoadTiming(const PageLoadTiming& other) = default; |
| 12 | 12 |
| 13 PageLoadTiming::~PageLoadTiming() {} | 13 PageLoadTiming::~PageLoadTiming() {} |
| 14 | 14 |
| 15 namespace { |
| 16 |
| 17 // The number of TimeDelta fields in PageLoadTiming. |
| 18 const int kNumTimeDeltas = 13; |
| 19 |
| 20 constexpr size_t ComputePageLoadTimingSize() { |
| 21 // This assumes that the members of PageLoadTiming are stored without any |
| 22 // padding. This is true for base::Time and base::Optional<base::TimeDelta>. |
| 23 return sizeof(base::Time) /* sizeof navigation_start */ + |
| 24 sizeof(base::Optional<base::TimeDelta>) * kNumTimeDeltas; |
| 25 } |
| 26 |
| 27 static_assert( |
| 28 sizeof(PageLoadTiming) == ComputePageLoadTimingSize(), |
| 29 "*** IMPORTANT ***: If you add new TimeDeltas to PageLoadTiming, update " |
| 30 "operator==, IsEmpty, and kNumTimeDeltas to reflect your change."); |
| 31 |
| 32 } // namespace |
| 33 |
| 15 bool PageLoadTiming::operator==(const PageLoadTiming& other) const { | 34 bool PageLoadTiming::operator==(const PageLoadTiming& other) const { |
| 16 return navigation_start == other.navigation_start && | 35 return navigation_start == other.navigation_start && |
| 17 response_start == other.response_start && | 36 response_start == other.response_start && |
| 18 dom_content_loaded_event_start == | 37 dom_content_loaded_event_start == |
| 19 other.dom_content_loaded_event_start && | 38 other.dom_content_loaded_event_start && |
| 20 load_event_start == other.load_event_start && | 39 load_event_start == other.load_event_start && |
| 21 first_layout == other.first_layout && | 40 first_layout == other.first_layout && |
| 22 first_paint == other.first_paint && | 41 first_paint == other.first_paint && |
| 23 first_text_paint == other.first_text_paint && | 42 first_text_paint == other.first_text_paint && |
| 24 first_image_paint == other.first_image_paint && | 43 first_image_paint == other.first_image_paint && |
| (...skipping 16 matching lines...) Expand all Loading... |
| 41 !parse_blocked_on_script_load_from_document_write_duration; | 60 !parse_blocked_on_script_load_from_document_write_duration; |
| 42 } | 61 } |
| 43 | 62 |
| 44 PageLoadMetadata::PageLoadMetadata() {} | 63 PageLoadMetadata::PageLoadMetadata() {} |
| 45 | 64 |
| 46 bool PageLoadMetadata::operator==(const PageLoadMetadata& other) const { | 65 bool PageLoadMetadata::operator==(const PageLoadMetadata& other) const { |
| 47 return behavior_flags == other.behavior_flags; | 66 return behavior_flags == other.behavior_flags; |
| 48 } | 67 } |
| 49 | 68 |
| 50 } // namespace page_load_metrics | 69 } // namespace page_load_metrics |
| OLD | NEW |