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 "content/browser/browser_thread.h" | 12 #include "content/browser/browser_thread.h" |
13 #include "content/browser/content_browser_client.h" | 13 #include "content/browser/content_browser_client.h" |
14 #include "content/browser/download/download_resource_handler.h" | 14 #include "content/browser/download/download_resource_handler.h" |
15 #include "content/browser/plugin_service.h" | 15 #include "content/browser/plugin_service.h" |
16 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 16 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
17 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" | 17 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" |
18 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 18 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
19 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" | 19 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" |
| 20 #include "content/browser/resource_context.h" |
20 #include "content/common/resource_response.h" | 21 #include "content/common/resource_response.h" |
21 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
22 #include "net/base/mime_sniffer.h" | 23 #include "net/base/mime_sniffer.h" |
23 #include "net/base/mime_util.h" | 24 #include "net/base/mime_util.h" |
24 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
25 #include "net/http/http_response_headers.h" | 26 #include "net/http/http_response_headers.h" |
26 #include "webkit/plugins/npapi/plugin_list.h" | 27 #include "webkit/plugins/npapi/plugin_list.h" |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 // know how to display the content. We follow Firefox here and show our | 303 // know how to display the content. We follow Firefox here and show our |
303 // own error page instead of triggering a download. | 304 // own error page instead of triggering a download. |
304 // TODO(abarth): We should abstract the response_code test, but this kind | 305 // TODO(abarth): We should abstract the response_code test, but this kind |
305 // of check is scattered throughout our codebase. | 306 // of check is scattered throughout our codebase. |
306 request_->SimulateError(net::ERR_FILE_NOT_FOUND); | 307 request_->SimulateError(net::ERR_FILE_NOT_FOUND); |
307 return false; | 308 return false; |
308 } | 309 } |
309 | 310 |
310 info->set_is_download(true); | 311 info->set_is_download(true); |
311 | 312 |
| 313 DownloadId dl_id = info->context()->next_download_id_thunk().Run(); |
| 314 |
312 scoped_refptr<ResourceHandler> handler( | 315 scoped_refptr<ResourceHandler> handler( |
313 new DownloadResourceHandler(host_, | 316 new DownloadResourceHandler(host_, |
314 info->child_id(), | 317 info->child_id(), |
315 info->route_id(), | 318 info->route_id(), |
316 info->request_id(), | 319 info->request_id(), |
317 request_->url(), | 320 request_->url(), |
| 321 dl_id, |
318 host_->download_file_manager(), | 322 host_->download_file_manager(), |
319 request_, | 323 request_, |
320 false, | 324 false, |
321 DownloadResourceHandler::OnStartedCallback(), | 325 DownloadResourceHandler::OnStartedCallback(), |
322 DownloadSaveInfo())); | 326 DownloadSaveInfo())); |
323 | 327 |
324 if (host_->delegate()) { | 328 if (host_->delegate()) { |
325 handler = host_->delegate()->DownloadStarting( | 329 handler = host_->delegate()->DownloadStarting( |
326 handler, *info->context(), request_, info->child_id(), | 330 handler, *info->context(), request_, info->child_id(), |
327 info->route_id(), info->request_id(), false, in_complete); | 331 info->route_id(), info->request_id(), false, in_complete); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 wait_for_plugins_ = false; | 468 wait_for_plugins_ = false; |
465 if (!request_) | 469 if (!request_) |
466 return; | 470 return; |
467 | 471 |
468 ResourceDispatcherHostRequestInfo* info = | 472 ResourceDispatcherHostRequestInfo* info = |
469 ResourceDispatcherHost::InfoForRequest(request_); | 473 ResourceDispatcherHost::InfoForRequest(request_); |
470 host_->PauseRequest(info->child_id(), info->request_id(), false); | 474 host_->PauseRequest(info->child_id(), info->request_id(), false); |
471 if (!CompleteResponseStarted(info->request_id(), false)) | 475 if (!CompleteResponseStarted(info->request_id(), false)) |
472 host_->CancelRequest(info->child_id(), info->request_id(), false); | 476 host_->CancelRequest(info->child_id(), info->request_id(), false); |
473 } | 477 } |
OLD | NEW |