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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // DidStartNavigation would address this. | 267 // DidStartNavigation would address this. |
268 PageLoadTracker* tracker = | 268 PageLoadTracker* tracker = |
269 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); | 269 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); |
270 if (tracker) { | 270 if (tracker) { |
271 ExtraRequestStartInfo extra_request_start_info(resource_type); | 271 ExtraRequestStartInfo extra_request_start_info(resource_type); |
272 tracker->OnStartedResource(extra_request_start_info); | 272 tracker->OnStartedResource(extra_request_start_info); |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 void MetricsWebContentsObserver::OnRequestComplete( | 276 void MetricsWebContentsObserver::OnRequestComplete( |
277 const GURL& url, | |
278 int frame_tree_node_id, | |
279 const content::GlobalRequestID& request_id, | 277 const content::GlobalRequestID& request_id, |
280 content::ResourceType resource_type, | 278 content::ResourceType resource_type, |
281 bool was_cached, | 279 bool was_cached, |
282 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> | 280 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> |
283 data_reduction_proxy_data, | 281 data_reduction_proxy_data, |
284 int64_t raw_body_bytes, | 282 int64_t raw_body_bytes, |
285 int64_t original_content_length, | 283 int64_t original_content_length, |
286 base::TimeTicks creation_time) { | 284 base::TimeTicks creation_time) { |
287 PageLoadTracker* tracker = | 285 PageLoadTracker* tracker = |
288 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); | 286 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); |
289 if (tracker) { | 287 if (tracker) { |
290 ExtraRequestCompleteInfo extra_request_complete_info( | 288 ExtraRequestCompleteInfo extra_request_complete_info( |
291 url, frame_tree_node_id, was_cached, raw_body_bytes, | 289 was_cached, raw_body_bytes, was_cached ? 0 : original_content_length, |
292 was_cached ? 0 : original_content_length, | |
293 std::move(data_reduction_proxy_data), resource_type); | 290 std::move(data_reduction_proxy_data), resource_type); |
294 tracker->OnLoadedResource(extra_request_complete_info); | 291 tracker->OnLoadedResource(extra_request_complete_info); |
295 } | 292 } |
296 } | 293 } |
297 | 294 |
298 void MetricsWebContentsObserver::OnNavigationDelayComplete( | 295 void MetricsWebContentsObserver::OnNavigationDelayComplete( |
299 content::NavigationHandle* navigation_handle, | 296 content::NavigationHandle* navigation_handle, |
300 base::TimeDelta scheduled_delay, | 297 base::TimeDelta scheduled_delay, |
301 base::TimeDelta actual_delay) { | 298 base::TimeDelta actual_delay) { |
302 auto it = provisional_loads_.find(navigation_handle); | 299 auto it = provisional_loads_.find(navigation_handle); |
303 if (it == provisional_loads_.end()) | 300 if (it == provisional_loads_.end()) |
304 return; | 301 return; |
305 it->second->OnNavigationDelayComplete(scheduled_delay, actual_delay); | 302 it->second->OnNavigationDelayComplete(scheduled_delay, actual_delay); |
306 } | 303 } |
307 | 304 |
308 const PageLoadExtraInfo | 305 const PageLoadExtraInfo |
309 MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() { | 306 MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() { |
310 DCHECK(committed_load_); | 307 DCHECK(committed_load_); |
311 return committed_load_->ComputePageLoadExtraInfo(); | 308 return committed_load_->ComputePageLoadExtraInfo(); |
312 } | 309 } |
313 | 310 |
314 void MetricsWebContentsObserver::DidFinishNavigation( | 311 void MetricsWebContentsObserver::DidFinishNavigation( |
315 content::NavigationHandle* navigation_handle) { | 312 content::NavigationHandle* navigation_handle) { |
316 if (!navigation_handle->IsInMainFrame() && committed_load_) { | 313 if (!navigation_handle->IsInMainFrame()) |
317 committed_load_->DidFinishSubFrameNavigation(navigation_handle); | |
318 return; | 314 return; |
319 } | |
320 | 315 |
321 std::unique_ptr<PageLoadTracker> finished_nav( | 316 std::unique_ptr<PageLoadTracker> finished_nav( |
322 std::move(provisional_loads_[navigation_handle])); | 317 std::move(provisional_loads_[navigation_handle])); |
323 provisional_loads_.erase(navigation_handle); | 318 provisional_loads_.erase(navigation_handle); |
324 | 319 |
325 // Ignore same-document navigations. | 320 // Ignore same-document navigations. |
326 if (navigation_handle->HasCommitted() && | 321 if (navigation_handle->HasCommitted() && |
327 navigation_handle->IsSameDocument()) { | 322 navigation_handle->IsSameDocument()) { |
328 if (finished_nav) | 323 if (finished_nav) |
329 finished_nav->StopTracking(); | 324 finished_nav->StopTracking(); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 observer_->RemoveTestingObserver(this); | 637 observer_->RemoveTestingObserver(this); |
643 observer_ = nullptr; | 638 observer_ = nullptr; |
644 } | 639 } |
645 } | 640 } |
646 | 641 |
647 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() { | 642 void MetricsWebContentsObserver::TestingObserver::OnGoingAway() { |
648 observer_ = nullptr; | 643 observer_ = nullptr; |
649 } | 644 } |
650 | 645 |
651 } // namespace page_load_metrics | 646 } // namespace page_load_metrics |
OLD | NEW |