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

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

Issue 10978016: Remove two functions on WebContentsDelegate which didn't belong in content. They were only called f… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: nits and fixed prerender browser tests Created 8 years, 2 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
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 <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 // static 593 // static
594 bool PrerenderManager::IsControlGroup() { 594 bool PrerenderManager::IsControlGroup() {
595 return GetMode() == PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP; 595 return GetMode() == PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP;
596 } 596 }
597 597
598 // static 598 // static
599 bool PrerenderManager::IsNoUseGroup() { 599 bool PrerenderManager::IsNoUseGroup() {
600 return GetMode() == PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP; 600 return GetMode() == PRERENDER_MODE_EXPERIMENT_NO_USE_GROUP;
601 } 601 }
602 602
603 // static
604 bool PrerenderManager::IsWebContentsPrerendering( 603 bool PrerenderManager::IsWebContentsPrerendering(
605 WebContents* web_contents) const { 604 WebContents* web_contents) const {
606 DCHECK(CalledOnValidThread()); 605 DCHECK(CalledOnValidThread());
607 for (std::list<linked_ptr<PrerenderData> >::const_iterator it = 606 if (GetPrerenderContents(web_contents))
608 active_prerender_list_.begin(); 607 return true;
609 it != active_prerender_list_.end();
610 ++it) {
611 TabContents* prerender_tab_contents =
612 it->get()->contents_->prerender_contents();
613 if (prerender_tab_contents &&
614 prerender_tab_contents->web_contents() == web_contents) {
615 return true;
616 }
617 }
618 608
619 // Also look through the pending-deletion list. 609 // Also look through the pending-deletion list.
620 for (std::list<PrerenderContents*>::const_iterator it = 610 for (std::list<PrerenderContents*>::const_iterator it =
621 pending_delete_list_.begin(); 611 pending_delete_list_.begin();
622 it != pending_delete_list_.end(); 612 it != pending_delete_list_.end();
623 ++it) { 613 ++it) {
624 TabContents* prerender_tab_contents = (*it)->prerender_contents(); 614 TabContents* prerender_tab_contents = (*it)->prerender_contents();
625 if (prerender_tab_contents && 615 if (prerender_tab_contents &&
626 prerender_tab_contents->web_contents() == web_contents) 616 prerender_tab_contents->web_contents() == web_contents)
627 return true; 617 return true;
628 } 618 }
629 619
630 return false; 620 return false;
631 } 621 }
632 622
623 PrerenderContents* PrerenderManager::GetPrerenderContents(
624 content::WebContents* web_contents) const {
625 DCHECK(CalledOnValidThread());
626 for (std::list<linked_ptr<PrerenderData> >::const_iterator it =
627 active_prerender_list_.begin();
628 it != active_prerender_list_.end();
629 ++it) {
630 TabContents* prerender_tab_contents =
631 it->get()->contents_->prerender_contents();
632 if (prerender_tab_contents &&
633 prerender_tab_contents->web_contents() == web_contents) {
634 return it->get()->contents_;
635 }
636 }
637 return NULL;
638 }
639
633 void PrerenderManager::MarkWebContentsAsPrerendered(WebContents* web_contents) { 640 void PrerenderManager::MarkWebContentsAsPrerendered(WebContents* web_contents) {
634 DCHECK(CalledOnValidThread()); 641 DCHECK(CalledOnValidThread());
635 prerendered_tab_contents_set_.insert(web_contents); 642 prerendered_tab_contents_set_.insert(web_contents);
636 } 643 }
637 644
638 void PrerenderManager::MarkWebContentsAsWouldBePrerendered( 645 void PrerenderManager::MarkWebContentsAsWouldBePrerendered(
639 WebContents* web_contents) { 646 WebContents* web_contents) {
640 DCHECK(CalledOnValidThread()); 647 DCHECK(CalledOnValidThread());
641 would_be_prerendered_map_[web_contents] = true; 648 would_be_prerendered_map_[web_contents] = true;
642 } 649 }
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 if (!render_process_host || !render_process_host->GetBrowserContext()) 1297 if (!render_process_host || !render_process_host->GetBrowserContext())
1291 return NULL; 1298 return NULL;
1292 Profile* profile = Profile::FromBrowserContext( 1299 Profile* profile = Profile::FromBrowserContext(
1293 render_process_host->GetBrowserContext()); 1300 render_process_host->GetBrowserContext());
1294 if (!profile) 1301 if (!profile)
1295 return NULL; 1302 return NULL;
1296 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); 1303 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile);
1297 } 1304 }
1298 1305
1299 } // namespace prerender 1306 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698