| OLD | NEW |
| 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 } | 393 } |
| 394 | 394 |
| 395 PrerenderHandle* PrerenderManager::AddPrerenderFromLocalPredictor( | 395 PrerenderHandle* PrerenderManager::AddPrerenderFromLocalPredictor( |
| 396 const GURL& url, | 396 const GURL& url, |
| 397 SessionStorageNamespace* session_storage_namespace, | 397 SessionStorageNamespace* session_storage_namespace, |
| 398 const gfx::Size& size) { | 398 const gfx::Size& size) { |
| 399 return AddPrerender(ORIGIN_LOCAL_PREDICTOR, -1, url, content::Referrer(), | 399 return AddPrerender(ORIGIN_LOCAL_PREDICTOR, -1, url, content::Referrer(), |
| 400 size, session_storage_namespace); | 400 size, session_storage_namespace); |
| 401 } | 401 } |
| 402 | 402 |
| 403 PrerenderHandle* PrerenderManager::AddPrerenderFromExternalRequest( |
| 404 const GURL& url, |
| 405 const content::Referrer& referrer, |
| 406 SessionStorageNamespace* session_storage_namespace, |
| 407 const gfx::Size& size) { |
| 408 return AddPrerender(ORIGIN_EXTERNAL_REQUEST, -1, url, referrer, size, |
| 409 session_storage_namespace); |
| 410 } |
| 411 |
| 403 void PrerenderManager::DestroyPrerenderForRenderView( | 412 void PrerenderManager::DestroyPrerenderForRenderView( |
| 404 int process_id, int view_id, FinalStatus final_status) { | 413 int process_id, int view_id, FinalStatus final_status) { |
| 405 DCHECK(CalledOnValidThread()); | 414 DCHECK(CalledOnValidThread()); |
| 406 if (PrerenderData* prerender_data = | 415 if (PrerenderData* prerender_data = |
| 407 FindPrerenderDataForChildAndRoute(process_id, view_id)) { | 416 FindPrerenderDataForChildAndRoute(process_id, view_id)) { |
| 408 prerender_data->contents()->Destroy(final_status); | 417 prerender_data->contents()->Destroy(final_status); |
| 409 } | 418 } |
| 410 } | 419 } |
| 411 | 420 |
| 412 void PrerenderManager::CancelAllPrerenders() { | 421 void PrerenderManager::CancelAllPrerenders() { |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 if (origin) | 796 if (origin) |
| 788 *origin = prerender_contents->origin(); | 797 *origin = prerender_contents->origin(); |
| 789 return true; | 798 return true; |
| 790 } | 799 } |
| 791 } | 800 } |
| 792 } | 801 } |
| 793 | 802 |
| 794 return false; | 803 return false; |
| 795 } | 804 } |
| 796 | 805 |
| 806 bool PrerenderManager::HasPrerenderedUrl( |
| 807 GURL url, |
| 808 content::WebContents* web_contents) const { |
| 809 content::SessionStorageNamespace* session_storage_namespace = web_contents-> |
| 810 GetController().GetDefaultSessionStorageNamespace(); |
| 811 |
| 812 for (ScopedVector<PrerenderData>::const_iterator it = |
| 813 active_prerenders_.begin(); |
| 814 it != active_prerenders_.end(); ++it) { |
| 815 PrerenderContents* prerender_contents = (*it)->contents(); |
| 816 if (prerender_contents->Matches(url, session_storage_namespace)) { |
| 817 return true; |
| 818 } |
| 819 } |
| 820 return false; |
| 821 } |
| 822 |
| 797 PrerenderContents* PrerenderManager::GetPrerenderContents( | 823 PrerenderContents* PrerenderManager::GetPrerenderContents( |
| 798 const content::WebContents* web_contents) const { | 824 const content::WebContents* web_contents) const { |
| 799 DCHECK(CalledOnValidThread()); | 825 DCHECK(CalledOnValidThread()); |
| 800 for (ScopedVector<PrerenderData>::const_iterator it = | 826 for (ScopedVector<PrerenderData>::const_iterator it = |
| 801 active_prerenders_.begin(); | 827 active_prerenders_.begin(); |
| 802 it != active_prerenders_.end(); ++it) { | 828 it != active_prerenders_.end(); ++it) { |
| 803 WebContents* prerender_web_contents = | 829 WebContents* prerender_web_contents = |
| 804 (*it)->contents()->prerender_contents(); | 830 (*it)->contents()->prerender_contents(); |
| 805 if (prerender_web_contents == web_contents) { | 831 if (prerender_web_contents == web_contents) { |
| 806 return (*it)->contents(); | 832 return (*it)->contents(); |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 logged_in_state_->erase(domain_key); | 1614 logged_in_state_->erase(domain_key); |
| 1589 } | 1615 } |
| 1590 | 1616 |
| 1591 void PrerenderManager::LoggedInPredictorDataReceived( | 1617 void PrerenderManager::LoggedInPredictorDataReceived( |
| 1592 scoped_ptr<LoggedInStateMap> new_map) { | 1618 scoped_ptr<LoggedInStateMap> new_map) { |
| 1593 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1619 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1594 logged_in_state_.swap(new_map); | 1620 logged_in_state_.swap(new_map); |
| 1595 } | 1621 } |
| 1596 | 1622 |
| 1597 } // namespace prerender | 1623 } // namespace prerender |
| OLD | NEW |