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

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

Powered by Google App Engine
This is Rietveld 408576698