| 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/download/download_resource_handler.h" | 5 #include "content/browser/download/download_resource_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "content/browser/byte_stream.h" | 14 #include "content/browser/byte_stream.h" |
| 15 #include "content/browser/download/download_create_info.h" | 15 #include "content/browser/download/download_create_info.h" |
| 16 #include "content/browser/download/download_interrupt_reasons_impl.h" | 16 #include "content/browser/download/download_interrupt_reasons_impl.h" |
| 17 #include "content/browser/download/download_manager_impl.h" | 17 #include "content/browser/download/download_manager_impl.h" |
| 18 #include "content/browser/download/download_request_handle.h" | 18 #include "content/browser/download/download_request_handle.h" |
| 19 #include "content/browser/download/download_task_runner.h" |
| 19 #include "content/browser/frame_host/frame_tree_node.h" | 20 #include "content/browser/frame_host/frame_tree_node.h" |
| 20 #include "content/browser/loader/resource_controller.h" | 21 #include "content/browser/loader/resource_controller.h" |
| 21 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 22 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 22 #include "content/browser/loader/resource_request_info_impl.h" | 23 #include "content/browser/loader/resource_request_info_impl.h" |
| 23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/download_interrupt_reasons.h" | 25 #include "content/public/browser/download_interrupt_reasons.h" |
| 25 #include "content/public/browser/navigation_entry.h" | 26 #include "content/public/browser/navigation_entry.h" |
| 26 #include "content/public/browser/render_frame_host.h" | 27 #include "content/public/browser/render_frame_host.h" |
| 27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/common/browser_side_navigation_policy.h" | 29 #include "content/public/common/browser_side_navigation_policy.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 64 |
| 64 DownloadManager* download_manager = | 65 DownloadManager* download_manager = |
| 65 info->request_handle->GetDownloadManager(); | 66 info->request_handle->GetDownloadManager(); |
| 66 if (!download_manager || !frame_host) { | 67 if (!download_manager || !frame_host) { |
| 67 // NULL in unittests or if the page closed right after starting the | 68 // NULL in unittests or if the page closed right after starting the |
| 68 // download. | 69 // download. |
| 69 if (!started_cb.is_null()) | 70 if (!started_cb.is_null()) |
| 70 started_cb.Run(nullptr, DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); | 71 started_cb.Run(nullptr, DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); |
| 71 | 72 |
| 72 if (stream) | 73 if (stream) |
| 73 BrowserThread::DeleteSoon(BrowserThread::FILE, FROM_HERE, | 74 GetDownloadTaskRunner()->DeleteSoon(FROM_HERE, stream.release()); |
| 74 stream.release()); | |
| 75 return; | 75 return; |
| 76 } | 76 } |
| 77 | 77 |
| 78 info->tab_url = tab_info->tab_url; | 78 info->tab_url = tab_info->tab_url; |
| 79 info->tab_referrer_url = tab_info->tab_referrer_url; | 79 info->tab_referrer_url = tab_info->tab_referrer_url; |
| 80 info->site_url = frame_host->GetSiteInstance()->GetSiteURL(); | 80 info->site_url = frame_host->GetSiteInstance()->GetSiteURL(); |
| 81 | 81 |
| 82 download_manager->StartDownload(std::move(info), std::move(stream), | 82 download_manager->StartDownload(std::move(info), std::move(stream), |
| 83 started_cb); | 83 started_cb); |
| 84 } | 84 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 " }", | 282 " }", |
| 283 request() ? | 283 request() ? |
| 284 request()->url().spec().c_str() : | 284 request()->url().spec().c_str() : |
| 285 "<NULL request>", | 285 "<NULL request>", |
| 286 info->GetChildID(), | 286 info->GetChildID(), |
| 287 info->GetRequestID(), | 287 info->GetRequestID(), |
| 288 info->GetRouteID()); | 288 info->GetRouteID()); |
| 289 } | 289 } |
| 290 | 290 |
| 291 } // namespace content | 291 } // namespace content |
| OLD | NEW |