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

Side by Side Diff: chrome/browser/prerender/prerender_manager.cc

Issue 160513002: Reports Prerender and Profile Total Bytes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/prerender/prerender_manager.h" 5 #include "chrome/browser/prerender/prerender_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 PrerenderManager::PrerenderManager(Profile* profile, 234 PrerenderManager::PrerenderManager(Profile* profile,
235 PrerenderTracker* prerender_tracker) 235 PrerenderTracker* prerender_tracker)
236 : enabled_(profile && profile->GetPrefs() && 236 : enabled_(profile && profile->GetPrefs() &&
237 profile->GetPrefs()->GetBoolean(prefs::kNetworkPredictionEnabled)), 237 profile->GetPrefs()->GetBoolean(prefs::kNetworkPredictionEnabled)),
238 profile_(profile), 238 profile_(profile),
239 prerender_tracker_(prerender_tracker), 239 prerender_tracker_(prerender_tracker),
240 prerender_contents_factory_(PrerenderContents::CreateFactory()), 240 prerender_contents_factory_(PrerenderContents::CreateFactory()),
241 last_prerender_start_time_(GetCurrentTimeTicks() - 241 last_prerender_start_time_(GetCurrentTimeTicks() -
242 base::TimeDelta::FromMilliseconds(kMinTimeBetweenPrerendersMs)), 242 base::TimeDelta::FromMilliseconds(kMinTimeBetweenPrerendersMs)),
243 prerender_history_(new PrerenderHistory(kHistoryLength)), 243 prerender_history_(new PrerenderHistory(kHistoryLength)),
244 histograms_(new PrerenderHistograms()) { 244 histograms_(new PrerenderHistograms()),
245 profile_network_bytes_(0) {
245 // There are some assumptions that the PrerenderManager is on the UI thread. 246 // There are some assumptions that the PrerenderManager is on the UI thread.
246 // Any other checks simply make sure that the PrerenderManager is accessed on 247 // Any other checks simply make sure that the PrerenderManager is accessed on
247 // the same thread that it was created on. 248 // the same thread that it was created on.
248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
249 250
250 if (IsLocalPredictorEnabled()) 251 if (IsLocalPredictorEnabled())
251 local_predictor_.reset(new PrerenderLocalPredictor(this)); 252 local_predictor_.reset(new PrerenderLocalPredictor(this));
252 253
253 if (IsLoggedInPredictorEnabled() && !profile_->IsOffTheRecord()) { 254 if (IsLoggedInPredictorEnabled() && !profile_->IsOffTheRecord()) {
254 predictors::PredictorDatabase* predictor_db = 255 predictors::PredictorDatabase* predictor_db =
(...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 const history::URLRow* url_row, 1761 const history::URLRow* url_row,
1761 history::VisitVector* visists) { 1762 history::VisitVector* visists) {
1762 histograms_->RecordPrerenderPageVisitedStatus(origin, experiment_id, success); 1763 histograms_->RecordPrerenderPageVisitedStatus(origin, experiment_id, success);
1763 } 1764 }
1764 1765
1765 // static 1766 // static
1766 void PrerenderManager::HangSessionStorageMergesForTesting() { 1767 void PrerenderManager::HangSessionStorageMergesForTesting() {
1767 g_hang_session_storage_merges_for_testing = true; 1768 g_hang_session_storage_merges_for_testing = true;
1768 } 1769 }
1769 1770
1771 void PrerenderManager::RecordBytes(bool used, int64 prerender_bytes) {
1772 if (ActuallyPrerendering())
1773 histograms_->RecordBytes(used, prerender_bytes, profile_network_bytes_);
1774 }
1775
1776 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64 bytes) {
1777 if (IsEnabled() && ActuallyPrerendering())
1778 profile_network_bytes_ += bytes;
1779 }
1780
1770 } // namespace prerender 1781 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698