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

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

Issue 2887933002: Remove usage of SequencedWorkerPool::GetNamedSequenceToken from ChromeDownloadManagerDelegate. (Closed)
Patch Set: Created 3 years, 7 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
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 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
15 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
16 #include "base/rand_util.h" 17 #include "base/rand_util.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/task_runner.h" 19 #include "base/task_runner.h"
19 #include "base/task_scheduler/post_task.h" 20 #include "base/task_scheduler/post_task.h"
20 #include "base/threading/sequenced_worker_pool.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/download/download_completion_blocker.h" 24 #include "chrome/browser/download/download_completion_blocker.h"
25 #include "chrome/browser/download/download_core_service.h" 25 #include "chrome/browser/download/download_core_service.h"
26 #include "chrome/browser/download/download_core_service_factory.h" 26 #include "chrome/browser/download/download_core_service_factory.h"
27 #include "chrome/browser/download/download_crx_util.h" 27 #include "chrome/browser/download/download_crx_util.h"
28 #include "chrome/browser/download/download_file_picker.h" 28 #include "chrome/browser/download/download_file_picker.h"
29 #include "chrome/browser/download/download_history.h" 29 #include "chrome/browser/download/download_history.h"
30 #include "chrome/browser/download/download_item_model.h" 30 #include "chrome/browser/download/download_item_model.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 const DownloadPathReservationTracker::FilenameConflictAction 205 const DownloadPathReservationTracker::FilenameConflictAction
206 kDefaultPlatformConflictAction = DownloadPathReservationTracker::UNIQUIFY; 206 kDefaultPlatformConflictAction = DownloadPathReservationTracker::UNIQUIFY;
207 #endif 207 #endif
208 208
209 } // namespace 209 } // namespace
210 210
211 ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile) 211 ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile)
212 : profile_(profile), 212 : profile_(profile),
213 next_download_id_(content::DownloadItem::kInvalidId), 213 next_download_id_(content::DownloadItem::kInvalidId),
214 download_prefs_(new DownloadPrefs(profile)), 214 download_prefs_(new DownloadPrefs(profile)),
215 weak_ptr_factory_(this) { 215 check_for_file_existence_task_runner_(
216 } 216 base::CreateSequencedTaskRunnerWithTraits(
217 {base::MayBlock(), base::TaskPriority::BACKGROUND,
218 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN})),
219 weak_ptr_factory_(this) {}
217 220
218 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { 221 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() {
219 // If a DownloadManager was set for this, Shutdown() must be called. 222 // If a DownloadManager was set for this, Shutdown() must be called.
220 DCHECK(!download_manager_); 223 DCHECK(!download_manager_);
221 } 224 }
222 225
223 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { 226 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) {
224 download_manager_ = dm; 227 download_manager_ = dm;
225 228
226 safe_browsing::SafeBrowsingService* sb_service = 229 safe_browsing::SafeBrowsingService* sb_service =
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 void ChromeDownloadManagerDelegate::ShowDownloadInShell( 529 void ChromeDownloadManagerDelegate::ShowDownloadInShell(
527 DownloadItem* download) { 530 DownloadItem* download) {
528 if (!download->CanShowInFolder()) 531 if (!download->CanShowInFolder())
529 return; 532 return;
530 base::FilePath platform_path( 533 base::FilePath platform_path(
531 GetPlatformDownloadPath(profile_, download, PLATFORM_CURRENT_PATH)); 534 GetPlatformDownloadPath(profile_, download, PLATFORM_CURRENT_PATH));
532 DCHECK(!platform_path.empty()); 535 DCHECK(!platform_path.empty());
533 platform_util::ShowItemInFolder(profile_, platform_path); 536 platform_util::ShowItemInFolder(profile_, platform_path);
534 } 537 }
535 538
539 void ContinueCheckingForFileExistence(
540 content::CheckForFileExistenceCallback callback) {
541 std::move(callback).Run(false);
542 }
543
536 void ChromeDownloadManagerDelegate::CheckForFileExistence( 544 void ChromeDownloadManagerDelegate::CheckForFileExistence(
537 DownloadItem* download, 545 DownloadItem* download,
538 const content::CheckForFileExistenceCallback& callback) { 546 content::CheckForFileExistenceCallback callback) {
539 #if defined(OS_CHROMEOS) 547 #if defined(OS_CHROMEOS)
540 drive::DownloadHandler* drive_download_handler = 548 drive::DownloadHandler* drive_download_handler =
541 drive::DownloadHandler::GetForProfile(profile_); 549 drive::DownloadHandler::GetForProfile(profile_);
542 if (drive_download_handler && 550 if (drive_download_handler &&
543 drive_download_handler->IsDriveDownload(download)) { 551 drive_download_handler->IsDriveDownload(download)) {
544 drive_download_handler->CheckForFileExistence(download, callback); 552 drive_download_handler->CheckForFileExistence(download,
553 std::move(callback));
545 return; 554 return;
546 } 555 }
547 #endif 556 #endif
548 static const char kSequenceToken[] = "ChromeDMD-FileExistenceChecker";
549 base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool();
550 scoped_refptr<base::SequencedTaskRunner> task_runner =
551 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
552 worker_pool->GetNamedSequenceToken(kSequenceToken),
553 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
554 base::PostTaskAndReplyWithResult( 557 base::PostTaskAndReplyWithResult(
555 task_runner.get(), 558 check_for_file_existence_task_runner_.get(), FROM_HERE,
556 FROM_HERE, 559 base::BindOnce(&base::PathExists, download->GetTargetFilePath()),
557 base::Bind(&base::PathExists, download->GetTargetFilePath()), 560 std::move(callback));
558 callback);
559 } 561 }
560 562
561 std::string 563 std::string
562 ChromeDownloadManagerDelegate::ApplicationClientIdForFileScanning() const { 564 ChromeDownloadManagerDelegate::ApplicationClientIdForFileScanning() const {
563 return std::string(chrome::kApplicationClientIDStringForAVScanning); 565 return std::string(chrome::kApplicationClientIDStringForAVScanning);
564 } 566 }
565 567
566 DownloadProtectionService* 568 DownloadProtectionService*
567 ChromeDownloadManagerDelegate::GetDownloadProtectionService() { 569 ChromeDownloadManagerDelegate::GetDownloadProtectionService() {
568 DCHECK_CURRENTLY_ON(BrowserThread::UI); 570 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) || 864 path.MatchesExtension(FILE_PATH_LITERAL(".xht")) ||
863 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) || 865 path.MatchesExtension(FILE_PATH_LITERAL(".xhtm")) ||
864 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) || 866 path.MatchesExtension(FILE_PATH_LITERAL(".xhtml")) ||
865 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) || 867 path.MatchesExtension(FILE_PATH_LITERAL(".xsl")) ||
866 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) { 868 path.MatchesExtension(FILE_PATH_LITERAL(".xslt"))) {
867 return true; 869 return true;
868 } 870 }
869 #endif 871 #endif
870 return false; 872 return false;
871 } 873 }
OLDNEW
« no previous file with comments | « chrome/browser/download/chrome_download_manager_delegate.h ('k') | content/public/browser/download_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698