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 <algorithm> | 7 #include <algorithm> |
8 #include <ostream> | 8 #include <ostream> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 const char kAbortChainSizeNewNavigation[] = | 44 const char kAbortChainSizeNewNavigation[] = |
45 "PageLoad.Internal.ProvisionalAbortChainSize.NewNavigation"; | 45 "PageLoad.Internal.ProvisionalAbortChainSize.NewNavigation"; |
46 const char kAbortChainSizeSameURL[] = | 46 const char kAbortChainSizeSameURL[] = |
47 "PageLoad.Internal.ProvisionalAbortChainSize.SameURL"; | 47 "PageLoad.Internal.ProvisionalAbortChainSize.SameURL"; |
48 const char kAbortChainSizeNoCommit[] = | 48 const char kAbortChainSizeNoCommit[] = |
49 "PageLoad.Internal.ProvisionalAbortChainSize.NoCommit"; | 49 "PageLoad.Internal.ProvisionalAbortChainSize.NoCommit"; |
50 const char kClientRedirectFirstPaintToNavigation[] = | 50 const char kClientRedirectFirstPaintToNavigation[] = |
51 "PageLoad.Internal.ClientRedirect.FirstPaintToNavigation"; | 51 "PageLoad.Internal.ClientRedirect.FirstPaintToNavigation"; |
52 const char kClientRedirectWithoutPaint[] = | 52 const char kClientRedirectWithoutPaint[] = |
53 "PageLoad.Internal.ClientRedirect.NavigationWithoutPaint"; | 53 "PageLoad.Internal.ClientRedirect.NavigationWithoutPaint"; |
| 54 const char kCommitToCompleteNoTimingIPCs[] = |
| 55 "PageLoad.Internal.CommitToComplete.NoTimingIPCs"; |
54 | 56 |
55 } // namespace internal | 57 } // namespace internal |
56 | 58 |
57 namespace { | 59 namespace { |
58 | 60 |
59 // Helper to allow use of Optional<> values in LOG() messages. | 61 // Helper to allow use of Optional<> values in LOG() messages. |
60 std::ostream& operator<<(std::ostream& os, | 62 std::ostream& operator<<(std::ostream& os, |
61 const base::Optional<base::TimeDelta>& opt) { | 63 const base::Optional<base::TimeDelta>& opt) { |
62 if (opt) | 64 if (opt) |
63 os << opt.value(); | 65 os << opt.value(); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 observer->OnStart(navigation_handle, currently_committed_url, | 260 observer->OnStart(navigation_handle, currently_committed_url, |
259 started_in_foreground_); | 261 started_in_foreground_); |
260 } | 262 } |
261 } | 263 } |
262 | 264 |
263 PageLoadTracker::~PageLoadTracker() { | 265 PageLoadTracker::~PageLoadTracker() { |
264 if (did_stop_tracking_) | 266 if (did_stop_tracking_) |
265 return; | 267 return; |
266 | 268 |
267 const PageLoadExtraInfo info = ComputePageLoadExtraInfo(); | 269 const PageLoadExtraInfo info = ComputePageLoadExtraInfo(); |
268 | 270 DCHECK_NE(static_cast<bool>(info.time_to_commit), |
| 271 static_cast<bool>(failed_provisional_load_info_)); |
269 if (info.time_to_commit && timing_.IsEmpty()) { | 272 if (info.time_to_commit && timing_.IsEmpty()) { |
270 RecordInternalError(ERR_NO_IPCS_RECEIVED); | 273 RecordInternalError(ERR_NO_IPCS_RECEIVED); |
| 274 const base::TimeTicks commit_time = |
| 275 navigation_start_ + info.time_to_commit.value(); |
| 276 PAGE_LOAD_HISTOGRAM(internal::kCommitToCompleteNoTimingIPCs, |
| 277 base::TimeTicks::Now() - commit_time); |
271 } | 278 } |
272 // Recall that trackers that are given ABORT_UNKNOWN_NAVIGATION have their | 279 // Recall that trackers that are given ABORT_UNKNOWN_NAVIGATION have their |
273 // chain length added to the next navigation. Take care not to double count | 280 // chain length added to the next navigation. Take care not to double count |
274 // them. Also do not double count committed loads, which call this already. | 281 // them. Also do not double count committed loads, which call this already. |
275 if (commit_time_.is_null() && abort_type_ != ABORT_UNKNOWN_NAVIGATION) | 282 if (commit_time_.is_null() && abort_type_ != ABORT_UNKNOWN_NAVIGATION) |
276 LogAbortChainHistograms(nullptr); | 283 LogAbortChainHistograms(nullptr); |
277 | 284 |
278 for (const auto& observer : observers_) { | 285 for (const auto& observer : observers_) { |
279 observer->OnComplete(timing_, info); | 286 if (failed_provisional_load_info_) { |
| 287 observer->OnFailedProvisionalLoad(*failed_provisional_load_info_, info); |
| 288 } else { |
| 289 observer->OnComplete(timing_, info); |
| 290 } |
280 } | 291 } |
281 } | 292 } |
282 | 293 |
283 void PageLoadTracker::LogAbortChainHistograms( | 294 void PageLoadTracker::LogAbortChainHistograms( |
284 content::NavigationHandle* final_navigation) { | 295 content::NavigationHandle* final_navigation) { |
285 if (aborted_chain_size_ == 0) | 296 if (aborted_chain_size_ == 0) |
286 return; | 297 return; |
287 // Note that this could be broken out by this navigation's abort type, if more | 298 // Note that this could be broken out by this navigation's abort type, if more |
288 // granularity is needed. Add one to the chain size to count the current | 299 // granularity is needed. Add one to the chain size to count the current |
289 // navigation. In the other cases, the current navigation is the final | 300 // navigation. In the other cases, the current navigation is the final |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 ClampBrowserTimestampIfInterProcessTimeTickSkew(&commit_time_); | 373 ClampBrowserTimestampIfInterProcessTimeTickSkew(&commit_time_); |
363 url_ = navigation_handle->GetURL(); | 374 url_ = navigation_handle->GetURL(); |
364 for (const auto& observer : observers_) { | 375 for (const auto& observer : observers_) { |
365 observer->OnCommit(navigation_handle); | 376 observer->OnCommit(navigation_handle); |
366 } | 377 } |
367 LogAbortChainHistograms(navigation_handle); | 378 LogAbortChainHistograms(navigation_handle); |
368 } | 379 } |
369 | 380 |
370 void PageLoadTracker::FailedProvisionalLoad( | 381 void PageLoadTracker::FailedProvisionalLoad( |
371 content::NavigationHandle* navigation_handle) { | 382 content::NavigationHandle* navigation_handle) { |
372 for (const auto& observer : observers_) { | 383 DCHECK(!failed_provisional_load_info_); |
373 observer->OnFailedProvisionalLoad(navigation_handle); | 384 failed_provisional_load_info_.reset(new FailedProvisionalLoadInfo( |
374 } | 385 base::TimeTicks::Now() - navigation_handle->NavigationStart(), |
| 386 navigation_handle->GetNetErrorCode())); |
375 } | 387 } |
376 | 388 |
377 void PageLoadTracker::Redirect(content::NavigationHandle* navigation_handle) { | 389 void PageLoadTracker::Redirect(content::NavigationHandle* navigation_handle) { |
378 for (const auto& observer : observers_) { | 390 for (const auto& observer : observers_) { |
379 observer->OnRedirect(navigation_handle); | 391 observer->OnRedirect(navigation_handle); |
380 } | 392 } |
381 } | 393 } |
382 | 394 |
383 void PageLoadTracker::OnInputEvent(const blink::WebInputEvent& event) { | 395 void PageLoadTracker::OnInputEvent(const blink::WebInputEvent& event) { |
384 for (const auto& observer : observers_) { | 396 for (const auto& observer : observers_) { |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 if (navigation_handle->IsSamePage() || navigation_handle->IsErrorPage()) | 951 if (navigation_handle->IsSamePage() || navigation_handle->IsErrorPage()) |
940 return false; | 952 return false; |
941 const std::string& mime_type = web_contents()->GetContentsMimeType(); | 953 const std::string& mime_type = web_contents()->GetContentsMimeType(); |
942 if (mime_type != "text/html" && mime_type != "application/xhtml+xml") | 954 if (mime_type != "text/html" && mime_type != "application/xhtml+xml") |
943 return false; | 955 return false; |
944 } | 956 } |
945 return true; | 957 return true; |
946 } | 958 } |
947 | 959 |
948 } // namespace page_load_metrics | 960 } // namespace page_load_metrics |
OLD | NEW |