| 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/browser/page_load_metrics/metrics_web_contents_observer.h" | 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 return false; | 85 return false; |
| 86 | 86 |
| 87 // If we have a non-empty timing, it should always have a navigation start. | 87 // If we have a non-empty timing, it should always have a navigation start. |
| 88 if (timing.navigation_start.is_null()) { | 88 if (timing.navigation_start.is_null()) { |
| 89 NOTREACHED() << "Received null navigation_start."; | 89 NOTREACHED() << "Received null navigation_start."; |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 // Verify proper ordering between the various timings. | 93 // Verify proper ordering between the various timings. |
| 94 | 94 |
| 95 if (!EventsInOrder(timing.response_start, timing.dom_loading)) { | |
| 96 // We sometimes get a zero response_start with a non-zero DOM loading. See | |
| 97 // crbug.com/590212. | |
| 98 DLOG(ERROR) << "Invalid response_start " << timing.response_start | |
| 99 << " for dom_loading " << timing.dom_loading; | |
| 100 return false; | |
| 101 } | |
| 102 | |
| 103 if (!EventsInOrder(timing.response_start, timing.parse_start)) { | 95 if (!EventsInOrder(timing.response_start, timing.parse_start)) { |
| 104 // We sometimes get a zero response_start with a non-zero parse start. See | 96 // We sometimes get a zero response_start with a non-zero parse start. See |
| 105 // crbug.com/590212. | 97 // crbug.com/590212. |
| 106 DLOG(ERROR) << "Invalid response_start " << timing.response_start | 98 DLOG(ERROR) << "Invalid response_start " << timing.response_start |
| 107 << " for parse_start " << timing.parse_start; | 99 << " for parse_start " << timing.parse_start; |
| 108 return false; | 100 return false; |
| 109 } | 101 } |
| 110 | 102 |
| 111 if (!EventsInOrder(timing.parse_start, timing.parse_stop)) { | 103 if (!EventsInOrder(timing.parse_start, timing.parse_stop)) { |
| 112 NOTREACHED() << "Invalid parse_start " << timing.parse_start | 104 NOTREACHED() << "Invalid parse_start " << timing.parse_start |
| (...skipping 15 matching lines...) Expand all Loading... |
| 128 if (timing.parse_blocked_on_script_load_from_document_write_duration > | 120 if (timing.parse_blocked_on_script_load_from_document_write_duration > |
| 129 timing.parse_blocked_on_script_load_duration) { | 121 timing.parse_blocked_on_script_load_duration) { |
| 130 NOTREACHED() | 122 NOTREACHED() |
| 131 << "Invalid parse_blocked_on_script_load_from_document_write_duration " | 123 << "Invalid parse_blocked_on_script_load_from_document_write_duration " |
| 132 << timing.parse_blocked_on_script_load_from_document_write_duration | 124 << timing.parse_blocked_on_script_load_from_document_write_duration |
| 133 << " for parse_blocked_on_script_load_duration " | 125 << " for parse_blocked_on_script_load_duration " |
| 134 << timing.parse_blocked_on_script_load_duration; | 126 << timing.parse_blocked_on_script_load_duration; |
| 135 return false; | 127 return false; |
| 136 } | 128 } |
| 137 | 129 |
| 138 if (!EventsInOrder(timing.dom_loading, | 130 if (!EventsInOrder(timing.parse_stop, |
| 139 timing.dom_content_loaded_event_start)) { | 131 timing.dom_content_loaded_event_start)) { |
| 140 NOTREACHED() << "Invalid dom_loading " << timing.dom_loading | 132 NOTREACHED() << "Invalid parse_stop " << timing.parse_stop |
| 141 << " for dom_content_loaded_event_start " | 133 << " for dom_content_loaded_event_start " |
| 142 << timing.dom_content_loaded_event_start; | 134 << timing.dom_content_loaded_event_start; |
| 143 return false; | 135 return false; |
| 144 } | 136 } |
| 145 | 137 |
| 146 if (!EventsInOrder(timing.dom_content_loaded_event_start, | 138 if (!EventsInOrder(timing.dom_content_loaded_event_start, |
| 147 timing.load_event_start)) { | 139 timing.load_event_start)) { |
| 148 NOTREACHED() << "Invalid dom_content_loaded_event_start " | 140 NOTREACHED() << "Invalid dom_content_loaded_event_start " |
| 149 << timing.dom_content_loaded_event_start | 141 << timing.dom_content_loaded_event_start |
| 150 << " for load_event_start " << timing.load_event_start; | 142 << " for load_event_start " << timing.load_event_start; |
| 151 return false; | 143 return false; |
| 152 } | 144 } |
| 153 | 145 |
| 154 if (!EventsInOrder(timing.dom_loading, timing.first_layout)) { | 146 if (!EventsInOrder(timing.parse_start, timing.first_layout)) { |
| 155 NOTREACHED() << "Invalid dom_loading " << timing.dom_loading | 147 NOTREACHED() << "Invalid parse_start " << timing.parse_start |
| 156 << " for first_layout " << timing.first_layout; | 148 << " for first_layout " << timing.first_layout; |
| 157 return false; | 149 return false; |
| 158 } | 150 } |
| 159 | 151 |
| 160 if (!EventsInOrder(timing.first_layout, timing.first_paint)) { | 152 if (!EventsInOrder(timing.first_layout, timing.first_paint)) { |
| 161 // This can happen when we process an XHTML document that doesn't contain | 153 // This can happen when we process an XHTML document that doesn't contain |
| 162 // well formed XML. See crbug.com/627607. | 154 // well formed XML. See crbug.com/627607. |
| 163 DLOG(ERROR) << "Invalid first_layout " << timing.first_layout | 155 DLOG(ERROR) << "Invalid first_layout " << timing.first_layout |
| 164 << " for first_paint " << timing.first_paint; | 156 << " for first_paint " << timing.first_paint; |
| 165 return false; | 157 return false; |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 if (navigation_handle->IsSamePage() || navigation_handle->IsErrorPage()) | 976 if (navigation_handle->IsSamePage() || navigation_handle->IsErrorPage()) |
| 985 return false; | 977 return false; |
| 986 const std::string& mime_type = web_contents()->GetContentsMimeType(); | 978 const std::string& mime_type = web_contents()->GetContentsMimeType(); |
| 987 if (mime_type != "text/html" && mime_type != "application/xhtml+xml") | 979 if (mime_type != "text/html" && mime_type != "application/xhtml+xml") |
| 988 return false; | 980 return false; |
| 989 } | 981 } |
| 990 return true; | 982 return true; |
| 991 } | 983 } |
| 992 | 984 |
| 993 } // namespace page_load_metrics | 985 } // namespace page_load_metrics |
| OLD | NEW |