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