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

Side by Side Diff: content/browser/renderer_host/buffered_resource_handler.cc

Issue 10640019: Remove the HANDLED_EXTERNALLY status code. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: revert removing DCHECK from URLRequest::DoCancel Created 8 years, 4 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 (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/renderer_host/buffered_resource_handler.h" 5 #include "content/browser/renderer_host/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"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "content/browser/download/download_resource_handler.h" 13 #include "content/browser/download/download_resource_handler.h"
14 #include "content/browser/download/download_stats.h" 14 #include "content/browser/download/download_stats.h"
15 #include "content/browser/plugin_service_impl.h" 15 #include "content/browser/plugin_service_impl.h"
16 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" 16 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
17 #include "content/browser/renderer_host/resource_request_info_impl.h" 17 #include "content/browser/renderer_host/resource_request_info_impl.h"
18 #include "content/browser/renderer_host/resource_request_info_impl.h"
18 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" 19 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/content_browser_client.h" 21 #include "content/public/browser/content_browser_client.h"
21 #include "content/public/browser/download_save_info.h" 22 #include "content/public/browser/download_save_info.h"
22 #include "content/public/browser/resource_context.h" 23 #include "content/public/browser/resource_context.h"
23 #include "content/public/browser/resource_dispatcher_host_delegate.h" 24 #include "content/public/browser/resource_dispatcher_host_delegate.h"
24 #include "content/public/common/resource_response.h" 25 #include "content/public/common/resource_response.h"
25 #include "net/base/io_buffer.h" 26 #include "net/base/io_buffer.h"
26 #include "net/base/mime_sniffer.h" 27 #include "net/base/mime_sniffer.h"
27 #include "net/base/mime_util.h" 28 #include "net/base/mime_util.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 case STATE_STREAMING: 204 case STATE_STREAMING:
204 controller()->Resume(); 205 controller()->Resume();
205 break; 206 break;
206 } 207 }
207 } 208 }
208 209
209 void BufferedResourceHandler::Cancel() { 210 void BufferedResourceHandler::Cancel() {
210 controller()->Cancel(); 211 controller()->Cancel();
211 } 212 }
212 213
214 void BufferedResourceHandler::CancelWithError(int error) {
215 controller()->CancelWithError(error);
216 }
217
218 void BufferedResourceHandler::HandledExternally() {
219 controller()->HandledExternally();
220 }
221
213 bool BufferedResourceHandler::ProcessResponse(bool* defer) { 222 bool BufferedResourceHandler::ProcessResponse(bool* defer) {
214 DCHECK_EQ(STATE_PROCESSING, state_); 223 DCHECK_EQ(STATE_PROCESSING, state_);
215 224
216 // TODO(darin): Stop special-casing 304 responses. 225 // TODO(darin): Stop special-casing 304 responses.
217 if (!(response_->head.headers && 226 if (!(response_->head.headers &&
218 response_->head.headers->response_code() == 304)) { 227 response_->head.headers->response_code() == 304)) {
219 if (!SelectNextHandler(defer)) 228 if (!SelectNextHandler(defer))
220 return false; 229 return false;
221 if (*defer) 230 if (*defer)
222 return true; 231 return true;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 351 }
343 352
344 int request_id = ResourceRequestInfo::ForRequest(request_)->GetRequestID(); 353 int request_id = ResourceRequestInfo::ForRequest(request_)->GetRequestID();
345 354
346 // Inform the original ResourceHandler that this will be handled entirely by 355 // Inform the original ResourceHandler that this will be handled entirely by
347 // the new ResourceHandler. 356 // the new ResourceHandler.
348 // TODO(darin): We should probably check the return values of these. 357 // TODO(darin): We should probably check the return values of these.
349 bool defer_ignored = false; 358 bool defer_ignored = false;
350 next_handler_->OnResponseStarted(request_id, response_, &defer_ignored); 359 next_handler_->OnResponseStarted(request_id, response_, &defer_ignored);
351 DCHECK(!defer_ignored); 360 DCHECK(!defer_ignored);
352 net::URLRequestStatus status(net::URLRequestStatus::HANDLED_EXTERNALLY, 0); 361 net::URLRequestStatus status(net::URLRequestStatus::CANCELED,
362 net::ERR_ABORTED);
363 ResourceRequestInfoImpl* info =
364 ResourceRequestInfoImpl::ForRequest(request_);
365 info->set_handled_externally(true);
353 next_handler_->OnResponseCompleted(request_id, status, std::string()); 366 next_handler_->OnResponseCompleted(request_id, status, std::string());
354 367
355 // This is handled entirely within the new ResourceHandler, so just reset the 368 // This is handled entirely within the new ResourceHandler, so just reset the
356 // original ResourceHandler. 369 // original ResourceHandler.
357 next_handler_ = new_handler.Pass(); 370 next_handler_ = new_handler.Pass();
358 next_handler_->SetController(this); 371 next_handler_->SetController(this);
359 372
360 return CopyReadBufferToNextHandler(request_id); 373 return CopyReadBufferToNextHandler(request_id);
361 } 374 }
362 375
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 const std::vector<webkit::WebPluginInfo>& plugins) { 449 const std::vector<webkit::WebPluginInfo>& plugins) {
437 bool defer = false; 450 bool defer = false;
438 if (!ProcessResponse(&defer)) { 451 if (!ProcessResponse(&defer)) {
439 controller()->Cancel(); 452 controller()->Cancel();
440 } else if (!defer) { 453 } else if (!defer) {
441 controller()->Resume(); 454 controller()->Resume();
442 } 455 }
443 } 456 }
444 457
445 } // namespace content 458 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698