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

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

Issue 141163002: Make PrerenderTracker's resource_throttle_io_thread_map_ use RenderFrame IDs instead of RenderView … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_resource_throttle.h" 5 #include "chrome/browser/prerender/prerender_resource_throttle.h"
6 6
7 #include "chrome/browser/prerender/prerender_final_status.h" 7 #include "chrome/browser/prerender/prerender_final_status.h"
8 #include "chrome/browser/prerender/prerender_manager.h" 8 #include "chrome/browser/prerender/prerender_manager.h"
9 #include "chrome/browser/prerender/prerender_tracker.h" 9 #include "chrome/browser/prerender/prerender_tracker.h"
10 #include "chrome/browser/prerender/prerender_util.h" 10 #include "chrome/browser/prerender/prerender_util.h"
(...skipping 21 matching lines...) Expand all
32 PrerenderResourceThrottle::PrerenderResourceThrottle( 32 PrerenderResourceThrottle::PrerenderResourceThrottle(
33 net::URLRequest* request, 33 net::URLRequest* request,
34 PrerenderTracker* tracker) 34 PrerenderTracker* tracker)
35 : request_(request), 35 : request_(request),
36 tracker_(tracker) { 36 tracker_(tracker) {
37 } 37 }
38 38
39 void PrerenderResourceThrottle::WillStartRequest(bool* defer) { 39 void PrerenderResourceThrottle::WillStartRequest(bool* defer) {
40 const content::ResourceRequestInfo* info = 40 const content::ResourceRequestInfo* info =
41 content::ResourceRequestInfo::ForRequest(request_); 41 content::ResourceRequestInfo::ForRequest(request_);
42 int child_id = info->GetChildID();
43 int route_id = info->GetRouteID();
44
45 // If the prerender was used since the throttle was added, leave it
46 // alone.
47 if (!tracker_->IsPrerenderingOnIOThread(child_id, route_id))
48 return;
49
50 *defer = true; 42 *defer = true;
51 content::BrowserThread::PostTask( 43 content::BrowserThread::PostTask(
52 content::BrowserThread::UI, 44 content::BrowserThread::UI,
53 FROM_HERE, 45 FROM_HERE,
54 base::Bind(&PrerenderResourceThrottle::WillStartRequestOnUI, 46 base::Bind(&PrerenderResourceThrottle::WillStartRequestOnUI,
55 AsWeakPtr(), request_->method(), info->GetChildID(), 47 AsWeakPtr(), request_->method(), info->GetChildID(),
56 info->GetRenderFrameID(), request_->url())); 48 info->GetRenderFrameID(), request_->url()));
57 } 49 }
58 50
59 void PrerenderResourceThrottle::WillRedirectRequest(const GURL& new_url, 51 void PrerenderResourceThrottle::WillRedirectRequest(const GURL& new_url,
60 bool* defer) { 52 bool* defer) {
61 const content::ResourceRequestInfo* info = 53 const content::ResourceRequestInfo* info =
62 content::ResourceRequestInfo::ForRequest(request_); 54 content::ResourceRequestInfo::ForRequest(request_);
63 int child_id = info->GetChildID();
64 int route_id = info->GetRouteID();
65
66 // If the prerender was used since the throttle was added, leave it
67 // alone.
68 if (!tracker_->IsPrerenderingOnIOThread(child_id, route_id))
69 return;
70
71 *defer = true; 55 *defer = true;
72 std::string header; 56 std::string header;
73 request_->GetResponseHeaderByName(kFollowOnlyWhenPrerenderShown, &header); 57 request_->GetResponseHeaderByName(kFollowOnlyWhenPrerenderShown, &header);
74 58
75 content::BrowserThread::PostTask( 59 content::BrowserThread::PostTask(
76 content::BrowserThread::UI, 60 content::BrowserThread::UI,
77 FROM_HERE, 61 FROM_HERE,
78 base::Bind(&PrerenderResourceThrottle::WillRedirectRequestOnUI, 62 base::Bind(&PrerenderResourceThrottle::WillRedirectRequestOnUI,
79 AsWeakPtr(), header, info->GetResourceType(), info->IsAsync(), 63 AsWeakPtr(), header, info->GetResourceType(), info->IsAsync(),
80 info->GetChildID(), info->GetRenderFrameID(), new_url)); 64 info->GetChildID(), info->GetRenderFrameID(), new_url));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 render_process_id, render_frame_id); 162 render_process_id, render_frame_id);
179 content::WebContents* web_contents = 163 content::WebContents* web_contents =
180 content::WebContents::FromRenderFrameHost(rfh); 164 content::WebContents::FromRenderFrameHost(rfh);
181 return PrerenderContents::FromWebContents(web_contents); 165 return PrerenderContents::FromWebContents(web_contents);
182 } 166 }
183 167
184 void PrerenderResourceThrottle::AddResourceThrottle() { 168 void PrerenderResourceThrottle::AddResourceThrottle() {
185 const content::ResourceRequestInfo* info = 169 const content::ResourceRequestInfo* info =
186 content::ResourceRequestInfo::ForRequest(request_); 170 content::ResourceRequestInfo::ForRequest(request_);
187 int child_id = info->GetChildID(); 171 int child_id = info->GetChildID();
188 int route_id = info->GetRouteID(); 172 int route_id = info->GetRouteID();
tburkard 2014/01/17 11:26:11 So you said transition to RenderFrameID vs. Render
189 tracker_->AddResourceThrottleOnIOThread(child_id, route_id, AsWeakPtr()); 173 tracker_->AddResourceThrottleOnIOThread(child_id, route_id, AsWeakPtr());
190 } 174 }
191 175
192 } // namespace prerender 176 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698