Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Side by Side Diff: chrome/browser/download/chrome_download_manager_delegate.cc

Issue 2623313002: Use TaskScheduler instead of blocking pool in chrome_download_manager_delegate.cc. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/download/chrome_download_manager_delegate.h" 5 #include "chrome/browser/download/chrome_download_manager_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/rand_util.h" 15 #include "base/rand_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/task_runner.h" 17 #include "base/task_runner.h"
18 #include "base/task_runner_util.h" 18 #include "base/task_scheduler/post_task.h"
19 #include "base/threading/sequenced_worker_pool.h" 19 #include "base/threading/sequenced_worker_pool.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/download/download_completion_blocker.h" 23 #include "chrome/browser/download/download_completion_blocker.h"
24 #include "chrome/browser/download/download_crx_util.h" 24 #include "chrome/browser/download/download_crx_util.h"
25 #include "chrome/browser/download/download_file_picker.h" 25 #include "chrome/browser/download/download_file_picker.h"
26 #include "chrome/browser/download/download_history.h" 26 #include "chrome/browser/download/download_history.h"
27 #include "chrome/browser/download/download_item_model.h" 27 #include "chrome/browser/download/download_item_model.h"
28 #include "chrome/browser/download/download_path_reservation_tracker.h" 28 #include "chrome/browser/download/download_path_reservation_tracker.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } else { 169 } else {
170 // If the URL is malicious, we'll use that as the danger type. The results 170 // If the URL is malicious, we'll use that as the danger type. The results
171 // of the content check, if one is performed, will be ignored. 171 // of the content check, if one is performed, will be ignored.
172 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL; 172 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL;
173 } 173 }
174 callback.Run(danger_type); 174 callback.Run(danger_type);
175 } 175 }
176 176
177 #endif // FULL_SAFE_BROWSING 177 #endif // FULL_SAFE_BROWSING
178 178
179 // Called on the blocking pool to determine the MIME type for |path|. 179 // Called asynchronously to determine the MIME type for |path|.
180 std::string GetMimeType(const base::FilePath& path) { 180 std::string GetMimeType(const base::FilePath& path) {
181 std::string mime_type; 181 std::string mime_type;
182 net::GetMimeTypeFromFile(path, &mime_type); 182 net::GetMimeTypeFromFile(path, &mime_type);
183 return mime_type; 183 return mime_type;
184 } 184 }
185 185
186 // Reason for why danger type is DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE. 186 // Reason for why danger type is DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE.
187 // Used by "Download.DangerousFile.Reason" UMA metric. 187 // Used by "Download.DangerousFile.Reason" UMA metric.
188 // Do not change the ordering or remove items. 188 // Do not change the ordering or remove items.
189 enum DangerousFileReason { 189 enum DangerousFileReason {
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 return; 669 return;
670 } 670 }
671 #endif 671 #endif
672 callback.Run(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS); 672 callback.Run(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
673 } 673 }
674 674
675 void ChromeDownloadManagerDelegate::GetFileMimeType( 675 void ChromeDownloadManagerDelegate::GetFileMimeType(
676 const base::FilePath& path, 676 const base::FilePath& path,
677 const GetFileMimeTypeCallback& callback) { 677 const GetFileMimeTypeCallback& callback) {
678 DCHECK_CURRENTLY_ON(BrowserThread::UI); 678 DCHECK_CURRENTLY_ON(BrowserThread::UI);
679 base::PostTaskAndReplyWithResult(BrowserThread::GetBlockingPool(), 679 base::PostTaskWithTraitsAndReplyWithResult(
680 FROM_HERE, 680 FROM_HERE, base::TaskTraits().MayBlock(), base::Bind(&GetMimeType, path),
681 base::Bind(&GetMimeType, path), 681 callback);
682 callback);
683 } 682 }
684 683
685 #if defined(FULL_SAFE_BROWSING) 684 #if defined(FULL_SAFE_BROWSING)
686 void ChromeDownloadManagerDelegate::CheckClientDownloadDone( 685 void ChromeDownloadManagerDelegate::CheckClientDownloadDone(
687 uint32_t download_id, 686 uint32_t download_id,
688 DownloadProtectionService::DownloadCheckResult result) { 687 DownloadProtectionService::DownloadCheckResult result) {
689 DownloadItem* item = download_manager_->GetDownload(download_id); 688 DownloadItem* item = download_manager_->GetDownload(download_id);
690 if (!item || (item->GetState() != DownloadItem::IN_PROGRESS)) 689 if (!item || (item->GetState() != DownloadItem::IN_PROGRESS))
691 return; 690 return;
692 691
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || 812 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) ||
814 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || 813 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) ||
815 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || 814 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) ||
816 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || 815 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) ||
817 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { 816 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) {
818 return true; 817 return true;
819 } 818 }
820 #endif 819 #endif
821 return false; 820 return false;
822 } 821 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698