Chromium Code Reviews| 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/buffered_resource_handler.h" | 5 #include "content/browser/loader/buffered_resource_handler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 } | 300 } |
| 301 | 301 |
| 302 bool BufferedResourceHandler::SelectNextHandler(bool* defer) { | 302 bool BufferedResourceHandler::SelectNextHandler(bool* defer) { |
| 303 DCHECK(!response_->head.mime_type.empty()); | 303 DCHECK(!response_->head.mime_type.empty()); |
| 304 | 304 |
| 305 ResourceRequestInfoImpl* info = GetRequestInfo(); | 305 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 306 const std::string& mime_type = response_->head.mime_type; | 306 const std::string& mime_type = response_->head.mime_type; |
| 307 | 307 |
| 308 if (net::IsSupportedCertificateMimeType(mime_type)) { | 308 if (net::IsSupportedCertificateMimeType(mime_type)) { |
| 309 // Install certificate file. | 309 // Install certificate file. |
| 310 info->set_is_download(true); | |
| 310 scoped_ptr<ResourceHandler> handler( | 311 scoped_ptr<ResourceHandler> handler( |
| 311 new CertificateResourceHandler(request())); | 312 new CertificateResourceHandler(request())); |
| 312 return UseAlternateNextHandler(handler.Pass()); | 313 return UseAlternateNextHandler(handler.Pass()); |
| 313 } | 314 } |
| 314 | 315 |
| 315 if (!info->allow_download()) | 316 if (!info->allow_download()) |
| 316 return true; | 317 return true; |
| 317 | 318 |
| 318 bool must_download = MustDownload(); | 319 bool must_download = MustDownload(); |
| 319 if (!must_download) { | 320 if (!must_download) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 // of check is scattered throughout our codebase. | 366 // of check is scattered throughout our codebase. |
| 366 request()->CancelWithError(net::ERR_FILE_NOT_FOUND); | 367 request()->CancelWithError(net::ERR_FILE_NOT_FOUND); |
| 367 return false; | 368 return false; |
| 368 } | 369 } |
| 369 | 370 |
| 370 int request_id = GetRequestID(); | 371 int request_id = GetRequestID(); |
| 371 | 372 |
| 372 // Inform the original ResourceHandler that this will be handled entirely by | 373 // Inform the original ResourceHandler that this will be handled entirely by |
| 373 // the new ResourceHandler. | 374 // the new ResourceHandler. |
| 374 // TODO(darin): We should probably check the return values of these. | 375 // TODO(darin): We should probably check the return values of these. |
| 375 // TODO(davidben): These DCHECKs do actually trigger. | |
|
davidben
2014/02/12 19:58:56
(Removed this comment and replaced it with the oth
| |
| 376 bool defer_ignored = false; | 376 bool defer_ignored = false; |
| 377 next_handler_->OnResponseStarted(request_id, response_.get(), &defer_ignored); | 377 next_handler_->OnResponseStarted(request_id, response_.get(), &defer_ignored); |
| 378 // Although deferring OnResponseStarted is legal, the only downstream handler | |
| 379 // which does so is CrossSiteResourceHandler. Cross-site transitions should | |
| 380 // not trigger when switching handlers. | |
| 378 DCHECK(!defer_ignored); | 381 DCHECK(!defer_ignored); |
| 379 net::URLRequestStatus status(net::URLRequestStatus::CANCELED, | 382 net::URLRequestStatus status(net::URLRequestStatus::CANCELED, |
| 380 net::ERR_ABORTED); | 383 net::ERR_ABORTED); |
| 381 next_handler_->OnResponseCompleted(request_id, status, std::string(), | 384 next_handler_->OnResponseCompleted(request_id, status, std::string(), |
| 382 &defer_ignored); | 385 &defer_ignored); |
| 383 DCHECK(!defer_ignored); | 386 DCHECK(!defer_ignored); |
| 384 | 387 |
| 385 // This is handled entirely within the new ResourceHandler, so just reset the | 388 // This is handled entirely within the new ResourceHandler, so just reset the |
| 386 // original ResourceHandler. | 389 // original ResourceHandler. |
| 387 next_handler_ = new_handler.Pass(); | 390 next_handler_ = new_handler.Pass(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 const std::vector<WebPluginInfo>& plugins) { | 475 const std::vector<WebPluginInfo>& plugins) { |
| 473 bool defer = false; | 476 bool defer = false; |
| 474 if (!ProcessResponse(&defer)) { | 477 if (!ProcessResponse(&defer)) { |
| 475 controller()->Cancel(); | 478 controller()->Cancel(); |
| 476 } else if (!defer) { | 479 } else if (!defer) { |
| 477 controller()->Resume(); | 480 controller()->Resume(); |
| 478 } | 481 } |
| 479 } | 482 } |
| 480 | 483 |
| 481 } // namespace content | 484 } // namespace content |
| OLD | NEW |