| 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/renderer/page_load_metrics/metrics_render_frame_observer.h" | 5 #include "chrome/renderer/page_load_metrics/metrics_render_frame_observer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 if (page_timing_metrics_sender_) | 48 if (page_timing_metrics_sender_) |
| 49 page_timing_metrics_sender_->DidObserveLoadingBehavior(behavior); | 49 page_timing_metrics_sender_->DidObserveLoadingBehavior(behavior); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void MetricsRenderFrameObserver::FrameDetached() { | 52 void MetricsRenderFrameObserver::FrameDetached() { |
| 53 page_timing_metrics_sender_.reset(); | 53 page_timing_metrics_sender_.reset(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void MetricsRenderFrameObserver::DidCommitProvisionalLoad( | 56 void MetricsRenderFrameObserver::DidCommitProvisionalLoad( |
| 57 bool is_new_navigation, | 57 bool is_new_navigation, |
| 58 bool is_same_page_navigation) { | 58 bool is_same_document_navigation) { |
| 59 // Same-page navigations (e.g. an in-document navigation from a fragment | 59 // Same-document navigations (e.g. a navigation from a fragment link) aren't |
| 60 // link) aren't full page loads, since they don't go to network to load the | 60 // full page loads, since they don't go to network to load the main HTML |
| 61 // main HTML resource. DidStartProvisionalLoad doesn't get invoked for same | 61 // resource. DidStartProvisionalLoad doesn't get invoked for same document |
| 62 // page navigations, so we may still have an active | 62 // navigations, so we may still have an active page_timing_metrics_sender_ at |
| 63 // page_timing_metrics_sender_ at this point. | 63 // this point. |
| 64 if (is_same_page_navigation) | 64 if (is_same_document_navigation) |
| 65 return; | 65 return; |
| 66 | 66 |
| 67 // Make sure to release the sender for a previous navigation, if we have one. | 67 // Make sure to release the sender for a previous navigation, if we have one. |
| 68 page_timing_metrics_sender_.reset(); | 68 page_timing_metrics_sender_.reset(); |
| 69 | 69 |
| 70 // We only create a PageTimingMetricsSender if the page meets the criteria for | 70 // We only create a PageTimingMetricsSender if the page meets the criteria for |
| 71 // sending and recording metrics. Once page_timing_metrics_sender_ is | 71 // sending and recording metrics. Once page_timing_metrics_sender_ is |
| 72 // non-null, we will send metrics for the current page at some later time, as | 72 // non-null, we will send metrics for the current page at some later time, as |
| 73 // those metrics become available. | 73 // those metrics become available. |
| 74 if (ShouldSendMetrics()) { | 74 if (ShouldSendMetrics()) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 void MetricsRenderFrameObserver::OnDestruct() { | 176 void MetricsRenderFrameObserver::OnDestruct() { |
| 177 delete this; | 177 delete this; |
| 178 } | 178 } |
| 179 | 179 |
| 180 bool MetricsRenderFrameObserver::IsMainFrame() const { | 180 bool MetricsRenderFrameObserver::IsMainFrame() const { |
| 181 return render_frame()->IsMainFrame(); | 181 return render_frame()->IsMainFrame(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace page_load_metrics | 184 } // namespace page_load_metrics |
| OLD | NEW |