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

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: fix indentation 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (!IsOmniboxEnabled(profile_)) 290 if (!IsOmniboxEnabled(profile_))
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 bool prerender_on_mobile) {
302 Origin origin = prerender_on_mobile ? ORIGIN_EXTERNAL_REQUEST_MOBILE
303 : ORIGIN_EXTERNAL_REQUEST;
304 return AddPrerender(origin, url, referrer, size,
gone 2016/03/09 23:02:14 nit: does this fit on one line now?
Yusuf 2016/03/09 23:22:49 Done.
302 session_storage_namespace); 305 session_storage_namespace);
303 } 306 }
304 307
305 PrerenderHandle* PrerenderManager::AddPrerenderForInstant( 308 PrerenderHandle* PrerenderManager::AddPrerenderForInstant(
306 const GURL& url, 309 const GURL& url,
307 content::SessionStorageNamespace* session_storage_namespace, 310 content::SessionStorageNamespace* session_storage_namespace,
308 const gfx::Size& size) { 311 const gfx::Size& size) {
309 DCHECK(search::ShouldPrefetchSearchResults()); 312 DCHECK(search::ShouldPrefetchSearchResults());
310 return AddPrerender(ORIGIN_INSTANT, url, content::Referrer(), size, 313 return AddPrerender(ORIGIN_INSTANT, url, content::Referrer(), size,
311 session_storage_namespace); 314 session_storage_namespace);
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 930
928 GURL url = url_arg; 931 GURL url = url_arg;
929 GURL alias_url; 932 GURL alias_url;
930 if (IsControlGroup() && MaybeGetQueryStringBasedAliasURL(url, &alias_url)) 933 if (IsControlGroup() && MaybeGetQueryStringBasedAliasURL(url, &alias_url))
931 url = alias_url; 934 url = alias_url;
932 935
933 // From here on, we will record a FinalStatus so we need to register with the 936 // From here on, we will record a FinalStatus so we need to register with the
934 // histogram tracking. 937 // histogram tracking.
935 histograms_->RecordPrerender(origin, url_arg); 938 histograms_->RecordPrerender(origin, url_arg);
936 939
937 NetworkPredictionStatus prerendering_status = GetPredictionStatus(); 940 NetworkPredictionStatus prerendering_status =
941 GetPredictionStatusForOrigin(origin);
gone 2016/03/09 23:02:14 nit: should still fit on one line?
Yusuf 2016/03/09 23:22:49 Nope.
938 if (prerendering_status != NetworkPredictionStatus::ENABLED) { 942 if (prerendering_status != NetworkPredictionStatus::ENABLED) {
939 FinalStatus final_status = 943 FinalStatus final_status =
940 prerendering_status == NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK 944 prerendering_status == NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK
941 ? FINAL_STATUS_CELLULAR_NETWORK 945 ? FINAL_STATUS_CELLULAR_NETWORK
942 : FINAL_STATUS_PRERENDERING_DISABLED; 946 : FINAL_STATUS_PRERENDERING_DISABLED;
943 RecordFinalStatusWithoutCreatingPrerenderContents(url, origin, 947 RecordFinalStatusWithoutCreatingPrerenderContents(url, origin,
944 final_status); 948 final_status);
945 return nullptr; 949 return nullptr;
946 } 950 }
947 951
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 DCHECK_GE(recent_profile_bytes, 0); 1282 DCHECK_GE(recent_profile_bytes, 0);
1279 histograms_->RecordNetworkBytes( 1283 histograms_->RecordNetworkBytes(
1280 origin, used, prerender_bytes, recent_profile_bytes); 1284 origin, used, prerender_bytes, recent_profile_bytes);
1281 } 1285 }
1282 1286
1283 NetworkPredictionStatus PrerenderManager::GetPredictionStatus() const { 1287 NetworkPredictionStatus PrerenderManager::GetPredictionStatus() const {
1284 DCHECK(CalledOnValidThread()); 1288 DCHECK(CalledOnValidThread());
1285 return CanPrefetchAndPrerenderUI(profile_->GetPrefs()); 1289 return CanPrefetchAndPrerenderUI(profile_->GetPrefs());
1286 } 1290 }
1287 1291
1292 NetworkPredictionStatus PrerenderManager::GetPredictionStatusForOrigin(
1293 Origin origin) const {
1294 NetworkPredictionStatus prerender_status = GetPredictionStatus();
1295 if (prerender_status == NetworkPredictionStatus::DISABLED_DUE_TO_NETWORK
1296 && origin == ORIGIN_EXTERNAL_REQUEST_MOBILE) {
1297 prerender_status = NetworkPredictionStatus::ENABLED;
1298 }
1299 return prerender_status;
1300 }
1301
1288 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64_t bytes) { 1302 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64_t bytes) {
1289 DCHECK_GE(bytes, 0); 1303 DCHECK_GE(bytes, 0);
1290 if (GetPredictionStatus() == NetworkPredictionStatus::ENABLED && 1304 if (GetPredictionStatus() == NetworkPredictionStatus::ENABLED &&
1291 ActuallyPrerendering()) 1305 ActuallyPrerendering())
1292 profile_network_bytes_ += bytes; 1306 profile_network_bytes_ += bytes;
1293 } 1307 }
1294 1308
1295 void PrerenderManager::AddPrerenderProcessHost( 1309 void PrerenderManager::AddPrerenderProcessHost(
1296 content::RenderProcessHost* process_host) { 1310 content::RenderProcessHost* process_host) {
1297 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1311 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 13 matching lines...) Expand all
1311 } 1325 }
1312 1326
1313 void PrerenderManager::RenderProcessHostDestroyed( 1327 void PrerenderManager::RenderProcessHostDestroyed(
1314 content::RenderProcessHost* host) { 1328 content::RenderProcessHost* host) {
1315 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1329 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1316 size_t erased = prerender_process_hosts_.erase(host); 1330 size_t erased = prerender_process_hosts_.erase(host);
1317 DCHECK_EQ(1u, erased); 1331 DCHECK_EQ(1u, erased);
1318 } 1332 }
1319 1333
1320 } // namespace prerender 1334 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698