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

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

Issue 1767243002: Update prerender policy for custom tabs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename with "cellular" and add explicit AddPrerender call Created 4 years, 9 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <functional> 10 #include <functional>
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 return NULL; 291 return NULL;
292 return AddPrerender(ORIGIN_OMNIBOX, url, content::Referrer(), size, 292 return AddPrerender(ORIGIN_OMNIBOX, url, content::Referrer(), size,
293 session_storage_namespace); 293 session_storage_namespace);
294 } 294 }
295 295
296 PrerenderHandle* PrerenderManager::AddPrerenderFromExternalRequest( 296 PrerenderHandle* PrerenderManager::AddPrerenderFromExternalRequest(
297 const GURL& url, 297 const GURL& url,
298 const content::Referrer& referrer, 298 const content::Referrer& referrer,
299 SessionStorageNamespace* session_storage_namespace, 299 SessionStorageNamespace* session_storage_namespace,
300 const gfx::Size& size) { 300 const gfx::Size& size) {
301 return AddPrerender(ORIGIN_EXTERNAL_REQUEST, url, referrer, size, 301 return AddPrerender(
302 ORIGIN_EXTERNAL_REQUEST, url, referrer, size, session_storage_namespace);
303 }
304
305 PrerenderHandle* PrerenderManager::AddPrerenderOnCellularFromExternalRequest(
306 const GURL& url,
307 const content::Referrer& referrer,
308 SessionStorageNamespace* session_storage_namespace,
309 const gfx::Size& size) {
310 return AddPrerender(ORIGIN_EXTERNAL_REQUEST_FORCED_CELLULAR,
311 url,
312 referrer,
313 size,
302 session_storage_namespace); 314 session_storage_namespace);
303 } 315 }
304 316
305 PrerenderHandle* PrerenderManager::AddPrerenderForInstant( 317 PrerenderHandle* PrerenderManager::AddPrerenderForInstant(
306 const GURL& url, 318 const GURL& url,
307 content::SessionStorageNamespace* session_storage_namespace, 319 content::SessionStorageNamespace* session_storage_namespace,
308 const gfx::Size& size) { 320 const gfx::Size& size) {
309 DCHECK(search::ShouldPrefetchSearchResults()); 321 DCHECK(search::ShouldPrefetchSearchResults());
310 return AddPrerender(ORIGIN_INSTANT, url, content::Referrer(), size, 322 return AddPrerender(ORIGIN_INSTANT, url, content::Referrer(), size,
311 session_storage_namespace); 323 session_storage_namespace);
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 939
928 GURL url = url_arg; 940 GURL url = url_arg;
929 GURL alias_url; 941 GURL alias_url;
930 if (IsControlGroup() && MaybeGetQueryStringBasedAliasURL(url, &alias_url)) 942 if (IsControlGroup() && MaybeGetQueryStringBasedAliasURL(url, &alias_url))
931 url = alias_url; 943 url = alias_url;
932 944
933 // From here on, we will record a FinalStatus so we need to register with the 945 // From here on, we will record a FinalStatus so we need to register with the
934 // histogram tracking. 946 // histogram tracking.
935 histograms_->RecordPrerender(origin, url_arg); 947 histograms_->RecordPrerender(origin, url_arg);
936 948
937 NetworkPredictionStatus prerendering_status = GetPredictionStatus(); 949 NetworkPredictionStatus prerendering_status =
950 GetPredictionStatusForOrigin(origin);
938 if (prerendering_status != NetworkPredictionStatus::ENABLED) { 951 if (prerendering_status != NetworkPredictionStatus::ENABLED) {
939 FinalStatus final_status = 952 FinalStatus final_status =
940 prerendering_status == NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK 953 prerendering_status == NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK
941 ? FINAL_STATUS_CELLULAR_NETWORK 954 ? FINAL_STATUS_CELLULAR_NETWORK
942 : FINAL_STATUS_PRERENDERING_DISABLED; 955 : FINAL_STATUS_PRERENDERING_DISABLED;
943 RecordFinalStatusWithoutCreatingPrerenderContents(url, origin, 956 RecordFinalStatusWithoutCreatingPrerenderContents(url, origin,
944 final_status); 957 final_status);
945 return nullptr; 958 return nullptr;
946 } 959 }
947 960
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 DCHECK_GE(recent_profile_bytes, 0); 1289 DCHECK_GE(recent_profile_bytes, 0);
1277 histograms_->RecordNetworkBytes( 1290 histograms_->RecordNetworkBytes(
1278 origin, used, prerender_bytes, recent_profile_bytes); 1291 origin, used, prerender_bytes, recent_profile_bytes);
1279 } 1292 }
1280 1293
1281 NetworkPredictionStatus PrerenderManager::GetPredictionStatus() const { 1294 NetworkPredictionStatus PrerenderManager::GetPredictionStatus() const {
1282 DCHECK(CalledOnValidThread()); 1295 DCHECK(CalledOnValidThread());
1283 return CanPrefetchAndPrerenderUI(profile_->GetPrefs()); 1296 return CanPrefetchAndPrerenderUI(profile_->GetPrefs());
1284 } 1297 }
1285 1298
1299 NetworkPredictionStatus PrerenderManager::GetPredictionStatusForOrigin(
1300 Origin origin) const {
1301 NetworkPredictionStatus prediction_status = GetPredictionStatus();
1302 if (prediction_status == NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK
1303 && origin == ORIGIN_EXTERNAL_REQUEST_FORCED_CELLULAR) {
1304 prediction_status = NetworkPredictionStatus::ENABLED;
1305 }
1306 return prediction_status;
1307 }
1308
1286 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64_t bytes) { 1309 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64_t bytes) {
1287 DCHECK_GE(bytes, 0); 1310 DCHECK_GE(bytes, 0);
1288 if (GetPredictionStatus() == NetworkPredictionStatus::ENABLED && 1311 if (GetPredictionStatus() == NetworkPredictionStatus::ENABLED &&
1289 ActuallyPrerendering()) 1312 ActuallyPrerendering())
1290 profile_network_bytes_ += bytes; 1313 profile_network_bytes_ += bytes;
1291 } 1314 }
1292 1315
1293 void PrerenderManager::AddPrerenderProcessHost( 1316 void PrerenderManager::AddPrerenderProcessHost(
1294 content::RenderProcessHost* process_host) { 1317 content::RenderProcessHost* process_host) {
1295 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1318 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 13 matching lines...) Expand all
1309 } 1332 }
1310 1333
1311 void PrerenderManager::RenderProcessHostDestroyed( 1334 void PrerenderManager::RenderProcessHostDestroyed(
1312 content::RenderProcessHost* host) { 1335 content::RenderProcessHost* host) {
1313 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1336 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1314 size_t erased = prerender_process_hosts_.erase(host); 1337 size_t erased = prerender_process_hosts_.erase(host);
1315 DCHECK_EQ(1u, erased); 1338 DCHECK_EQ(1u, erased);
1316 } 1339 }
1317 1340
1318 } // namespace prerender 1341 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698