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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor.cc

Issue 10827103: Speculative resource prefetching - fixing missing navigations due to server side redirects. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Passing redirect_url as an argument to ResourceDispatcherHostDelegate::OnRequestRedirected. Created 8 years, 4 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/predictors/resource_prefetch_predictor.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 num_resources_assumed_prefetched(25) { 77 num_resources_assumed_prefetched(25) {
78 } 78 }
79 79
80 ResourcePrefetchPredictor::URLRequestSummary::URLRequestSummary() 80 ResourcePrefetchPredictor::URLRequestSummary::URLRequestSummary()
81 : resource_type(ResourceType::LAST_TYPE), 81 : resource_type(ResourceType::LAST_TYPE),
82 was_cached(false) { 82 was_cached(false) {
83 } 83 }
84 84
85 ResourcePrefetchPredictor::URLRequestSummary::URLRequestSummary( 85 ResourcePrefetchPredictor::URLRequestSummary::URLRequestSummary(
86 const URLRequestSummary& other) 86 const URLRequestSummary& other)
87 : navigation_id(other.navigation_id), 87 : navigation_id(other.navigation_id),
88 resource_url(other.resource_url), 88 resource_url(other.resource_url),
89 resource_type(other.resource_type), 89 resource_type(other.resource_type),
90 mime_type(other.mime_type), 90 mime_type(other.mime_type),
91 was_cached(other.was_cached) { 91 was_cached(other.was_cached),
92 redirect_url(other.redirect_url) {
92 } 93 }
93 94
94 ResourcePrefetchPredictor::URLRequestSummary::~URLRequestSummary() { 95 ResourcePrefetchPredictor::URLRequestSummary::~URLRequestSummary() {
95 } 96 }
96 97
97 ResourcePrefetchPredictor::UrlTableCacheValue::UrlTableCacheValue() { 98 ResourcePrefetchPredictor::UrlTableCacheValue::UrlTableCacheValue() {
98 } 99 }
99 100
100 ResourcePrefetchPredictor::UrlTableCacheValue::~UrlTableCacheValue() { 101 ResourcePrefetchPredictor::UrlTableCacheValue::~UrlTableCacheValue() {
101 } 102 }
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 const URLRequestSummary& response) { 339 const URLRequestSummary& response) {
339 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 340 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
340 341
341 // TODO(shishir): The prefreshing will be stopped here. 342 // TODO(shishir): The prefreshing will be stopped here.
342 } 343 }
343 344
344 void ResourcePrefetchPredictor::OnMainFrameRedirect( 345 void ResourcePrefetchPredictor::OnMainFrameRedirect(
345 const URLRequestSummary& response) { 346 const URLRequestSummary& response) {
346 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 347 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
347 348
349 // Remove the older navigation.
348 inflight_navigations_.erase(response.navigation_id); 350 inflight_navigations_.erase(response.navigation_id);
351
352 // We do not see another navigation start for a redirect, so record the
James Hawkins 2012/08/02 18:17:50 nit: Don't use pronouns in comments (we); pronouns
Shishir 2012/08/02 18:25:43 Done.
353 // redirect url as a new navigation.
354
355 // The redirect url may be empty if the url was invalid.
356 if (response.redirect_url.is_empty())
357 return;
358
359 NavigationID navigation_id(response.navigation_id);
360 navigation_id.main_frame_url = response.redirect_url;
361 inflight_navigations_.insert(std::make_pair(
362 navigation_id, std::vector<URLRequestSummary>()));
349 } 363 }
350 364
351 void ResourcePrefetchPredictor::OnSubresourceResponse( 365 void ResourcePrefetchPredictor::OnSubresourceResponse(
352 const URLRequestSummary& response) { 366 const URLRequestSummary& response) {
353 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 367 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
354 368
355 if (inflight_navigations_.find(response.navigation_id) == 369 if (inflight_navigations_.find(response.navigation_id) ==
356 inflight_navigations_.end()) { 370 inflight_navigations_.end()) {
357 return; 371 return;
358 } 372 }
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 tables_, 771 tables_,
758 urls_to_delete)); 772 urls_to_delete));
759 } 773 }
760 774
761 void ResourcePrefetchPredictor::SetTablesForTesting( 775 void ResourcePrefetchPredictor::SetTablesForTesting(
762 scoped_refptr<ResourcePrefetchPredictorTables> tables) { 776 scoped_refptr<ResourcePrefetchPredictorTables> tables) {
763 tables_ = tables; 777 tables_ = tables;
764 } 778 }
765 779
766 } // namespace predictors 780 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698