| 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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 return nullptr; | 709 return nullptr; |
| 710 } | 710 } |
| 711 | 711 |
| 712 PrerenderContents* PrerenderManager::GetPrerenderContentsForRoute( | 712 PrerenderContents* PrerenderManager::GetPrerenderContentsForRoute( |
| 713 int child_id, | 713 int child_id, |
| 714 int route_id) const { | 714 int route_id) const { |
| 715 WebContents* web_contents = tab_util::GetWebContentsByID(child_id, route_id); | 715 WebContents* web_contents = tab_util::GetWebContentsByID(child_id, route_id); |
| 716 return web_contents ? GetPrerenderContents(web_contents) : nullptr; | 716 return web_contents ? GetPrerenderContents(web_contents) : nullptr; |
| 717 } | 717 } |
| 718 | 718 |
| 719 PrerenderContents* PrerenderManager::GetPrerenderContentsForProcess( | |
| 720 int render_process_id) const { | |
| 721 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 722 for (auto& prerender_data : active_prerenders_) { | |
| 723 PrerenderContents* prerender_contents = prerender_data->contents(); | |
| 724 if (prerender_contents->GetRenderViewHost()->GetProcess()->GetID() == | |
| 725 render_process_id) { | |
| 726 return prerender_contents; | |
| 727 } | |
| 728 } | |
| 729 return nullptr; | |
| 730 } | |
| 731 | |
| 732 std::vector<WebContents*> PrerenderManager::GetAllPrerenderingContents() const { | 719 std::vector<WebContents*> PrerenderManager::GetAllPrerenderingContents() const { |
| 733 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 720 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 734 std::vector<WebContents*> result; | 721 std::vector<WebContents*> result; |
| 735 | 722 |
| 736 for (const auto& prerender : active_prerenders_) { | 723 for (const auto& prerender : active_prerenders_) { |
| 737 WebContents* contents = prerender->contents()->prerender_contents(); | 724 WebContents* contents = prerender->contents()->prerender_contents(); |
| 738 if (contents && | 725 if (contents && |
| 739 prerender->contents()->prerender_mode() == FULL_PRERENDER) { | 726 prerender->contents()->prerender_mode() == FULL_PRERENDER) { |
| 740 result.push_back(contents); | 727 result.push_back(contents); |
| 741 } | 728 } |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 DCHECK_EQ(1u, erased); | 1377 DCHECK_EQ(1u, erased); |
| 1391 } | 1378 } |
| 1392 | 1379 |
| 1393 void PrerenderManager::SetPrerenderContentsFactoryForTest( | 1380 void PrerenderManager::SetPrerenderContentsFactoryForTest( |
| 1394 PrerenderContents::Factory* prerender_contents_factory) { | 1381 PrerenderContents::Factory* prerender_contents_factory) { |
| 1395 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1382 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1396 prerender_contents_factory_.reset(prerender_contents_factory); | 1383 prerender_contents_factory_.reset(prerender_contents_factory); |
| 1397 } | 1384 } |
| 1398 | 1385 |
| 1399 } // namespace prerender | 1386 } // namespace prerender |
| OLD | NEW |