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

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

Issue 2535723005: Stop using ResourceController in ResourceThrottle (Closed)
Patch Set: Addressed #62 Created 4 years 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
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/prerender/prerender_final_status.h" 11 #include "chrome/browser/prerender/prerender_final_status.h"
12 #include "chrome/browser/prerender/prerender_manager.h" 12 #include "chrome/browser/prerender/prerender_manager.h"
13 #include "chrome/browser/prerender/prerender_util.h" 13 #include "chrome/browser/prerender/prerender_util.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/render_frame_host.h" 15 #include "content/public/browser/render_frame_host.h"
16 #include "content/public/browser/resource_controller.h"
17 #include "content/public/browser/resource_request_info.h" 16 #include "content/public/browser/resource_request_info.h"
18 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
19 #include "net/http/http_response_headers.h" 18 #include "net/http/http_response_headers.h"
20 #include "net/url_request/redirect_info.h" 19 #include "net/url_request/redirect_info.h"
21 #include "net/url_request/url_request.h" 20 #include "net/url_request/url_request.h"
22 21
23 using content::BrowserThread; 22 using content::BrowserThread;
24 using content::ResourceType; 23 using content::ResourceType;
25 24
26 namespace prerender { 25 namespace prerender {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 content::IsResourceTypeFrame(info->GetResourceType()), 132 content::IsResourceTypeFrame(info->GetResourceType()),
134 IsNoStoreResponse(*request_), redirect_count, 133 IsNoStoreResponse(*request_), redirect_count,
135 info->GetChildID(), info->GetRenderFrameID(), 134 info->GetChildID(), info->GetRenderFrameID(),
136 prerender_throttle_info_)); 135 prerender_throttle_info_));
137 } 136 }
138 137
139 const char* PrerenderResourceThrottle::GetNameForLogging() const { 138 const char* PrerenderResourceThrottle::GetNameForLogging() const {
140 return "PrerenderResourceThrottle"; 139 return "PrerenderResourceThrottle";
141 } 140 }
142 141
143 void PrerenderResourceThrottle::Resume() { 142 void PrerenderResourceThrottle::ResumeHandler() {
144 controller()->Resume(); 143 Resume();
145 }
146
147 void PrerenderResourceThrottle::Cancel() {
148 controller()->Cancel();
149 } 144 }
150 145
151 // static 146 // static
152 void PrerenderResourceThrottle::WillStartRequestOnUI( 147 void PrerenderResourceThrottle::WillStartRequestOnUI(
153 const base::WeakPtr<PrerenderResourceThrottle>& throttle, 148 const base::WeakPtr<PrerenderResourceThrottle>& throttle,
154 const std::string& method, 149 const std::string& method,
155 ResourceType resource_type, 150 ResourceType resource_type,
156 int render_process_id, 151 int render_process_id,
157 int render_frame_id, 152 int render_frame_id,
158 const GURL& url, 153 const GURL& url,
(...skipping 28 matching lines...) Expand all
187 // to conserve network usage in mobile devices. 182 // to conserve network usage in mobile devices.
188 prerender_contents->AddResourceThrottle(throttle); 183 prerender_contents->AddResourceThrottle(throttle);
189 return; 184 return;
190 #endif 185 #endif
191 } 186 }
192 } 187 }
193 188
194 BrowserThread::PostTask( 189 BrowserThread::PostTask(
195 BrowserThread::IO, FROM_HERE, 190 BrowserThread::IO, FROM_HERE,
196 base::Bind(cancel ? &PrerenderResourceThrottle::Cancel 191 base::Bind(cancel ? &PrerenderResourceThrottle::Cancel
197 : &PrerenderResourceThrottle::Resume, 192 : &PrerenderResourceThrottle::ResumeHandler,
198 throttle)); 193 throttle));
199 } 194 }
200 195
201 // static 196 // static
202 void PrerenderResourceThrottle::WillRedirectRequestOnUI( 197 void PrerenderResourceThrottle::WillRedirectRequestOnUI(
203 const base::WeakPtr<PrerenderResourceThrottle>& throttle, 198 const base::WeakPtr<PrerenderResourceThrottle>& throttle,
204 const std::string& follow_only_when_prerender_shown_header, 199 const std::string& follow_only_when_prerender_shown_header,
205 ResourceType resource_type, 200 ResourceType resource_type,
206 bool async, 201 bool async,
207 bool is_no_store, 202 bool is_no_store,
(...skipping 26 matching lines...) Expand all
234 // Defer the redirect until the prerender is used or canceled. 229 // Defer the redirect until the prerender is used or canceled.
235 prerender_contents->AddResourceThrottle(throttle); 230 prerender_contents->AddResourceThrottle(throttle);
236 return; 231 return;
237 } 232 }
238 } 233 }
239 } 234 }
240 235
241 BrowserThread::PostTask( 236 BrowserThread::PostTask(
242 BrowserThread::IO, FROM_HERE, 237 BrowserThread::IO, FROM_HERE,
243 base::Bind(cancel ? &PrerenderResourceThrottle::Cancel 238 base::Bind(cancel ? &PrerenderResourceThrottle::Cancel
244 : &PrerenderResourceThrottle::Resume, 239 : &PrerenderResourceThrottle::ResumeHandler,
245 throttle)); 240 throttle));
246 } 241 }
247 242
248 // static 243 // static
249 void PrerenderResourceThrottle::WillProcessResponseOnUI( 244 void PrerenderResourceThrottle::WillProcessResponseOnUI(
250 bool is_main_resource, 245 bool is_main_resource,
251 bool is_no_store, 246 bool is_no_store,
252 int redirect_count, 247 int redirect_count,
253 int render_process_id, 248 int render_process_id,
254 int render_frame_id, 249 int render_frame_id,
(...skipping 18 matching lines...) Expand all
273 if (g_prerender_contents_for_testing) 268 if (g_prerender_contents_for_testing)
274 return g_prerender_contents_for_testing; 269 return g_prerender_contents_for_testing;
275 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( 270 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(
276 render_process_id, render_frame_id); 271 render_process_id, render_frame_id);
277 content::WebContents* web_contents = 272 content::WebContents* web_contents =
278 content::WebContents::FromRenderFrameHost(rfh); 273 content::WebContents::FromRenderFrameHost(rfh);
279 return PrerenderContents::FromWebContents(web_contents); 274 return PrerenderContents::FromWebContents(web_contents);
280 } 275 }
281 276
282 } // namespace prerender 277 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698