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

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: Fixing comment. 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
mmenke 2012/08/01 15:39:53 Completely unrelated, but while you're here, mind
Shishir 2012/08/01 18:07:49 Done.
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 const URLRequestSummary& response) { 347 const URLRequestSummary& response) {
347 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 348 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
348 349
349 // TODO(shishir): The prefreshing will be stopped here. 350 // TODO(shishir): The prefreshing will be stopped here.
350 } 351 }
351 352
352 void ResourcePrefetchPredictor::OnMainFrameRedirect( 353 void ResourcePrefetchPredictor::OnMainFrameRedirect(
353 const URLRequestSummary& response) { 354 const URLRequestSummary& response) {
354 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 355 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
355 356
357 // Remove the older navigation.
356 inflight_navigations_.erase(response.navigation_id); 358 inflight_navigations_.erase(response.navigation_id);
359
360 // We do not see another navigation start for a redirect, so record the
361 // redirect url as a new navigation.
mmenke 2012/08/01 10:25:37 This comment is phrased/placed really oddly, since
Shishir 2012/08/01 18:07:49 Done.
362 if (response.redirect_url.is_empty())
mmenke 2012/08/01 10:25:37 When does this happen? Think a comment would be r
Shishir 2012/08/01 18:07:49 Done.
363 return;
364
365 NavigationID navigation_id(response.navigation_id);
366 navigation_id.main_frame_url = response.redirect_url;
367 inflight_navigations_.insert(std::make_pair(
368 navigation_id, std::vector<URLRequestSummary>()));
357 } 369 }
358 370
359 void ResourcePrefetchPredictor::OnSubresourceResponse( 371 void ResourcePrefetchPredictor::OnSubresourceResponse(
360 const URLRequestSummary& response) { 372 const URLRequestSummary& response) {
361 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 373 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
362 374
363 if (inflight_navigations_.find(response.navigation_id) == 375 if (inflight_navigations_.find(response.navigation_id) ==
364 inflight_navigations_.end()) { 376 inflight_navigations_.end()) {
365 return; 377 return;
366 } 378 }
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 tables_, 774 tables_,
763 urls_to_delete)); 775 urls_to_delete));
764 } 776 }
765 777
766 void ResourcePrefetchPredictor::SetTablesForTesting( 778 void ResourcePrefetchPredictor::SetTablesForTesting(
767 scoped_refptr<ResourcePrefetchPredictorTables> tables) { 779 scoped_refptr<ResourcePrefetchPredictorTables> tables) {
768 tables_ = tables; 780 tables_ = tables;
769 } 781 }
770 782
771 } // namespace predictors 783 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698