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

Side by Side Diff: chrome/browser/prerender/prerender_manager.cc

Issue 10377058: Remove IsPendingDelete from PrerenderManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remediate to review Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prerender/prerender_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 // list, instead of deleting directly here? 514 // list, instead of deleting directly here?
515 AddToHistory(prerender_contents.get()); 515 AddToHistory(prerender_contents.get());
516 RecordNavigation(url); 516 RecordNavigation(url);
517 return true; 517 return true;
518 } 518 }
519 519
520 void PrerenderManager::MoveEntryToPendingDelete(PrerenderContents* entry, 520 void PrerenderManager::MoveEntryToPendingDelete(PrerenderContents* entry,
521 FinalStatus final_status) { 521 FinalStatus final_status) {
522 DCHECK(CalledOnValidThread()); 522 DCHECK(CalledOnValidThread());
523 DCHECK(entry); 523 DCHECK(entry);
524 DCHECK(!IsPendingDelete(entry)); 524 // Confirm this entry has not already been moved to the pending delete list.
525 DCHECK_EQ(0, std::count(pending_delete_list_.begin(),
526 pending_delete_list_.end(), entry));
525 527
526 for (PrerenderContentsDataList::iterator it = prerender_list_.begin(); 528 for (PrerenderContentsDataList::iterator it = prerender_list_.begin();
527 it != prerender_list_.end(); 529 it != prerender_list_.end();
528 ++it) { 530 ++it) {
529 if (it->contents_ == entry) { 531 if (it->contents_ == entry) {
530 bool swapped_in_dummy_replacement = false; 532 bool swapped_in_dummy_replacement = false;
531 533
532 // If this PrerenderContents is being deleted due to a cancellation, 534 // If this PrerenderContents is being deleted due to a cancellation,
533 // we need to create a dummy replacement for PPLT accounting purposes 535 // we need to create a dummy replacement for PPLT accounting purposes
534 // for the Match Complete group. 536 // for the Match Complete group.
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 const GURL& url, 1061 const GURL& url,
1060 const content::Referrer& referrer, 1062 const content::Referrer& referrer,
1061 Origin origin, 1063 Origin origin,
1062 uint8 experiment_id) { 1064 uint8 experiment_id) {
1063 DCHECK(CalledOnValidThread()); 1065 DCHECK(CalledOnValidThread());
1064 return prerender_contents_factory_->CreatePrerenderContents( 1066 return prerender_contents_factory_->CreatePrerenderContents(
1065 this, prerender_tracker_, profile_, url, 1067 this, prerender_tracker_, profile_, url,
1066 referrer, origin, experiment_id); 1068 referrer, origin, experiment_id);
1067 } 1069 }
1068 1070
1069 bool PrerenderManager::IsPendingDelete(PrerenderContents* entry) const {
1070 DCHECK(CalledOnValidThread());
1071 for (std::list<PrerenderContents*>::const_iterator it =
1072 pending_delete_list_.begin();
1073 it != pending_delete_list_.end();
1074 ++it) {
1075 if (*it == entry)
1076 return true;
1077 }
1078
1079 return false;
1080 }
1081
1082 void PrerenderManager::DeletePendingDeleteEntries() { 1071 void PrerenderManager::DeletePendingDeleteEntries() {
1083 while (!pending_delete_list_.empty()) { 1072 while (!pending_delete_list_.empty()) {
1084 PrerenderContents* contents = pending_delete_list_.front(); 1073 PrerenderContents* contents = pending_delete_list_.front();
1085 pending_delete_list_.pop_front(); 1074 pending_delete_list_.pop_front();
1086 delete contents; 1075 delete contents;
1087 } 1076 }
1088 } 1077 }
1089 1078
1090 PrerenderManager::PrerenderContentsData* PrerenderManager::FindEntryData( 1079 PrerenderManager::PrerenderContentsData* PrerenderManager::FindEntryData(
1091 const GURL& url) { 1080 const GURL& url) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 if (!render_process_host || !render_process_host->GetBrowserContext()) 1257 if (!render_process_host || !render_process_host->GetBrowserContext())
1269 return NULL; 1258 return NULL;
1270 Profile* profile = Profile::FromBrowserContext( 1259 Profile* profile = Profile::FromBrowserContext(
1271 render_process_host->GetBrowserContext()); 1260 render_process_host->GetBrowserContext());
1272 if (!profile) 1261 if (!profile)
1273 return NULL; 1262 return NULL;
1274 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); 1263 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile);
1275 } 1264 }
1276 1265
1277 } // namespace prerender 1266 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698