| OLD | NEW |
| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 | 234 |
| 235 bool CrossSiteResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { | 235 bool CrossSiteResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { |
| 236 CHECK(!in_cross_site_transition_); | 236 CHECK(!in_cross_site_transition_); |
| 237 return next_handler_->OnReadCompleted(bytes_read, defer); | 237 return next_handler_->OnReadCompleted(bytes_read, defer); |
| 238 } | 238 } |
| 239 | 239 |
| 240 void CrossSiteResourceHandler::OnResponseCompleted( | 240 void CrossSiteResourceHandler::OnResponseCompleted( |
| 241 const net::URLRequestStatus& status, | 241 const net::URLRequestStatus& status, |
| 242 const std::string& security_info, | |
| 243 bool* defer) { | 242 bool* defer) { |
| 244 if (!in_cross_site_transition_) { | 243 if (!in_cross_site_transition_) { |
| 245 // If we're not transferring, then we should pass this through. | 244 // If we're not transferring, then we should pass this through. |
| 246 next_handler_->OnResponseCompleted(status, security_info, defer); | 245 next_handler_->OnResponseCompleted(status, defer); |
| 247 return; | 246 return; |
| 248 } | 247 } |
| 249 | 248 |
| 250 // We have to buffer the call until after the transition completes. | 249 // We have to buffer the call until after the transition completes. |
| 251 completed_during_transition_ = true; | 250 completed_during_transition_ = true; |
| 252 completed_status_ = status; | 251 completed_status_ = status; |
| 253 completed_security_info_ = security_info; | |
| 254 | 252 |
| 255 // Defer to tell RDH not to notify the world or clean up the pending request. | 253 // Defer to tell RDH not to notify the world or clean up the pending request. |
| 256 // We will do so in ResumeResponse. | 254 // We will do so in ResumeResponse. |
| 257 *defer = true; | 255 *defer = true; |
| 258 OnDidDefer(); | 256 OnDidDefer(); |
| 259 } | 257 } |
| 260 | 258 |
| 261 // We can now send the response to the new renderer, which will cause | 259 // We can now send the response to the new renderer, which will cause |
| 262 // WebContentsImpl to swap in the new renderer and destroy the old one. | 260 // WebContentsImpl to swap in the new renderer and destroy the old one. |
| 263 void CrossSiteResourceHandler::ResumeResponse() { | 261 void CrossSiteResourceHandler::ResumeResponse() { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 281 } | 279 } |
| 282 | 280 |
| 283 // Remove ourselves from the ExtraRequestInfo. | 281 // Remove ourselves from the ExtraRequestInfo. |
| 284 info->set_cross_site_handler(NULL); | 282 info->set_cross_site_handler(NULL); |
| 285 | 283 |
| 286 // If the response completed during the transition, notify the next | 284 // If the response completed during the transition, notify the next |
| 287 // event handler. | 285 // event handler. |
| 288 if (completed_during_transition_) { | 286 if (completed_during_transition_) { |
| 289 bool defer = false; | 287 bool defer = false; |
| 290 next_handler_->OnResponseCompleted(completed_status_, | 288 next_handler_->OnResponseCompleted(completed_status_, |
| 291 completed_security_info_, | |
| 292 &defer); | 289 &defer); |
| 293 if (!defer) | 290 if (!defer) |
| 294 ResumeIfDeferred(); | 291 ResumeIfDeferred(); |
| 295 } | 292 } |
| 296 } | 293 } |
| 297 | 294 |
| 298 // static | 295 // static |
| 299 void CrossSiteResourceHandler::SetLeakRequestsForTesting( | 296 void CrossSiteResourceHandler::SetLeakRequestsForTesting( |
| 300 bool leak_requests_for_testing) { | 297 bool leak_requests_for_testing) { |
| 301 leak_requests_for_testing_ = leak_requests_for_testing; | 298 leak_requests_for_testing_ = leak_requests_for_testing; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 controller()->Resume(); | 379 controller()->Resume(); |
| 383 } | 380 } |
| 384 } | 381 } |
| 385 | 382 |
| 386 void CrossSiteResourceHandler::OnDidDefer() { | 383 void CrossSiteResourceHandler::OnDidDefer() { |
| 387 did_defer_ = true; | 384 did_defer_ = true; |
| 388 request()->LogBlockedBy("CrossSiteResourceHandler"); | 385 request()->LogBlockedBy("CrossSiteResourceHandler"); |
| 389 } | 386 } |
| 390 | 387 |
| 391 } // namespace content | 388 } // namespace content |
| OLD | NEW |