| 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 for (const auto& observer : observers_) { | 466 for (const auto& observer : observers_) { |
| 467 observer->OnUserInput(event); | 467 observer->OnUserInput(event); |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 | 470 |
| 471 void PageLoadTracker::FlushMetricsOnAppEnterBackground() { | 471 void PageLoadTracker::FlushMetricsOnAppEnterBackground() { |
| 472 if (!app_entered_background_) { | 472 if (!app_entered_background_) { |
| 473 RecordAppBackgroundPageLoadCompleted(false); | 473 RecordAppBackgroundPageLoadCompleted(false); |
| 474 app_entered_background_ = true; | 474 app_entered_background_ = true; |
| 475 } | 475 } |
| 476 |
| 477 const PageLoadExtraInfo info = ComputePageLoadExtraInfo(); |
| 478 for (auto it = observers_.begin(); it != observers_.end();) { |
| 479 if ((*it)->FlushMetricsOnAppEnterBackground(timing_, info) == |
| 480 PageLoadMetricsObserver::STOP_OBSERVING) { |
| 481 it = observers_.erase(it); |
| 482 } else { |
| 483 ++it; |
| 484 } |
| 485 } |
| 476 } | 486 } |
| 477 | 487 |
| 478 void PageLoadTracker::NotifyClientRedirectTo( | 488 void PageLoadTracker::NotifyClientRedirectTo( |
| 479 const PageLoadTracker& destination) { | 489 const PageLoadTracker& destination) { |
| 480 if (timing_.first_paint) { | 490 if (timing_.first_paint) { |
| 481 base::TimeTicks first_paint_time = | 491 base::TimeTicks first_paint_time = |
| 482 navigation_start() + timing_.first_paint.value(); | 492 navigation_start() + timing_.first_paint.value(); |
| 483 base::TimeDelta first_paint_to_navigation; | 493 base::TimeDelta first_paint_to_navigation; |
| 484 if (destination.navigation_start() > first_paint_time) | 494 if (destination.navigation_start() > first_paint_time) |
| 485 first_paint_to_navigation = | 495 first_paint_to_navigation = |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 const blink::WebInputEvent& event) { | 918 const blink::WebInputEvent& event) { |
| 909 // Ignore browser navigation or reload which comes with type Undefined. | 919 // Ignore browser navigation or reload which comes with type Undefined. |
| 910 if (event.type == blink::WebInputEvent::Type::Undefined) | 920 if (event.type == blink::WebInputEvent::Type::Undefined) |
| 911 return; | 921 return; |
| 912 | 922 |
| 913 if (committed_load_) | 923 if (committed_load_) |
| 914 committed_load_->OnInputEvent(event); | 924 committed_load_->OnInputEvent(event); |
| 915 } | 925 } |
| 916 | 926 |
| 917 void MetricsWebContentsObserver::FlushMetricsOnAppEnterBackground() { | 927 void MetricsWebContentsObserver::FlushMetricsOnAppEnterBackground() { |
| 928 // Signal to observers that we've been backgrounded, in cases where the |
| 929 // FlushMetricsOnAppEnterBackground callback gets invoked before the |
| 930 // associated WasHidden callback. |
| 931 WasHidden(); |
| 932 |
| 918 if (committed_load_) | 933 if (committed_load_) |
| 919 committed_load_->FlushMetricsOnAppEnterBackground(); | 934 committed_load_->FlushMetricsOnAppEnterBackground(); |
| 920 for (const auto& kv : provisional_loads_) { | 935 for (const auto& kv : provisional_loads_) { |
| 921 kv.second->FlushMetricsOnAppEnterBackground(); | 936 kv.second->FlushMetricsOnAppEnterBackground(); |
| 922 } | 937 } |
| 923 for (const auto& tracker : aborted_provisional_loads_) { | 938 for (const auto& tracker : aborted_provisional_loads_) { |
| 924 tracker->FlushMetricsOnAppEnterBackground(); | 939 tracker->FlushMetricsOnAppEnterBackground(); |
| 925 } | 940 } |
| 926 } | 941 } |
| 927 | 942 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 content::NavigationHandle* navigation_handle) const { | 1088 content::NavigationHandle* navigation_handle) const { |
| 1074 DCHECK(navigation_handle->IsInMainFrame()); | 1089 DCHECK(navigation_handle->IsInMainFrame()); |
| 1075 DCHECK(!navigation_handle->HasCommitted() || | 1090 DCHECK(!navigation_handle->HasCommitted() || |
| 1076 !navigation_handle->IsSamePage()); | 1091 !navigation_handle->IsSamePage()); |
| 1077 | 1092 |
| 1078 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), | 1093 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), |
| 1079 navigation_handle).ShouldTrack(); | 1094 navigation_handle).ShouldTrack(); |
| 1080 } | 1095 } |
| 1081 | 1096 |
| 1082 } // namespace page_load_metrics | 1097 } // namespace page_load_metrics |
| OLD | NEW |