| 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 |
| 719 std::vector<WebContents*> PrerenderManager::GetAllPrerenderingContents() const { | 732 std::vector<WebContents*> PrerenderManager::GetAllPrerenderingContents() const { |
| 720 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 733 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 721 std::vector<WebContents*> result; | 734 std::vector<WebContents*> result; |
| 722 | 735 |
| 723 for (const auto& prerender : active_prerenders_) { | 736 for (const auto& prerender : active_prerenders_) { |
| 724 WebContents* contents = prerender->contents()->prerender_contents(); | 737 WebContents* contents = prerender->contents()->prerender_contents(); |
| 725 if (contents && | 738 if (contents && |
| 726 prerender->contents()->prerender_mode() == FULL_PRERENDER) { | 739 prerender->contents()->prerender_mode() == FULL_PRERENDER) { |
| 727 result.push_back(contents); | 740 result.push_back(contents); |
| 728 } | 741 } |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 DCHECK_EQ(1u, erased); | 1390 DCHECK_EQ(1u, erased); |
| 1378 } | 1391 } |
| 1379 | 1392 |
| 1380 void PrerenderManager::SetPrerenderContentsFactoryForTest( | 1393 void PrerenderManager::SetPrerenderContentsFactoryForTest( |
| 1381 PrerenderContents::Factory* prerender_contents_factory) { | 1394 PrerenderContents::Factory* prerender_contents_factory) { |
| 1382 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1395 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1383 prerender_contents_factory_.reset(prerender_contents_factory); | 1396 prerender_contents_factory_.reset(prerender_contents_factory); |
| 1384 } | 1397 } |
| 1385 | 1398 |
| 1386 } // namespace prerender | 1399 } // namespace prerender |
| OLD | NEW |