Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc

Issue 2798953002: [PageLoadMetrics] Keep track of Ad Sizes on Pages (Closed)
Patch Set: Address comments from PS22 Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // DidStartNavigation would address this. 264 // DidStartNavigation would address this.
265 PageLoadTracker* tracker = 265 PageLoadTracker* tracker =
266 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); 266 GetTrackerOrNullForRequest(request_id, resource_type, creation_time);
267 if (tracker) { 267 if (tracker) {
268 ExtraRequestStartInfo extra_request_start_info(resource_type); 268 ExtraRequestStartInfo extra_request_start_info(resource_type);
269 tracker->OnStartedResource(extra_request_start_info); 269 tracker->OnStartedResource(extra_request_start_info);
270 } 270 }
271 } 271 }
272 272
273 void MetricsWebContentsObserver::OnRequestComplete( 273 void MetricsWebContentsObserver::OnRequestComplete(
274 const GURL& url,
275 int frame_tree_node_id,
274 const content::GlobalRequestID& request_id, 276 const content::GlobalRequestID& request_id,
275 content::ResourceType resource_type, 277 content::ResourceType resource_type,
276 bool was_cached, 278 bool was_cached,
277 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> 279 std::unique_ptr<data_reduction_proxy::DataReductionProxyData>
278 data_reduction_proxy_data, 280 data_reduction_proxy_data,
279 int64_t raw_body_bytes, 281 int64_t raw_body_bytes,
280 int64_t original_content_length, 282 int64_t original_content_length,
281 base::TimeTicks creation_time) { 283 base::TimeTicks creation_time) {
282 PageLoadTracker* tracker = 284 PageLoadTracker* tracker =
283 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); 285 GetTrackerOrNullForRequest(request_id, resource_type, creation_time);
284 if (tracker) { 286 if (tracker) {
285 ExtraRequestCompleteInfo extra_request_complete_info( 287 ExtraRequestCompleteInfo extra_request_complete_info(
286 was_cached, raw_body_bytes, was_cached ? 0 : original_content_length, 288 url, frame_tree_node_id, was_cached, raw_body_bytes,
289 was_cached ? 0 : original_content_length,
287 std::move(data_reduction_proxy_data), resource_type); 290 std::move(data_reduction_proxy_data), resource_type);
288 tracker->OnLoadedResource(extra_request_complete_info); 291 tracker->OnLoadedResource(extra_request_complete_info);
289 } 292 }
290 } 293 }
291 294
292 void MetricsWebContentsObserver::OnNavigationDelayComplete( 295 void MetricsWebContentsObserver::OnNavigationDelayComplete(
293 content::NavigationHandle* navigation_handle, 296 content::NavigationHandle* navigation_handle,
294 base::TimeDelta scheduled_delay, 297 base::TimeDelta scheduled_delay,
295 base::TimeDelta actual_delay) { 298 base::TimeDelta actual_delay) {
296 auto it = provisional_loads_.find(navigation_handle); 299 auto it = provisional_loads_.find(navigation_handle);
297 if (it == provisional_loads_.end()) 300 if (it == provisional_loads_.end())
298 return; 301 return;
299 it->second->OnNavigationDelayComplete(scheduled_delay, actual_delay); 302 it->second->OnNavigationDelayComplete(scheduled_delay, actual_delay);
300 } 303 }
301 304
302 const PageLoadExtraInfo 305 const PageLoadExtraInfo
303 MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() { 306 MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() {
304 DCHECK(committed_load_); 307 DCHECK(committed_load_);
305 return committed_load_->ComputePageLoadExtraInfo(); 308 return committed_load_->ComputePageLoadExtraInfo();
306 } 309 }
307 310
308 void MetricsWebContentsObserver::DidFinishNavigation( 311 void MetricsWebContentsObserver::DidFinishNavigation(
309 content::NavigationHandle* navigation_handle) { 312 content::NavigationHandle* navigation_handle) {
310 if (!navigation_handle->IsInMainFrame()) 313 if (!navigation_handle->IsInMainFrame() && committed_load_) {
314 committed_load_->DidFinishSubFrameNavigation(navigation_handle);
311 return; 315 return;
316 }
312 317
313 std::unique_ptr<PageLoadTracker> finished_nav( 318 std::unique_ptr<PageLoadTracker> finished_nav(
314 std::move(provisional_loads_[navigation_handle])); 319 std::move(provisional_loads_[navigation_handle]));
315 provisional_loads_.erase(navigation_handle); 320 provisional_loads_.erase(navigation_handle);
316 321
317 // Ignore same-document navigations. 322 // Ignore same-document navigations.
318 if (navigation_handle->HasCommitted() && 323 if (navigation_handle->HasCommitted() &&
319 navigation_handle->IsSameDocument()) { 324 navigation_handle->IsSameDocument()) {
320 if (finished_nav) 325 if (finished_nav)
321 finished_nav->StopTracking(); 326 finished_nav->StopTracking();
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 content::NavigationHandle* navigation_handle) const { 608 content::NavigationHandle* navigation_handle) const {
604 DCHECK(navigation_handle->IsInMainFrame()); 609 DCHECK(navigation_handle->IsInMainFrame());
605 DCHECK(!navigation_handle->HasCommitted() || 610 DCHECK(!navigation_handle->HasCommitted() ||
606 !navigation_handle->IsSameDocument()); 611 !navigation_handle->IsSameDocument());
607 612
608 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), 613 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(),
609 navigation_handle).ShouldTrack(); 614 navigation_handle).ShouldTrack();
610 } 615 }
611 616
612 } // namespace page_load_metrics 617 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698