Chromium Code Reviews| Index: chrome/browser/prerender/prerender_link_manager.cc |
| diff --git a/chrome/browser/prerender/prerender_link_manager.cc b/chrome/browser/prerender/prerender_link_manager.cc |
| index c12e6cce61b5123ad9fa5e93e3cbfcb75c6b9b3b..2ca4be07e28e6d13359fe17adaa02050b6cb22ec 100644 |
| --- a/chrome/browser/prerender/prerender_link_manager.cc |
| +++ b/chrome/browser/prerender/prerender_link_manager.cc |
| @@ -50,34 +50,39 @@ bool PrerenderLinkManager::OnAddPrerender(int child_id, |
| replacements.ClearRef(); |
| const GURL url = orig_url.ReplaceComponents(replacements); |
| - if (!manager_->AddPrerenderFromLinkRelPrerender( |
| - child_id, render_view_route_id, url, referrer, size)) { |
| + PrerenderHandle prerender = manager_->AddPrerenderFromLinkRelPrerender( |
|
dominich
2012/06/18 15:32:44
the addition of this doesn't seem to have changed
gavinp
2012/06/18 16:40:48
No. It's meant to prepare prerendermanager to have
|
| + child_id, render_view_route_id, url, referrer, size); |
| + if (!prerender) |
|
dominich
2012/06/18 15:32:44
i'm not comfortable with this implicit cast to boo
gavinp
2012/06/18 16:40:48
Already fixed.
|
| return false; |
| - } |
| + DVLOG(4) << "... prerender initial ref count = " << prerender->ref_count_; |
| + |
| const ChildAndPrerenderIdPair child_and_prerender_id(child_id, prerender_id); |
| - DCHECK_EQ(0U, ids_to_url_map_.count(child_and_prerender_id)); |
| - ids_to_url_map_.insert(std::make_pair(child_and_prerender_id, url)); |
| + DCHECK_EQ(0U, ids_to_prerender_map_.count(child_and_prerender_id)); |
| + ids_to_prerender_map_.insert( |
| + std::make_pair(child_and_prerender_id, prerender)); |
| + DVLOG(4) << "... prerender onexit ref count = " << prerender->ref_count_; |
| return true; |
| } |
| // TODO(gavinp): Once an observer interface is provided down to the WebKit |
| -// layer, we should add DCHECK_NE(0L, ids_to_url_map_.count(...)) to both |
| +// layer, we should add DCHECK_NE(0L, ids_to_prerender_map_.count(...)) to both |
| // OnCancelPrerender and OnAbandonPrerender. We can't do this now, since |
| // the WebKit layer isn't even aware if we didn't add the prerender to the map |
| // in OnAddPrerender above. |
| void PrerenderLinkManager::OnCancelPrerender(int child_id, int prerender_id) { |
| DVLOG(2) << "OnCancelPrerender, child_id = " << child_id |
| << ", prerender_id = " << prerender_id; |
| + DVLOG(4) << "... initial map size = " << ids_to_prerender_map_.size(); |
| const ChildAndPrerenderIdPair child_and_prerender_id(child_id, prerender_id); |
| - IdPairToUrlMap::iterator id_url_iter = |
| - ids_to_url_map_.find(child_and_prerender_id); |
| - if (id_url_iter == ids_to_url_map_.end()) { |
| - DVLOG(5) << "... canceling a prerender that doesn't exist."; |
| - return; |
| + |
| + IdPairToPrerenderMap::iterator it = ids_to_prerender_map_.find(child_and_prerender_id); |
| + if (it != ids_to_prerender_map_.end()) { |
| + DVLOG(5) << "ref count = " << it->second->ref_count_; |
| } |
| - const GURL url = id_url_iter->second; |
| - ids_to_url_map_.erase(id_url_iter); |
| - manager_->MaybeCancelPrerender(url); |
| + |
| + ids_to_prerender_map_.erase(child_and_prerender_id); |
| + DVLOG(4) << "... final map size = " << ids_to_prerender_map_.size(); |
| + |
| } |
| void PrerenderLinkManager::OnAbandonPrerender(int child_id, int prerender_id) { |
| @@ -85,8 +90,10 @@ void PrerenderLinkManager::OnAbandonPrerender(int child_id, int prerender_id) { |
| << ", prerender_id = " << prerender_id; |
| // TODO(gavinp,cbentzel): Implement reasonable behaviour for |
| // navigation away from launcher. |
| - const ChildAndPrerenderIdPair child_and_prerender_id(child_id, prerender_id); |
| - ids_to_url_map_.erase(child_and_prerender_id); |
| + |
| + // const ChildAndPrerenderIdPair child_and_prerender_id(child_id, prerender_id); |
| + // XYZZY: WHOAH NELLY |
| + //ids_to_prerender_map_.erase(child_and_prerender_id); |
| } |
| void PrerenderLinkManager::OnChannelClosing(int child_id) { |
| @@ -96,9 +103,9 @@ void PrerenderLinkManager::OnChannelClosing(int child_id) { |
| const ChildAndPrerenderIdPair child_and_maximum_prerender_id( |
| child_id, std::numeric_limits<int>::max()); |
| std::queue<int> prerender_ids_to_abandon; |
| - for (IdPairToUrlMap::iterator |
| - i = ids_to_url_map_.lower_bound(child_and_minimum_prerender_id), |
| - e = ids_to_url_map_.upper_bound(child_and_maximum_prerender_id); |
| + for (IdPairToPrerenderMap::iterator |
| + i = ids_to_prerender_map_.lower_bound(child_and_minimum_prerender_id), |
| + e = ids_to_prerender_map_.upper_bound(child_and_maximum_prerender_id); |
| i != e; ++i) { |
| prerender_ids_to_abandon.push(i->first.second); |
| } |
| @@ -111,7 +118,7 @@ void PrerenderLinkManager::OnChannelClosing(int child_id) { |
| } |
| bool PrerenderLinkManager::IsEmpty() const { |
| - return ids_to_url_map_.empty(); |
| + return ids_to_prerender_map_.empty(); |
| } |
| } // namespace prerender |