| 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 "components/page_load_metrics/browser/metrics_web_contents_observer.h" | 5 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "components/page_load_metrics/common/page_load_metrics_messages.h" | 9 #include "components/page_load_metrics/common/page_load_metrics_messages.h" |
| 10 #include "components/page_load_metrics/common/page_load_timing.h" | 10 #include "components/page_load_metrics/common/page_load_timing.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool IsValidPageLoadTiming(const PageLoadTiming& timing) { | 44 bool IsValidPageLoadTiming(const PageLoadTiming& timing) { |
| 45 if (timing.IsEmpty()) | 45 if (timing.IsEmpty()) |
| 46 return false; | 46 return false; |
| 47 | 47 |
| 48 // If we have a non-empty timing, it should always have a navigation start. | 48 // If we have a non-empty timing, it should always have a navigation start. |
| 49 DCHECK(!timing.navigation_start.is_null()); | 49 DCHECK(!timing.navigation_start.is_null()); |
| 50 | 50 |
| 51 // If we have a DOM content loaded event, we should have a response start. | 51 // If we have a DOM content loaded event, we should have a response start. |
| 52 DCHECK_IMPLIES( | 52 DCHECK(timing.dom_content_loaded_event_start.is_zero() || |
| 53 !timing.dom_content_loaded_event_start.is_zero(), | 53 timing.response_start <= timing.dom_content_loaded_event_start); |
| 54 timing.response_start <= timing.dom_content_loaded_event_start); | |
| 55 | 54 |
| 56 // If we have a load event, we should have both a response start and a DCL. | 55 // If we have a load event, we should have both a response start and a DCL. |
| 57 // TODO(csharrison) crbug.com/536203 shows that sometimes we can get a load | 56 // TODO(csharrison) crbug.com/536203 shows that sometimes we can get a load |
| 58 // event without a DCL. Figure out if we can change this condition to use a | 57 // event without a DCL. Figure out if we can change this condition to use a |
| 59 // DCHECK instead. | 58 // DCHECK instead. |
| 60 if (!timing.load_event_start.is_zero() && | 59 if (!timing.load_event_start.is_zero() && |
| 61 (timing.dom_content_loaded_event_start.is_zero() || | 60 (timing.dom_content_loaded_event_start.is_zero() || |
| 62 timing.response_start > timing.load_event_start || | 61 timing.response_start > timing.load_event_start || |
| 63 timing.dom_content_loaded_event_start > timing.load_event_start)) { | 62 timing.dom_content_loaded_event_start > timing.load_event_start)) { |
| 64 return false; | 63 return false; |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 355 |
| 357 if (!committed_load_->UpdateTiming(timing)) { | 356 if (!committed_load_->UpdateTiming(timing)) { |
| 358 // If the page load tracker cannot update its timing, something is wrong | 357 // If the page load tracker cannot update its timing, something is wrong |
| 359 // with the IPC (it's from another load, or it's invalid in some other way). | 358 // with the IPC (it's from another load, or it's invalid in some other way). |
| 360 // We expect this to be a rare occurrence. | 359 // We expect this to be a rare occurrence. |
| 361 RecordInternalError(ERR_BAD_TIMING_IPC); | 360 RecordInternalError(ERR_BAD_TIMING_IPC); |
| 362 } | 361 } |
| 363 } | 362 } |
| 364 | 363 |
| 365 } // namespace page_load_metrics | 364 } // namespace page_load_metrics |
| OLD | NEW |