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

Side by Side Diff: content/browser/loader/cross_site_resource_handler.cc

Issue 184873004: Update resource requests to remove redundant frame ID. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comments Created 6 years, 9 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 "content/browser/loader/cross_site_resource_handler.h" 5 #include "content/browser/loader/cross_site_resource_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 25 matching lines...) Expand all
36 // The parameters to OnCrossSiteResponseHelper exceed the number of arguments 36 // The parameters to OnCrossSiteResponseHelper exceed the number of arguments
37 // base::Bind supports. 37 // base::Bind supports.
38 struct CrossSiteResponseParams { 38 struct CrossSiteResponseParams {
39 CrossSiteResponseParams( 39 CrossSiteResponseParams(
40 int render_view_id, 40 int render_view_id,
41 const GlobalRequestID& global_request_id, 41 const GlobalRequestID& global_request_id,
42 bool is_transfer, 42 bool is_transfer,
43 const std::vector<GURL>& transfer_url_chain, 43 const std::vector<GURL>& transfer_url_chain,
44 const Referrer& referrer, 44 const Referrer& referrer,
45 PageTransition page_transition, 45 PageTransition page_transition,
46 int64 frame_id, 46 int render_frame_id,
47 bool should_replace_current_entry) 47 bool should_replace_current_entry)
48 : render_view_id(render_view_id), 48 : render_view_id(render_view_id),
49 global_request_id(global_request_id), 49 global_request_id(global_request_id),
50 is_transfer(is_transfer), 50 is_transfer(is_transfer),
51 transfer_url_chain(transfer_url_chain), 51 transfer_url_chain(transfer_url_chain),
52 referrer(referrer), 52 referrer(referrer),
53 page_transition(page_transition), 53 page_transition(page_transition),
54 frame_id(frame_id), 54 render_frame_id(render_frame_id),
55 should_replace_current_entry(should_replace_current_entry) { 55 should_replace_current_entry(should_replace_current_entry) {
56 } 56 }
57 57
58 int render_view_id; 58 int render_view_id;
59 GlobalRequestID global_request_id; 59 GlobalRequestID global_request_id;
60 bool is_transfer; 60 bool is_transfer;
61 std::vector<GURL> transfer_url_chain; 61 std::vector<GURL> transfer_url_chain;
62 Referrer referrer; 62 Referrer referrer;
63 PageTransition page_transition; 63 PageTransition page_transition;
64 int64 frame_id; 64 int render_frame_id;
65 bool should_replace_current_entry; 65 bool should_replace_current_entry;
66 }; 66 };
67 67
68 void OnCrossSiteResponseHelper(const CrossSiteResponseParams& params) { 68 void OnCrossSiteResponseHelper(const CrossSiteResponseParams& params) {
69 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request; 69 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request;
70 if (params.is_transfer) { 70 if (params.is_transfer) {
71 cross_site_transferring_request.reset(new CrossSiteTransferringRequest( 71 cross_site_transferring_request.reset(new CrossSiteTransferringRequest(
72 params.global_request_id)); 72 params.global_request_id));
73 } 73 }
74 74
75 RenderViewHostImpl* rvh = 75 RenderViewHostImpl* rvh =
76 RenderViewHostImpl::FromID(params.global_request_id.child_id, 76 RenderViewHostImpl::FromID(params.global_request_id.child_id,
77 params.render_view_id); 77 params.render_view_id);
78 if (rvh) { 78 if (rvh) {
79 rvh->OnCrossSiteResponse( 79 rvh->OnCrossSiteResponse(
80 params.global_request_id, cross_site_transferring_request.Pass(), 80 params.global_request_id, cross_site_transferring_request.Pass(),
81 params.transfer_url_chain, params.referrer, 81 params.transfer_url_chain, params.referrer,
82 params.page_transition, params.frame_id, 82 params.page_transition, params.render_frame_id,
83 params.should_replace_current_entry); 83 params.should_replace_current_entry);
84 } else if (leak_requests_for_testing_ && cross_site_transferring_request) { 84 } else if (leak_requests_for_testing_ && cross_site_transferring_request) {
85 // Some unit tests expect requests to be leaked in this case, so they can 85 // Some unit tests expect requests to be leaked in this case, so they can
86 // pass them along manually. 86 // pass them along manually.
87 cross_site_transferring_request->ReleaseRequest(); 87 cross_site_transferring_request->ReleaseRequest();
88 } 88 }
89 } 89 }
90 90
91 } // namespace 91 } // namespace
92 92
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 GlobalRequestID global_id(info->GetChildID(), info->GetRequestID()); 300 GlobalRequestID global_id(info->GetChildID(), info->GetRequestID());
301 301
302 // Tell the contents responsible for this request that a cross-site response 302 // Tell the contents responsible for this request that a cross-site response
303 // is starting, so that it can tell its old renderer to run its onunload 303 // is starting, so that it can tell its old renderer to run its onunload
304 // handler now. We will wait until the unload is finished and (if a transfer 304 // handler now. We will wait until the unload is finished and (if a transfer
305 // is needed) for the new renderer's request to arrive. 305 // is needed) for the new renderer's request to arrive.
306 // The |transfer_url_chain| contains any redirect URLs that have already 306 // The |transfer_url_chain| contains any redirect URLs that have already
307 // occurred, plus the destination URL at the end. 307 // occurred, plus the destination URL at the end.
308 std::vector<GURL> transfer_url_chain; 308 std::vector<GURL> transfer_url_chain;
309 Referrer referrer; 309 Referrer referrer;
310 int frame_id = -1; 310 int render_frame_id = -1;
311 if (should_transfer) { 311 if (should_transfer) {
312 transfer_url_chain = request()->url_chain(); 312 transfer_url_chain = request()->url_chain();
313 referrer = Referrer(GURL(request()->referrer()), info->GetReferrerPolicy()); 313 referrer = Referrer(GURL(request()->referrer()), info->GetReferrerPolicy());
314 frame_id = info->GetFrameID(); 314 render_frame_id = info->GetRenderFrameID();
315 315
316 appcache::AppCacheInterceptor::PrepareForCrossSiteTransfer( 316 appcache::AppCacheInterceptor::PrepareForCrossSiteTransfer(
317 request(), global_id.child_id); 317 request(), global_id.child_id);
318 ResourceDispatcherHostImpl::Get()->MarkAsTransferredNavigation(global_id); 318 ResourceDispatcherHostImpl::Get()->MarkAsTransferredNavigation(global_id);
319 } 319 }
320 BrowserThread::PostTask( 320 BrowserThread::PostTask(
321 BrowserThread::UI, 321 BrowserThread::UI,
322 FROM_HERE, 322 FROM_HERE,
323 base::Bind( 323 base::Bind(
324 &OnCrossSiteResponseHelper, 324 &OnCrossSiteResponseHelper,
325 CrossSiteResponseParams(info->GetRouteID(), 325 CrossSiteResponseParams(info->GetRouteID(),
326 global_id, 326 global_id,
327 should_transfer, 327 should_transfer,
328 transfer_url_chain, 328 transfer_url_chain,
329 referrer, 329 referrer,
330 info->GetPageTransition(), 330 info->GetPageTransition(),
331 frame_id, 331 render_frame_id,
332 info->should_replace_current_entry()))); 332 info->should_replace_current_entry())));
333 } 333 }
334 334
335 void CrossSiteResourceHandler::ResumeIfDeferred() { 335 void CrossSiteResourceHandler::ResumeIfDeferred() {
336 if (did_defer_) { 336 if (did_defer_) {
337 request()->LogUnblocked(); 337 request()->LogUnblocked();
338 did_defer_ = false; 338 did_defer_ = false;
339 controller()->Resume(); 339 controller()->Resume();
340 } 340 }
341 } 341 }
342 342
343 void CrossSiteResourceHandler::OnDidDefer() { 343 void CrossSiteResourceHandler::OnDidDefer() {
344 did_defer_ = true; 344 did_defer_ = true;
345 request()->LogBlockedBy("CrossSiteResourceHandler"); 345 request()->LogBlockedBy("CrossSiteResourceHandler");
346 } 346 }
347 347
348 } // namespace content 348 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/web_request/web_request_api.cc ('k') | content/browser/loader/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698