 Chromium Code Reviews
 Chromium Code Reviews Issue 1710853002:
  android: Add a method to let Java know whether a prerender has finished loading.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1710853002:
  android: Add a method to let Java know whether a prerender has finished loading.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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 <stddef.h> | 7 #include <stddef.h> | 
| 8 | 8 | 
| 9 #include <algorithm> | 9 #include <algorithm> | 
| 10 #include <functional> | 10 #include <functional> | 
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 } | 655 } | 
| 656 return false; | 656 return false; | 
| 657 } | 657 } | 
| 658 | 658 | 
| 659 bool PrerenderManager::HasPrerenderedUrl( | 659 bool PrerenderManager::HasPrerenderedUrl( | 
| 660 GURL url, | 660 GURL url, | 
| 661 content::WebContents* web_contents) const { | 661 content::WebContents* web_contents) const { | 
| 662 content::SessionStorageNamespace* session_storage_namespace = web_contents-> | 662 content::SessionStorageNamespace* session_storage_namespace = web_contents-> | 
| 663 GetController().GetDefaultSessionStorageNamespace(); | 663 GetController().GetDefaultSessionStorageNamespace(); | 
| 664 | 664 | 
| 665 for (ScopedVector<PrerenderData>::const_iterator it = | 665 for (const auto& prerender_data : active_prerenders_) { | 
| 
gavinp
2016/02/25 18:44:55
Thanks. This is closely related and so refactoring
 | |
| 666 active_prerenders_.begin(); | 666 PrerenderContents* prerender_contents = prerender_data->contents(); | 
| 667 it != active_prerenders_.end(); ++it) { | 667 if (prerender_contents->Matches(url, session_storage_namespace)) | 
| 668 PrerenderContents* prerender_contents = (*it)->contents(); | |
| 669 if (prerender_contents->Matches(url, session_storage_namespace)) { | |
| 670 return true; | 668 return true; | 
| 671 } | |
| 672 } | 669 } | 
| 673 return false; | 670 return false; | 
| 674 } | 671 } | 
| 672 | |
| 673 bool PrerenderManager::HasPrerenderedAndFinishedLoadingUrl( | |
| 674 GURL url, | |
| 675 content::WebContents* web_contents) const { | |
| 676 content::SessionStorageNamespace* session_storage_namespace = | |
| 677 web_contents->GetController().GetDefaultSessionStorageNamespace(); | |
| 678 | |
| 679 for (const auto& prerender_data : active_prerenders_) { | |
| 680 PrerenderContents* prerender_contents = prerender_data->contents(); | |
| 681 if (prerender_contents->Matches(url, session_storage_namespace) && | |
| 682 prerender_contents->has_finished_loading()) | |
| 683 return true; | |
| 684 } | |
| 685 return false; | |
| 686 } | |
| 675 | 687 | 
| 676 PrerenderContents* PrerenderManager::GetPrerenderContents( | 688 PrerenderContents* PrerenderManager::GetPrerenderContents( | 
| 677 const content::WebContents* web_contents) const { | 689 const content::WebContents* web_contents) const { | 
| 678 DCHECK(CalledOnValidThread()); | 690 DCHECK(CalledOnValidThread()); | 
| 679 for (ScopedVector<PrerenderData>::const_iterator it = | 691 for (ScopedVector<PrerenderData>::const_iterator it = | 
| 680 active_prerenders_.begin(); | 692 active_prerenders_.begin(); | 
| 681 it != active_prerenders_.end(); ++it) { | 693 it != active_prerenders_.end(); ++it) { | 
| 682 WebContents* prerender_web_contents = | 694 WebContents* prerender_web_contents = | 
| 683 (*it)->contents()->prerender_contents(); | 695 (*it)->contents()->prerender_contents(); | 
| 684 if (prerender_web_contents == web_contents) { | 696 if (prerender_web_contents == web_contents) { | 
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1299 } | 1311 } | 
| 1300 | 1312 | 
| 1301 void PrerenderManager::RenderProcessHostDestroyed( | 1313 void PrerenderManager::RenderProcessHostDestroyed( | 
| 1302 content::RenderProcessHost* host) { | 1314 content::RenderProcessHost* host) { | 
| 1303 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1315 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 
| 1304 size_t erased = prerender_process_hosts_.erase(host); | 1316 size_t erased = prerender_process_hosts_.erase(host); | 
| 1305 DCHECK_EQ(1u, erased); | 1317 DCHECK_EQ(1u, erased); | 
| 1306 } | 1318 } | 
| 1307 | 1319 | 
| 1308 } // namespace prerender | 1320 } // namespace prerender | 
| OLD | NEW |