OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" | |
13 #include "content/browser/browser_thread.h" | 12 #include "content/browser/browser_thread.h" |
14 #include "content/browser/content_browser_client.h" | 13 #include "content/browser/content_browser_client.h" |
14 #include "content/browser/download/download_resource_handler.h" | |
15 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 15 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
16 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" | 16 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" |
17 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 17 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
18 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" | 18 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" |
19 #include "content/common/resource_response.h" | 19 #include "content/common/resource_response.h" |
20 #include "net/base/io_buffer.h" | 20 #include "net/base/io_buffer.h" |
21 #include "net/base/mime_sniffer.h" | 21 #include "net/base/mime_sniffer.h" |
22 #include "net/base/mime_util.h" | 22 #include "net/base/mime_util.h" |
23 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
24 #include "net/http/http_response_headers.h" | 24 #include "net/http/http_response_headers.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 // know how to display the content. We follow Firefox here and show our | 301 // know how to display the content. We follow Firefox here and show our |
302 // own error page instead of triggering a download. | 302 // own error page instead of triggering a download. |
303 // TODO(abarth): We should abstract the response_code test, but this kind | 303 // TODO(abarth): We should abstract the response_code test, but this kind |
304 // of check is scattered throughout our codebase. | 304 // of check is scattered throughout our codebase. |
305 request_->SimulateError(net::ERR_FILE_NOT_FOUND); | 305 request_->SimulateError(net::ERR_FILE_NOT_FOUND); |
306 return false; | 306 return false; |
307 } | 307 } |
308 | 308 |
309 info->set_is_download(true); | 309 info->set_is_download(true); |
310 | 310 |
311 DownloadThrottlingResourceHandler* download_handler = | 311 scoped_refptr<ResourceHandler> handler( |
Paweł Hajdan Jr.
2011/08/16 17:14:08
This is a bit suspicious to me: previously this wa
jam
2011/08/16 18:18:20
this is fine as well, we use this pattern in other
| |
312 new DownloadThrottlingResourceHandler(host_, | 312 new DownloadResourceHandler(host_, |
313 request_, | 313 info->child_id(), |
314 request_->url(), | 314 info->route_id(), |
315 info->child_id(), | 315 info->request_id(), |
316 info->route_id(), | 316 request_->url(), |
317 request_id, | 317 host_->download_file_manager(), |
318 in_complete); | 318 request_, |
319 UseAlternateResourceHandler(request_id, download_handler); | 319 false, |
320 DownloadSaveInfo())); | |
321 | |
322 if (host_->delegate()) { | |
323 handler = host_->delegate()->DownloadStarting( | |
324 handler, *info->context(), request_, info->child_id(), | |
325 info->route_id(), info->request_id(), false, in_complete); | |
326 } | |
327 | |
328 UseAlternateResourceHandler(request_id, handler); | |
320 } | 329 } |
321 return real_handler_->OnResponseStarted(request_id, response_); | 330 return real_handler_->OnResponseStarted(request_id, response_); |
322 } | 331 } |
323 | 332 |
324 bool BufferedResourceHandler::ShouldWaitForPlugins() { | 333 bool BufferedResourceHandler::ShouldWaitForPlugins() { |
325 bool need_plugin_list; | 334 bool need_plugin_list; |
326 if (!ShouldDownload(&need_plugin_list) || !need_plugin_list) | 335 if (!ShouldDownload(&need_plugin_list) || !need_plugin_list) |
327 return false; | 336 return false; |
328 | 337 |
329 // We don't want to keep buffering as our buffer will fill up. | 338 // We don't want to keep buffering as our buffer will fill up. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 wait_for_plugins_ = false; | 461 wait_for_plugins_ = false; |
453 if (!request_) | 462 if (!request_) |
454 return; | 463 return; |
455 | 464 |
456 ResourceDispatcherHostRequestInfo* info = | 465 ResourceDispatcherHostRequestInfo* info = |
457 ResourceDispatcherHost::InfoForRequest(request_); | 466 ResourceDispatcherHost::InfoForRequest(request_); |
458 host_->PauseRequest(info->child_id(), info->request_id(), false); | 467 host_->PauseRequest(info->child_id(), info->request_id(), false); |
459 if (!CompleteResponseStarted(info->request_id(), false)) | 468 if (!CompleteResponseStarted(info->request_id(), false)) |
460 host_->CancelRequest(info->child_id(), info->request_id(), false); | 469 host_->CancelRequest(info->child_id(), info->request_id(), false); |
461 } | 470 } |
OLD | NEW |