| 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/drag_download_file.h" | 5 #include "content/browser/download/drag_download_file.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "content/browser/download/download_stats.h" | 16 #include "content/browser/download/download_stats.h" |
| 17 #include "content/browser/web_contents/web_contents_impl.h" | 17 #include "content/browser/web_contents/web_contents_impl.h" |
| 18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/download_item.h" | 20 #include "content/public/browser/download_item.h" |
| 21 #include "content/public/browser/download_save_info.h" | 21 #include "content/public/browser/download_save_info.h" |
| 22 #include "content/public/browser/download_url_parameters.h" | 22 #include "content/public/browser/download_url_parameters.h" |
| 23 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 typedef base::Callback<void(bool)> OnCompleted; | 29 typedef base::Callback<void(bool)> OnCompleted; |
| 29 | 30 |
| 30 } // namespace | 31 } // namespace |
| 31 | 32 |
| 32 // On windows, DragDownloadFile runs on a thread other than the UI thread. | 33 // On windows, DragDownloadFile runs on a thread other than the UI thread. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 std::unique_ptr<content::DownloadUrlParameters> params( | 71 std::unique_ptr<content::DownloadUrlParameters> params( |
| 71 DownloadUrlParameters::CreateForWebContentsMainFrame( | 72 DownloadUrlParameters::CreateForWebContentsMainFrame( |
| 72 web_contents_, url_)); | 73 web_contents_, url_)); |
| 73 params->set_referrer(referrer_); | 74 params->set_referrer(referrer_); |
| 74 params->set_referrer_encoding(referrer_encoding_); | 75 params->set_referrer_encoding(referrer_encoding_); |
| 75 params->set_callback(base::Bind(&DragDownloadFileUI::OnDownloadStarted, | 76 params->set_callback(base::Bind(&DragDownloadFileUI::OnDownloadStarted, |
| 76 weak_ptr_factory_.GetWeakPtr())); | 77 weak_ptr_factory_.GetWeakPtr())); |
| 77 params->set_file_path(file_path); | 78 params->set_file_path(file_path); |
| 78 params->set_file(std::move(file)); // Nulls file. | 79 params->set_file(std::move(file)); // Nulls file. |
| 79 BrowserContext::GetDownloadManager(web_contents_->GetBrowserContext()) | 80 BrowserContext::GetDownloadManager(web_contents_->GetBrowserContext()) |
| 80 ->DownloadUrl(std::move(params)); | 81 ->DownloadUrl(std::move(params), NO_TRAFFIC_ANNOTATION_YET); |
| 81 } | 82 } |
| 82 | 83 |
| 83 void Cancel() { | 84 void Cancel() { |
| 84 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 85 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 85 if (download_item_) | 86 if (download_item_) |
| 86 download_item_->Cancel(true); | 87 download_item_->Cancel(true); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void Delete() { | 90 void Delete() { |
| 90 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 91 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 242 |
| 242 void DragDownloadFile::CheckThread() { | 243 void DragDownloadFile::CheckThread() { |
| 243 #if defined(OS_WIN) | 244 #if defined(OS_WIN) |
| 244 DCHECK(drag_task_runner_->BelongsToCurrentThread()); | 245 DCHECK(drag_task_runner_->BelongsToCurrentThread()); |
| 245 #else | 246 #else |
| 246 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 247 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 247 #endif | 248 #endif |
| 248 } | 249 } |
| 249 | 250 |
| 250 } // namespace content | 251 } // namespace content |
| OLD | NEW |