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/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_net_log_parameters.h" |
13 #include "content/browser/download/download_resource_handler.h" | 14 #include "content/browser/download/download_resource_handler.h" |
14 #include "content/browser/download/download_stats.h" | 15 #include "content/browser/download/download_stats.h" |
15 #include "content/browser/download/download_types.h" | 16 #include "content/browser/download/download_types.h" |
16 #include "content/browser/plugin_service_impl.h" | 17 #include "content/browser/plugin_service_impl.h" |
17 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 18 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
18 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 19 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
19 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" | 20 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h" |
20 #include "content/browser/resource_context.h" | 21 #include "content/browser/resource_context.h" |
21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/content_browser_client.h" | 23 #include "content/public/browser/content_browser_client.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" |
28 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
| 30 #include "net/base/net_log.h" |
29 #include "net/http/http_content_disposition.h" | 31 #include "net/http/http_content_disposition.h" |
30 #include "net/http/http_response_headers.h" | 32 #include "net/http/http_response_headers.h" |
31 #include "webkit/plugins/webplugininfo.h" | 33 #include "webkit/plugins/webplugininfo.h" |
32 | 34 |
33 namespace content { | 35 namespace content { |
34 | 36 |
35 namespace { | 37 namespace { |
36 | 38 |
37 void RecordSnifferMetrics(bool sniffing_blocked, | 39 void RecordSnifferMetrics(bool sniffing_blocked, |
38 bool we_would_like_to_sniff, | 40 bool we_would_like_to_sniff, |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 // know how to display the content. We follow Firefox here and show our | 298 // know how to display the content. We follow Firefox here and show our |
297 // own error page instead of triggering a download. | 299 // own error page instead of triggering a download. |
298 // TODO(abarth): We should abstract the response_code test, but this kind | 300 // TODO(abarth): We should abstract the response_code test, but this kind |
299 // of check is scattered throughout our codebase. | 301 // of check is scattered throughout our codebase. |
300 request_->SimulateError(net::ERR_FILE_NOT_FOUND); | 302 request_->SimulateError(net::ERR_FILE_NOT_FOUND); |
301 return false; | 303 return false; |
302 } | 304 } |
303 | 305 |
304 info->set_is_download(true); | 306 info->set_is_download(true); |
305 | 307 |
| 308 net::BoundNetLog bound_net_log = |
| 309 net::BoundNetLog::Make(request_->net_log().net_log(), |
| 310 net::NetLog::SOURCE_DOWNLOAD); |
| 311 |
| 312 bound_net_log.AddEvent( |
| 313 net::NetLog::TYPE_DOWNLOAD_URL_REQUEST, |
| 314 make_scoped_refptr(new net::NetLogSourceParameter( |
| 315 "source_dependency", |
| 316 request_->net_log().source()))); |
| 317 |
| 318 request_->net_log().AddEvent( |
| 319 net::NetLog::TYPE_DOWNLOAD_STARTED, |
| 320 make_scoped_refptr(new net::NetLogSourceParameter( |
| 321 "source_dependency", |
| 322 bound_net_log.source()))); |
| 323 |
306 scoped_refptr<ResourceHandler> handler( | 324 scoped_refptr<ResourceHandler> handler( |
307 new DownloadResourceHandler(host_, | 325 new DownloadResourceHandler(host_, |
308 info->child_id(), | 326 info->child_id(), |
309 info->route_id(), | 327 info->route_id(), |
310 info->request_id(), | 328 info->request_id(), |
311 request_->url(), | 329 request_->url(), |
| 330 bound_net_log, |
312 host_->download_file_manager(), | 331 host_->download_file_manager(), |
313 request_, | 332 request_, |
314 DownloadResourceHandler::OnStartedCallback(), | 333 DownloadResourceHandler::OnStartedCallback(), |
315 DownloadSaveInfo())); | 334 DownloadSaveInfo())); |
316 | 335 |
317 if (host_->delegate()) { | 336 if (host_->delegate()) { |
318 handler = host_->delegate()->DownloadStarting( | 337 handler = host_->delegate()->DownloadStarting( |
319 handler, *info->context(), request_, info->child_id(), | 338 handler, *info->context(), request_, info->child_id(), |
320 info->route_id(), info->request_id(), false); | 339 info->route_id(), info->request_id(), false); |
321 } | 340 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 return; | 486 return; |
468 | 487 |
469 ResourceDispatcherHostRequestInfo* info = | 488 ResourceDispatcherHostRequestInfo* info = |
470 ResourceDispatcherHost::InfoForRequest(request_); | 489 ResourceDispatcherHost::InfoForRequest(request_); |
471 host_->PauseRequest(info->child_id(), info->request_id(), false); | 490 host_->PauseRequest(info->child_id(), info->request_id(), false); |
472 if (!CompleteResponseStarted(info->request_id())) | 491 if (!CompleteResponseStarted(info->request_id())) |
473 host_->CancelRequest(info->child_id(), info->request_id(), false); | 492 host_->CancelRequest(info->child_id(), info->request_id(), false); |
474 } | 493 } |
475 | 494 |
476 } // namespace content | 495 } // namespace content |
OLD | NEW |