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

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: Updates and address Ojan's comments Created 3 years, 8 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // correctly (for example Link: preloads). 238 // correctly (for example Link: preloads).
239 if (committed_load_ && 239 if (committed_load_ &&
240 creation_time >= committed_load_->navigation_start()) { 240 creation_time >= committed_load_->navigation_start()) {
241 return committed_load_.get(); 241 return committed_load_.get();
242 } 242 }
243 } 243 }
244 return nullptr; 244 return nullptr;
245 } 245 }
246 246
247 void MetricsWebContentsObserver::OnRequestComplete( 247 void MetricsWebContentsObserver::OnRequestComplete(
248 const GURL& url,
249 int frame_tree_node_id,
248 const content::GlobalRequestID& request_id, 250 const content::GlobalRequestID& request_id,
249 content::ResourceType resource_type, 251 content::ResourceType resource_type,
250 bool was_cached, 252 bool was_cached,
251 bool used_data_reduction_proxy, 253 bool used_data_reduction_proxy,
252 int64_t raw_body_bytes, 254 int64_t raw_body_bytes,
253 int64_t original_content_length, 255 int64_t original_content_length,
254 base::TimeTicks creation_time) { 256 base::TimeTicks creation_time) {
255 PageLoadTracker* tracker = 257 PageLoadTracker* tracker =
256 GetTrackerOrNullForRequest(request_id, resource_type, creation_time); 258 GetTrackerOrNullForRequest(request_id, resource_type, creation_time);
257 if (tracker) { 259 if (tracker) {
258 ExtraRequestInfo extra_request_info( 260 ExtraRequestInfo extra_request_info(
259 was_cached, raw_body_bytes, used_data_reduction_proxy, 261 url, frame_tree_node_id, was_cached, raw_body_bytes,
260 was_cached ? 0 : original_content_length); 262 used_data_reduction_proxy, was_cached ? 0 : original_content_length);
261 tracker->OnLoadedResource(extra_request_info); 263 tracker->OnLoadedResource(extra_request_info);
262 } 264 }
263 } 265 }
264 266
265 const PageLoadExtraInfo 267 const PageLoadExtraInfo
266 MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() { 268 MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() {
267 DCHECK(committed_load_); 269 DCHECK(committed_load_);
268 return committed_load_->ComputePageLoadExtraInfo(); 270 return committed_load_->ComputePageLoadExtraInfo();
269 } 271 }
270 272
271 void MetricsWebContentsObserver::DidFinishNavigation( 273 void MetricsWebContentsObserver::DidFinishNavigation(
272 content::NavigationHandle* navigation_handle) { 274 content::NavigationHandle* navigation_handle) {
273 if (!navigation_handle->IsInMainFrame()) 275 if (!navigation_handle->IsInMainFrame()) {
276 if (committed_load_)
277 committed_load_->CommitSubFrame(navigation_handle);
Charlie Harrison 2017/04/10 18:39:41 DidCommitSubFrame? CommitSubFrame sounds like a di
jkarlin 2017/04/11 16:46:27 Done.
274 return; 278 return;
279 }
275 280
276 std::unique_ptr<PageLoadTracker> finished_nav( 281 std::unique_ptr<PageLoadTracker> finished_nav(
277 std::move(provisional_loads_[navigation_handle])); 282 std::move(provisional_loads_[navigation_handle]));
278 provisional_loads_.erase(navigation_handle); 283 provisional_loads_.erase(navigation_handle);
279 284
280 // Ignore same-document navigations. 285 // Ignore same-document navigations.
281 if (navigation_handle->HasCommitted() && 286 if (navigation_handle->HasCommitted() &&
282 navigation_handle->IsSameDocument()) { 287 navigation_handle->IsSameDocument()) {
283 if (finished_nav) 288 if (finished_nav)
284 finished_nav->StopTracking(); 289 finished_nav->StopTracking();
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 content::NavigationHandle* navigation_handle) const { 578 content::NavigationHandle* navigation_handle) const {
574 DCHECK(navigation_handle->IsInMainFrame()); 579 DCHECK(navigation_handle->IsInMainFrame());
575 DCHECK(!navigation_handle->HasCommitted() || 580 DCHECK(!navigation_handle->HasCommitted() ||
576 !navigation_handle->IsSameDocument()); 581 !navigation_handle->IsSameDocument());
577 582
578 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), 583 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(),
579 navigation_handle).ShouldTrack(); 584 navigation_handle).ShouldTrack();
580 } 585 }
581 586
582 } // namespace page_load_metrics 587 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698