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

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

Issue 45693002: Add ExternalPrerenderRequestHandler and related API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit fixes and fixing the test Created 7 years, 1 month 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 } 385 }
386 386
387 PrerenderHandle* PrerenderManager::AddPrerenderFromLocalPredictor( 387 PrerenderHandle* PrerenderManager::AddPrerenderFromLocalPredictor(
388 const GURL& url, 388 const GURL& url,
389 SessionStorageNamespace* session_storage_namespace, 389 SessionStorageNamespace* session_storage_namespace,
390 const gfx::Size& size) { 390 const gfx::Size& size) {
391 return AddPrerender(ORIGIN_LOCAL_PREDICTOR, -1, url, content::Referrer(), 391 return AddPrerender(ORIGIN_LOCAL_PREDICTOR, -1, url, content::Referrer(),
392 size, session_storage_namespace); 392 size, session_storage_namespace);
393 } 393 }
394 394
395 PrerenderHandle* PrerenderManager::AddPrerenderFromExternalRequest(
396 const GURL& url,
397 const content::Referrer& referrer,
398 SessionStorageNamespace* session_storage_namespace,
399 const gfx::Size& size) {
400 return AddPrerender(ORIGIN_EXTERNAL_REQUEST, -1, url, referrer, size,
401 session_storage_namespace);
402 }
403
395 void PrerenderManager::DestroyPrerenderForRenderView( 404 void PrerenderManager::DestroyPrerenderForRenderView(
396 int process_id, int view_id, FinalStatus final_status) { 405 int process_id, int view_id, FinalStatus final_status) {
397 DCHECK(CalledOnValidThread()); 406 DCHECK(CalledOnValidThread());
398 if (PrerenderData* prerender_data = 407 if (PrerenderData* prerender_data =
399 FindPrerenderDataForChildAndRoute(process_id, view_id)) { 408 FindPrerenderDataForChildAndRoute(process_id, view_id)) {
400 prerender_data->contents()->Destroy(final_status); 409 prerender_data->contents()->Destroy(final_status);
401 } 410 }
402 } 411 }
403 412
404 void PrerenderManager::CancelAllPrerenders() { 413 void PrerenderManager::CancelAllPrerenders() {
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 if (origin) 787 if (origin)
779 *origin = prerender_contents->origin(); 788 *origin = prerender_contents->origin();
780 return true; 789 return true;
781 } 790 }
782 } 791 }
783 } 792 }
784 793
785 return false; 794 return false;
786 } 795 }
787 796
797 bool PrerenderManager::HasPrerenderedUrl(
798 GURL url,
799 content::WebContents* web_contents) const {
800 content::SessionStorageNamespace* session_storage_namespace = web_contents->
801 GetController().GetDefaultSessionStorageNamespace();
802
803 for (ScopedVector<PrerenderData>::const_iterator it =
804 active_prerenders_.begin();
805 it != active_prerenders_.end(); ++it) {
806 PrerenderContents* prerender_contents = (*it)->contents();
807 if (prerender_contents->Matches(url, session_storage_namespace)) {
808 return true;
809 }
810 }
811 return false;
812 }
813
788 PrerenderContents* PrerenderManager::GetPrerenderContents( 814 PrerenderContents* PrerenderManager::GetPrerenderContents(
789 const content::WebContents* web_contents) const { 815 const content::WebContents* web_contents) const {
790 DCHECK(CalledOnValidThread()); 816 DCHECK(CalledOnValidThread());
791 for (ScopedVector<PrerenderData>::const_iterator it = 817 for (ScopedVector<PrerenderData>::const_iterator it =
792 active_prerenders_.begin(); 818 active_prerenders_.begin();
793 it != active_prerenders_.end(); ++it) { 819 it != active_prerenders_.end(); ++it) {
794 WebContents* prerender_web_contents = 820 WebContents* prerender_web_contents =
795 (*it)->contents()->prerender_contents(); 821 (*it)->contents()->prerender_contents();
796 if (prerender_web_contents == web_contents) { 822 if (prerender_web_contents == web_contents) {
797 return (*it)->contents(); 823 return (*it)->contents();
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 logged_in_state_->erase(domain_key); 1605 logged_in_state_->erase(domain_key);
1580 } 1606 }
1581 1607
1582 void PrerenderManager::LoggedInPredictorDataReceived( 1608 void PrerenderManager::LoggedInPredictorDataReceived(
1583 scoped_ptr<LoggedInStateMap> new_map) { 1609 scoped_ptr<LoggedInStateMap> new_map) {
1584 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1610 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1585 logged_in_state_.swap(new_map); 1611 logged_in_state_.swap(new_map);
1586 } 1612 }
1587 1613
1588 } // namespace prerender 1614 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698