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

Side by Side Diff: chrome/browser/net/resource_prefetch_predictor_observer.cc

Issue 2587443002: predictors: Make speculative_prefetch_predictor work with PlzNavigate (Closed)
Patch Set: Modified after clamy@ review Created 3 years, 12 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
« no previous file with comments | « no previous file | chrome/browser/predictors/resource_prefetch_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/net/resource_prefetch_predictor_observer.h" 5 #include "chrome/browser/net/resource_prefetch_predictor_observer.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 predictors::NavigationID* navigation_id, 63 predictors::NavigationID* navigation_id,
64 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, 64 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
65 const GURL& main_frame_url, 65 const GURL& main_frame_url,
66 const base::TimeTicks& creation_time) { 66 const base::TimeTicks& creation_time) {
67 DCHECK_CURRENTLY_ON(BrowserThread::UI); 67 DCHECK_CURRENTLY_ON(BrowserThread::UI);
68 content::WebContents* web_contents = web_contents_getter.Run(); 68 content::WebContents* web_contents = web_contents_getter.Run();
69 if (!web_contents) 69 if (!web_contents)
70 return false; 70 return false;
71 *navigation_id = 71 *navigation_id =
72 predictors::NavigationID(web_contents, main_frame_url, creation_time); 72 predictors::NavigationID(web_contents, main_frame_url, creation_time);
73 return true; 73 // A WebContents might be associated with something that is not a tab.
74 // In this case tab_id will be -1 and is_valid() will return false.
75 return navigation_id->is_valid();
74 } 76 }
75 77
76 } // namespace 78 } // namespace
77 79
78 namespace chrome_browser_net { 80 namespace chrome_browser_net {
79 81
80 ResourcePrefetchPredictorObserver::ResourcePrefetchPredictorObserver( 82 ResourcePrefetchPredictorObserver::ResourcePrefetchPredictorObserver(
81 ResourcePrefetchPredictor* predictor) 83 ResourcePrefetchPredictor* predictor)
82 : predictor_(predictor->AsWeakPtr()) { 84 : predictor_(predictor->AsWeakPtr()) {
83 DCHECK_CURRENTLY_ON(BrowserThread::UI); 85 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 const base::TimeTicks& creation_time) const { 227 const base::TimeTicks& creation_time) const {
226 DCHECK_CURRENTLY_ON(BrowserThread::UI); 228 DCHECK_CURRENTLY_ON(BrowserThread::UI);
227 if (!TryToFillNavigationID(&summary->navigation_id, web_contents_getter, 229 if (!TryToFillNavigationID(&summary->navigation_id, web_contents_getter,
228 main_frame_url, creation_time)) { 230 main_frame_url, creation_time)) {
229 return; 231 return;
230 } 232 }
231 predictor_->RecordURLResponse(*summary); 233 predictor_->RecordURLResponse(*summary);
232 } 234 }
233 235
234 } // namespace chrome_browser_net 236 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/predictors/resource_prefetch_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698