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_link_manager.h" | 5 #include "chrome/browser/prerender/prerender_link_manager.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 void PrerenderLinkManager::OnCancelPrerender(int child_id, int prerender_id) { | 91 void PrerenderLinkManager::OnCancelPrerender(int child_id, int prerender_id) { |
92 DVLOG(2) << "OnCancelPrerender, child_id = " << child_id | 92 DVLOG(2) << "OnCancelPrerender, child_id = " << child_id |
93 << ", prerender_id = " << prerender_id; | 93 << ", prerender_id = " << prerender_id; |
94 const ChildAndPrerenderIdPair child_and_prerender_id(child_id, prerender_id); | 94 const ChildAndPrerenderIdPair child_and_prerender_id(child_id, prerender_id); |
95 IdPairToPrerenderHandleMap::iterator id_to_handle_iter = | 95 IdPairToPrerenderHandleMap::iterator id_to_handle_iter = |
96 ids_to_handle_map_.find(child_and_prerender_id); | 96 ids_to_handle_map_.find(child_and_prerender_id); |
97 if (id_to_handle_iter == ids_to_handle_map_.end()) { | 97 if (id_to_handle_iter == ids_to_handle_map_.end()) { |
98 DVLOG(5) << "... canceling a prerender that doesn't exist."; | 98 DVLOG(5) << "... canceling a prerender that doesn't exist."; |
99 return; | 99 return; |
100 } | 100 } |
101 PrerenderHandle* prerender_handle = id_to_handle_iter->second; | 101 |
| 102 scoped_ptr<PrerenderHandle> prerender_handle(id_to_handle_iter->second); |
| 103 ids_to_handle_map_.erase(id_to_handle_iter); |
102 prerender_handle->OnCancel(); | 104 prerender_handle->OnCancel(); |
103 | 105 |
104 // Because OnCancel() can remove the prerender from the map, we need to | 106 // Because OnCancel() can remove the prerender from the map, we need to |
105 // consider our iterator invalid. | 107 // consider our iterator invalid. |
106 id_to_handle_iter = ids_to_handle_map_.find(child_and_prerender_id); | 108 id_to_handle_iter = ids_to_handle_map_.find(child_and_prerender_id); |
107 if (id_to_handle_iter != ids_to_handle_map_.end()) | 109 if (id_to_handle_iter != ids_to_handle_map_.end()) |
108 RemovePrerender(id_to_handle_iter); | 110 RemovePrerender(id_to_handle_iter); |
109 } | 111 } |
110 | 112 |
111 void PrerenderLinkManager::OnAbandonPrerender(int child_id, int prerender_id) { | 113 void PrerenderLinkManager::OnAbandonPrerender(int child_id, int prerender_id) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 if (it == ids_to_handle_map_.end()) | 202 if (it == ids_to_handle_map_.end()) |
201 return; | 203 return; |
202 const int child_id = it->first.first; | 204 const int child_id = it->first.first; |
203 const int prerender_id = it->first.second; | 205 const int prerender_id = it->first.second; |
204 | 206 |
205 Send(child_id, new PrerenderMsg_OnPrerenderStop(prerender_id)); | 207 Send(child_id, new PrerenderMsg_OnPrerenderStop(prerender_id)); |
206 RemovePrerender(it); | 208 RemovePrerender(it); |
207 } | 209 } |
208 | 210 |
209 } // namespace prerender | 211 } // namespace prerender |
OLD | NEW |