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

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

Issue 2560043004: [PageLoadMetrics] Record bytes usage per page (Closed)
Patch Set: Include main frame resource Created 4 years 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 navigation_handle, 171 navigation_handle,
172 base::MakeUnique<PageLoadTracker>( 172 base::MakeUnique<PageLoadTracker>(
173 in_foreground_, embedder_interface_.get(), currently_committed_url, 173 in_foreground_, embedder_interface_.get(), currently_committed_url,
174 navigation_handle, user_initiated_info, chain_size, 174 navigation_handle, user_initiated_info, chain_size,
175 chain_size_same_url))); 175 chain_size_same_url)));
176 } 176 }
177 177
178 void MetricsWebContentsObserver::OnRequestComplete( 178 void MetricsWebContentsObserver::OnRequestComplete(
179 content::ResourceType resource_type, 179 content::ResourceType resource_type,
180 bool was_cached, 180 bool was_cached,
181 int net_error) { 181 int64_t raw_body_bytes,
182 // For simplicity, only count subresources. Navigations are hard to attribute 182 base::TimeTicks creation_time) {
183 // here because we won't have a committed load by the time data streams in 183 // If the navigation hasn't committed yet then we'll miss the resource (this
Bryan McQuade 2016/12/16 14:28:45 let's maybe add a comment here noting some of the
jkarlin 2016/12/19 19:26:01 Done.
184 // from the IO thread. 184 // happens on the new tab page). Also, if the resource request was started
185 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME && 185 // before this navigation then it should be ignored.
186 net_error != net::OK) { 186 if (!committed_load_ || creation_time < committed_load_->navigation_start()) {
187 return; 187 return;
188 } 188 }
189 if (!committed_load_) 189
190 return; 190 committed_load_->OnLoadedResource(was_cached, raw_body_bytes);
191 committed_load_->OnLoadedSubresource(was_cached);
192 } 191 }
193 192
194 const PageLoadExtraInfo 193 const PageLoadExtraInfo
195 MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() { 194 MetricsWebContentsObserver::GetPageLoadExtraInfoForCommittedLoad() {
196 DCHECK(committed_load_); 195 DCHECK(committed_load_);
197 return committed_load_->ComputePageLoadExtraInfo(); 196 return committed_load_->ComputePageLoadExtraInfo();
198 } 197 }
199 198
200 void MetricsWebContentsObserver::DidFinishNavigation( 199 void MetricsWebContentsObserver::DidFinishNavigation(
201 content::NavigationHandle* navigation_handle) { 200 content::NavigationHandle* navigation_handle) {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 content::NavigationHandle* navigation_handle) const { 472 content::NavigationHandle* navigation_handle) const {
474 DCHECK(navigation_handle->IsInMainFrame()); 473 DCHECK(navigation_handle->IsInMainFrame());
475 DCHECK(!navigation_handle->HasCommitted() || 474 DCHECK(!navigation_handle->HasCommitted() ||
476 !navigation_handle->IsSamePage()); 475 !navigation_handle->IsSamePage());
477 476
478 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(), 477 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(),
479 navigation_handle).ShouldTrack(); 478 navigation_handle).ShouldTrack();
480 } 479 }
481 480
482 } // namespace page_load_metrics 481 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698