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

Side by Side 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, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // *** IMPORTANT ***: If you change the number of TimeDeltas in PageLoadTiming,
18 // also make sure to update the implementation of operator== and IsEmpty below
19 // to reflect your changes (and update kNumTimeDeltas as well).
20 const int kNumTimeDeltas = 13;
21
22 const size_t kSizeOfTime = sizeof(base::Time);
23 const size_t kSizeOfOptionalTimeDelta = sizeof(base::Optional<base::TimeDelta>);
24 const size_t kSizeOfAllOptionalTimeDeltas =
25 kSizeOfOptionalTimeDelta * kNumTimeDeltas;
26 static_assert(
27 sizeof(page_load_metrics::PageLoadTiming) ==
28 kSizeOfTime + kSizeOfAllOptionalTimeDeltas,
29 "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
30
31 } // namespace
32
15 bool PageLoadTiming::operator==(const PageLoadTiming& other) const { 33 bool PageLoadTiming::operator==(const PageLoadTiming& other) const {
16 return navigation_start == other.navigation_start && 34 return navigation_start == other.navigation_start &&
17 response_start == other.response_start && 35 response_start == other.response_start &&
18 dom_loading == other.dom_loading && 36 dom_loading == other.dom_loading &&
19 dom_content_loaded_event_start == 37 dom_content_loaded_event_start ==
20 other.dom_content_loaded_event_start && 38 other.dom_content_loaded_event_start &&
21 load_event_start == other.load_event_start && 39 load_event_start == other.load_event_start &&
22 first_layout == other.first_layout && 40 first_layout == other.first_layout &&
23 first_paint == other.first_paint && 41 first_paint == other.first_paint &&
24 first_text_paint == other.first_text_paint && 42 first_text_paint == other.first_text_paint &&
(...skipping 15 matching lines...) Expand all
40 !parse_blocked_on_script_load_from_document_write_duration; 58 !parse_blocked_on_script_load_from_document_write_duration;
41 } 59 }
42 60
43 PageLoadMetadata::PageLoadMetadata() {} 61 PageLoadMetadata::PageLoadMetadata() {}
44 62
45 bool PageLoadMetadata::operator==(const PageLoadMetadata& other) const { 63 bool PageLoadMetadata::operator==(const PageLoadMetadata& other) const {
46 return behavior_flags == other.behavior_flags; 64 return behavior_flags == other.behavior_flags;
47 } 65 }
48 66
49 } // namespace page_load_metrics 67 } // namespace page_load_metrics
OLDNEW
« 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