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

Unified Diff: chrome/browser/predictors/resource_prefetch_predictor.cc

Issue 2923813002: predictors: Don't call IsUrlPrefetchable twice. (Closed)
Patch Set: . Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/predictors/resource_prefetch_predictor.cc
diff --git a/chrome/browser/predictors/resource_prefetch_predictor.cc b/chrome/browser/predictors/resource_prefetch_predictor.cc
index 01375a75003647d630fad917ee84ebd7199fb7f5..13887e0f25cee5fe4697634d19d80f50e48490ad 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor.cc
+++ b/chrome/browser/predictors/resource_prefetch_predictor.cc
@@ -585,9 +585,6 @@ void ResourcePrefetchPredictor::OnPrefetchingFinished(
bool ResourcePrefetchPredictor::IsUrlPrefetchable(
const GURL& main_frame_url) const {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
alexilin 2017/06/06 16:43:32 nit: Could you move a thread checking to GetPrefet
Benoit L 2017/06/07 08:50:27 Done.
- if (initialization_state_ != INITIALIZED)
- return false;
-
return GetPrefetchData(main_frame_url, nullptr);
}
@@ -743,6 +740,9 @@ void ResourcePrefetchPredictor::OnNavigationComplete(
bool ResourcePrefetchPredictor::GetPrefetchData(
const GURL& main_frame_url,
ResourcePrefetchPredictor::Prediction* prediction) const {
alexilin 2017/06/06 16:43:32 Thanks for fixing this! I forgot to add the check
+ if (initialization_state_ != INITIALIZED)
+ return false;
+
std::vector<GURL>* urls =
prediction ? &prediction->subresource_urls : nullptr;
DCHECK(!urls || urls->empty());
@@ -1397,16 +1397,14 @@ void ResourcePrefetchPredictor::ConnectToHistoryService() {
}
}
-void ResourcePrefetchPredictor::StartPrefetching(const GURL& url) {
+void ResourcePrefetchPredictor::StartPrefetching(
+ const GURL& url,
+ const ResourcePrefetchPredictor::Prediction& prediction) {
TRACE_EVENT1("browser", "ResourcePrefetchPredictor::StartPrefetching", "url",
url.spec());
if (!prefetch_manager_.get()) // Not enabled.
return;
- ResourcePrefetchPredictor::Prediction prediction;
- bool has_data = GetPrefetchData(url, &prediction);
- DCHECK(has_data);
-
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&ResourcePrefetcherManager::MaybeAddPrefetch,

Powered by Google App Engine
This is Rietveld 408576698