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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(MetricsWebContentsObserver, message, | 112 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(MetricsWebContentsObserver, message, |
113 render_frame_host) | 113 render_frame_host) |
114 IPC_MESSAGE_HANDLER(PageLoadMetricsMsg_TimingUpdated, OnTimingUpdated) | 114 IPC_MESSAGE_HANDLER(PageLoadMetricsMsg_TimingUpdated, OnTimingUpdated) |
115 IPC_MESSAGE_UNHANDLED(handled = false) | 115 IPC_MESSAGE_UNHANDLED(handled = false) |
116 IPC_END_MESSAGE_MAP() | 116 IPC_END_MESSAGE_MAP() |
117 return handled; | 117 return handled; |
118 } | 118 } |
119 | 119 |
120 void MetricsWebContentsObserver::WillStartNavigationRequest( | 120 void MetricsWebContentsObserver::WillStartNavigationRequest( |
121 content::NavigationHandle* navigation_handle) { | 121 content::NavigationHandle* navigation_handle) { |
122 // Same-page navigations should never go through WillStartNavigationRequest. | 122 // Same-document navigations should never go through |
123 DCHECK(!navigation_handle->IsSamePage()); | 123 // WillStartNavigationRequest. |
| 124 DCHECK(!navigation_handle->IsSameDocument()); |
124 | 125 |
125 if (!navigation_handle->IsInMainFrame()) | 126 if (!navigation_handle->IsInMainFrame()) |
126 return; | 127 return; |
127 | 128 |
128 UserInitiatedInfo user_initiated_info( | 129 UserInitiatedInfo user_initiated_info( |
129 CreateUserInitiatedInfo(navigation_handle, committed_load_.get())); | 130 CreateUserInitiatedInfo(navigation_handle, committed_load_.get())); |
130 std::unique_ptr<PageLoadTracker> last_aborted = | 131 std::unique_ptr<PageLoadTracker> last_aborted = |
131 NotifyAbortedProvisionalLoadsNewNavigation(navigation_handle, | 132 NotifyAbortedProvisionalLoadsNewNavigation(navigation_handle, |
132 user_initiated_info); | 133 user_initiated_info); |
133 | 134 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 255 |
255 void MetricsWebContentsObserver::DidFinishNavigation( | 256 void MetricsWebContentsObserver::DidFinishNavigation( |
256 content::NavigationHandle* navigation_handle) { | 257 content::NavigationHandle* navigation_handle) { |
257 if (!navigation_handle->IsInMainFrame()) | 258 if (!navigation_handle->IsInMainFrame()) |
258 return; | 259 return; |
259 | 260 |
260 std::unique_ptr<PageLoadTracker> finished_nav( | 261 std::unique_ptr<PageLoadTracker> finished_nav( |
261 std::move(provisional_loads_[navigation_handle])); | 262 std::move(provisional_loads_[navigation_handle])); |
262 provisional_loads_.erase(navigation_handle); | 263 provisional_loads_.erase(navigation_handle); |
263 | 264 |
264 // Ignore same-page navigations. | 265 // Ignore same-document navigations. |
265 if (navigation_handle->HasCommitted() && navigation_handle->IsSamePage()) { | 266 if (navigation_handle->HasCommitted() && |
| 267 navigation_handle->IsSameDocument()) { |
266 if (finished_nav) | 268 if (finished_nav) |
267 finished_nav->StopTracking(); | 269 finished_nav->StopTracking(); |
268 return; | 270 return; |
269 } | 271 } |
270 | 272 |
271 // Ignore internally generated aborts for navigations with HTTP responses that | 273 // Ignore internally generated aborts for navigations with HTTP responses that |
272 // don't commit, such as HTTP 204 responses and downloads. | 274 // don't commit, such as HTTP 204 responses and downloads. |
273 if (!navigation_handle->HasCommitted() && | 275 if (!navigation_handle->HasCommitted() && |
274 navigation_handle->GetNetErrorCode() == net::ERR_ABORTED && | 276 navigation_handle->GetNetErrorCode() == net::ERR_ABORTED && |
275 navigation_handle->GetResponseHeaders()) { | 277 navigation_handle->GetResponseHeaders()) { |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 // with the IPC (it's from another load, or it's invalid in some other way). | 540 // with the IPC (it's from another load, or it's invalid in some other way). |
539 // We expect this to be a rare occurrence. | 541 // We expect this to be a rare occurrence. |
540 RecordInternalError(ERR_BAD_TIMING_IPC); | 542 RecordInternalError(ERR_BAD_TIMING_IPC); |
541 } | 543 } |
542 } | 544 } |
543 | 545 |
544 bool MetricsWebContentsObserver::ShouldTrackNavigation( | 546 bool MetricsWebContentsObserver::ShouldTrackNavigation( |
545 content::NavigationHandle* navigation_handle) const { | 547 content::NavigationHandle* navigation_handle) const { |
546 DCHECK(navigation_handle->IsInMainFrame()); | 548 DCHECK(navigation_handle->IsInMainFrame()); |
547 DCHECK(!navigation_handle->HasCommitted() || | 549 DCHECK(!navigation_handle->HasCommitted() || |
548 !navigation_handle->IsSamePage()); | 550 !navigation_handle->IsSameDocument()); |
549 | 551 |
550 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), | 552 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), |
551 navigation_handle).ShouldTrack(); | 553 navigation_handle).ShouldTrack(); |
552 } | 554 } |
553 | 555 |
554 } // namespace page_load_metrics | 556 } // namespace page_load_metrics |
OLD | NEW |