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

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

Issue 893843003: Add RedirectInfo as a redirect parameter to ResourceThrottles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Document ResourceThrottle Created 5 years, 10 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
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_util.h" 9 #include "chrome/browser/prerender/prerender_util.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/render_frame_host.h" 11 #include "content/public/browser/render_frame_host.h"
12 #include "content/public/browser/resource_controller.h" 12 #include "content/public/browser/resource_controller.h"
13 #include "content/public/browser/resource_request_info.h" 13 #include "content/public/browser/resource_request_info.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "net/url_request/redirect_info.h"
15 #include "net/url_request/url_request.h" 16 #include "net/url_request/url_request.h"
16 17
17 using content::ResourceType; 18 using content::ResourceType;
18 19
19 namespace prerender { 20 namespace prerender {
20 21
21 namespace { 22 namespace {
22 static const char kFollowOnlyWhenPrerenderShown[] = 23 static const char kFollowOnlyWhenPrerenderShown[] =
23 "follow-only-when-prerender-shown"; 24 "follow-only-when-prerender-shown";
24 25
(...skipping 15 matching lines...) Expand all
40 *defer = true; 41 *defer = true;
41 content::BrowserThread::PostTask( 42 content::BrowserThread::PostTask(
42 content::BrowserThread::UI, 43 content::BrowserThread::UI,
43 FROM_HERE, 44 FROM_HERE,
44 base::Bind(&PrerenderResourceThrottle::WillStartRequestOnUI, 45 base::Bind(&PrerenderResourceThrottle::WillStartRequestOnUI,
45 AsWeakPtr(), request_->method(), info->GetResourceType(), 46 AsWeakPtr(), request_->method(), info->GetResourceType(),
46 info->GetChildID(), info->GetRenderFrameID(), 47 info->GetChildID(), info->GetRenderFrameID(),
47 request_->url())); 48 request_->url()));
48 } 49 }
49 50
50 void PrerenderResourceThrottle::WillRedirectRequest(const GURL& new_url, 51 void PrerenderResourceThrottle::WillRedirectRequest(
51 bool* defer) { 52 const net::RedirectInfo& redirect_info,
53 bool* defer) {
52 const content::ResourceRequestInfo* info = 54 const content::ResourceRequestInfo* info =
53 content::ResourceRequestInfo::ForRequest(request_); 55 content::ResourceRequestInfo::ForRequest(request_);
54 *defer = true; 56 *defer = true;
55 std::string header; 57 std::string header;
56 request_->GetResponseHeaderByName(kFollowOnlyWhenPrerenderShown, &header); 58 request_->GetResponseHeaderByName(kFollowOnlyWhenPrerenderShown, &header);
57 59
58 content::BrowserThread::PostTask( 60 content::BrowserThread::PostTask(
59 content::BrowserThread::UI, 61 content::BrowserThread::UI,
60 FROM_HERE, 62 FROM_HERE,
61 base::Bind(&PrerenderResourceThrottle::WillRedirectRequestOnUI, 63 base::Bind(&PrerenderResourceThrottle::WillRedirectRequestOnUI,
62 AsWeakPtr(), header, info->GetResourceType(), info->IsAsync(), 64 AsWeakPtr(), header, info->GetResourceType(), info->IsAsync(),
63 info->GetChildID(), info->GetRenderFrameID(), new_url)); 65 info->GetChildID(), info->GetRenderFrameID(),
66 redirect_info.new_url));
64 } 67 }
65 68
66 const char* PrerenderResourceThrottle::GetNameForLogging() const { 69 const char* PrerenderResourceThrottle::GetNameForLogging() const {
67 return "PrerenderResourceThrottle"; 70 return "PrerenderResourceThrottle";
68 } 71 }
69 72
70 void PrerenderResourceThrottle::Resume() { 73 void PrerenderResourceThrottle::Resume() {
71 controller()->Resume(); 74 controller()->Resume();
72 } 75 }
73 76
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (g_prerender_contents_for_testing) 161 if (g_prerender_contents_for_testing)
159 return g_prerender_contents_for_testing; 162 return g_prerender_contents_for_testing;
160 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( 163 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(
161 render_process_id, render_frame_id); 164 render_process_id, render_frame_id);
162 content::WebContents* web_contents = 165 content::WebContents* web_contents =
163 content::WebContents::FromRenderFrameHost(rfh); 166 content::WebContents::FromRenderFrameHost(rfh);
164 return PrerenderContents::FromWebContents(web_contents); 167 return PrerenderContents::FromWebContents(web_contents);
165 } 168 }
166 169
167 } // namespace prerender 170 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_resource_throttle.h ('k') | chrome/browser/prerender/prerender_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698