Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: chrome/browser/prerender/prerender_tracker.cc

Issue 138583003: Add back the code to PrerenderManager::PendingSwap to handle RenderViewCreated being called for a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_tracker.h" 5 #include "chrome/browser/prerender/prerender_tracker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/prerender/prerender_manager.h" 10 #include "chrome/browser/prerender/prerender_manager.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 const base::WeakPtr<PrerenderPendingSwapThrottle>& throttle) { 111 const base::WeakPtr<PrerenderPendingSwapThrottle>& throttle) {
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
113 113
114 ChildRouteIdPair render_frame_route_id_pair( 114 ChildRouteIdPair render_frame_route_id_pair(
115 render_process_id, render_frame_id); 115 render_process_id, render_frame_id);
116 PendingSwapThrottleMap::iterator it = 116 PendingSwapThrottleMap::iterator it =
117 pending_swap_throttle_map_.find(render_frame_route_id_pair); 117 pending_swap_throttle_map_.find(render_frame_route_id_pair);
118 DCHECK(it != pending_swap_throttle_map_.end()); 118 DCHECK(it != pending_swap_throttle_map_.end());
119 if (it == pending_swap_throttle_map_.end()) 119 if (it == pending_swap_throttle_map_.end())
120 return; 120 return;
121 it->second.throttle = throttle; 121 it->second.throttles.push_back(throttle);
122 } 122 }
123 123
124 void PrerenderTracker::AddPrerenderOnIOThread( 124 void PrerenderTracker::AddPrerenderOnIOThread(
125 const ChildRouteIdPair& child_route_id_pair) { 125 const ChildRouteIdPair& child_route_id_pair) {
126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
127 DCHECK(!IsPrerenderingOnIOThread(child_route_id_pair.first, 127 DCHECK(!IsPrerenderingOnIOThread(child_route_id_pair.first,
128 child_route_id_pair.second)); 128 child_route_id_pair.second));
129 129
130 resource_throttle_io_thread_map_.insert( 130 resource_throttle_io_thread_map_.insert(
131 std::make_pair(child_route_id_pair, ResourceThrottleList())); 131 std::make_pair(child_route_id_pair, ResourceThrottleList()));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 166 }
167 167
168 void PrerenderTracker::RemovePrerenderPendingSwapOnIOThread( 168 void PrerenderTracker::RemovePrerenderPendingSwapOnIOThread(
169 const ChildRouteIdPair& render_frame_route_id_pair, 169 const ChildRouteIdPair& render_frame_route_id_pair,
170 bool swap_successful) { 170 bool swap_successful) {
171 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 171 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
172 PendingSwapThrottleMap::iterator it = 172 PendingSwapThrottleMap::iterator it =
173 pending_swap_throttle_map_.find(render_frame_route_id_pair); 173 pending_swap_throttle_map_.find(render_frame_route_id_pair);
174 DCHECK(it != pending_swap_throttle_map_.end()); 174 DCHECK(it != pending_swap_throttle_map_.end());
175 // Cancel or resume all throttled resources. 175 // Cancel or resume all throttled resources.
176 if (it->second.throttle) { 176 for (size_t i = 0; i < it->second.throttles.size(); i++) {
177 if (!it->second.throttles[i])
178 continue;
177 if (swap_successful) 179 if (swap_successful)
178 it->second.throttle->Cancel(); 180 it->second.throttles[i]->Cancel();
179 else 181 else
180 it->second.throttle->Resume(); 182 it->second.throttles[i]->Resume();
181 } 183 }
182 pending_swap_throttle_map_.erase(render_frame_route_id_pair); 184 pending_swap_throttle_map_.erase(render_frame_route_id_pair);
183 } 185 }
184 186
185 void PrerenderTracker::AddPrerenderPendingSwap( 187 void PrerenderTracker::AddPrerenderPendingSwap(
186 const ChildRouteIdPair& render_frame_route_id_pair, 188 const ChildRouteIdPair& render_frame_route_id_pair,
187 const GURL& url) { 189 const GURL& url) {
188 BrowserThread::PostTask( 190 BrowserThread::PostTask(
189 BrowserThread::IO, FROM_HERE, 191 BrowserThread::IO, FROM_HERE,
190 base::Bind(&PrerenderTracker::AddPrerenderPendingSwapOnIOThread, 192 base::Bind(&PrerenderTracker::AddPrerenderPendingSwapOnIOThread,
(...skipping 17 matching lines...) Expand all
208 210
209 PrerenderTracker::PendingSwapThrottleData::~PendingSwapThrottleData() { 211 PrerenderTracker::PendingSwapThrottleData::~PendingSwapThrottleData() {
210 } 212 }
211 213
212 // static 214 // static
213 PrerenderTracker* PrerenderTracker::GetDefault() { 215 PrerenderTracker* PrerenderTracker::GetDefault() {
214 return g_browser_process->prerender_tracker(); 216 return g_browser_process->prerender_tracker();
215 } 217 }
216 218
217 } // namespace prerender 219 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698