From abc35582397a3d44bdb03d3c3071f46ec4db32eb Mon Sep 17 00:00:00 2001 From: "anujk.sharma" Date: Fri, 24 Apr 2015 11:08:25 -0700 Subject: [PATCH] favor DCHECK_CURRENTLY_ON for better logs in chrome/browser/download BUG=466848 Review URL: https://codereview.chromium.org/1090323003 Cr-Commit-Position: refs/heads/master@{#326839} --- .../download/chrome_download_manager_delegate.cc | 28 +++++------ chrome/browser/download/download_crx_util.cc | 2 +- chrome/browser/download/download_history.cc | 24 ++++----- .../browser/download/download_history_unittest.cc | 58 +++++++++++----------- .../download/download_path_reservation_tracker.cc | 16 +++--- .../browser/download/download_request_limiter.cc | 6 +-- .../browser/download/download_target_determiner.cc | 50 +++++++++---------- 7 files changed, 92 insertions(+), 92 deletions(-) diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc index ad2b94bae06f..b1bae98152bc 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.cc +++ b/chrome/browser/download/chrome_download_manager_delegate.cc @@ -213,7 +213,7 @@ ChromeDownloadManagerDelegate::GetDownloadIdReceiverCallback() { } void ChromeDownloadManagerDelegate::SetNextId(uint32 next_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!profile_->IsOffTheRecord()); DCHECK_NE(content::DownloadItem::kInvalidId, next_id); next_download_id_ = next_id; @@ -228,7 +228,7 @@ void ChromeDownloadManagerDelegate::SetNextId(uint32 next_id) { void ChromeDownloadManagerDelegate::GetNextId( const content::DownloadIdCallback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); if (profile_->IsOffTheRecord()) { content::BrowserContext::GetDownloadManager( profile_->GetOriginalProfile())->GetDelegate()->GetNextId(callback); @@ -243,7 +243,7 @@ void ChromeDownloadManagerDelegate::GetNextId( void ChromeDownloadManagerDelegate::ReturnNextId( const content::DownloadIdCallback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!profile_->IsOffTheRecord()); DCHECK_NE(content::DownloadItem::kInvalidId, next_download_id_); callback.Run(next_download_id_++); @@ -268,7 +268,7 @@ bool ChromeDownloadManagerDelegate::DetermineDownloadTarget( bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension( const base::FilePath& path) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); if (path.Extension().empty()) return false; #if defined(ENABLE_EXTENSIONS) @@ -283,7 +283,7 @@ bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension( // static void ChromeDownloadManagerDelegate::DisableSafeBrowsing(DownloadItem* item) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); #if defined(FULL_SAFE_BROWSING) SafeBrowsingState* state = static_cast( item->GetUserData(&kSafeBrowsingUserDataKey)); @@ -298,7 +298,7 @@ void ChromeDownloadManagerDelegate::DisableSafeBrowsing(DownloadItem* item) { bool ChromeDownloadManagerDelegate::IsDownloadReadyForCompletion( DownloadItem* item, const base::Closure& internal_complete_callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); #if defined(FULL_SAFE_BROWSING) SafeBrowsingState* state = static_cast( item->GetUserData(&kSafeBrowsingUserDataKey)); @@ -516,7 +516,7 @@ ChromeDownloadManagerDelegate::ApplicationClientIdForFileScanning() const { DownloadProtectionService* ChromeDownloadManagerDelegate::GetDownloadProtectionService() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); #if defined(FULL_SAFE_BROWSING) SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); if (sb_service && sb_service->download_protection_service() && @@ -531,7 +531,7 @@ void ChromeDownloadManagerDelegate::NotifyExtensions( DownloadItem* download, const base::FilePath& virtual_path, const NotifyExtensionsCallback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); #if defined(ENABLE_EXTENSIONS) extensions::ExtensionDownloadsEventRouter* router = DownloadServiceFactory::GetForBrowserContext(profile_) @@ -555,7 +555,7 @@ void ChromeDownloadManagerDelegate::ReserveVirtualPath( bool create_directory, DownloadPathReservationTracker::FilenameConflictAction conflict_action, const DownloadTargetDeterminerDelegate::ReservedPathCallback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!virtual_path.empty()); #if defined(OS_CHROMEOS) // TODO(asanka): Handle path reservations for virtual paths as well. @@ -578,7 +578,7 @@ void ChromeDownloadManagerDelegate::PromptUserForDownloadPath( DownloadItem* download, const base::FilePath& suggested_path, const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); #if defined(OS_ANDROID) chrome::android::ChromeDownloadManagerOverwriteInfoBarDelegate::Create( InfoBarService::FromWebContents(download->GetWebContents()), @@ -592,7 +592,7 @@ void ChromeDownloadManagerDelegate::DetermineLocalPath( DownloadItem* download, const base::FilePath& virtual_path, const DownloadTargetDeterminerDelegate::LocalPathCallback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); #if defined(OS_CHROMEOS) drive::DownloadHandler* drive_download_handler = drive::DownloadHandler::GetForProfile(profile_); @@ -609,7 +609,7 @@ void ChromeDownloadManagerDelegate::CheckDownloadUrl( DownloadItem* download, const base::FilePath& suggested_path, const CheckDownloadUrlCallback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); #if defined(FULL_SAFE_BROWSING) safe_browsing::DownloadProtectionService* service = @@ -632,7 +632,7 @@ void ChromeDownloadManagerDelegate::CheckDownloadUrl( void ChromeDownloadManagerDelegate::GetFileMimeType( const base::FilePath& path, const GetFileMimeTypeCallback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); base::PostTaskAndReplyWithResult(BrowserThread::GetBlockingPool(), FROM_HERE, base::Bind(&GetMimeType, path), @@ -712,7 +712,7 @@ void ChromeDownloadManagerDelegate::OnDownloadTargetDetermined( int32 download_id, const content::DownloadTargetCallback& callback, scoped_ptr target_info) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DownloadItem* item = download_manager_->GetDownload(download_id); if (item) { if (!target_info->target_path.empty() && diff --git a/chrome/browser/download/download_crx_util.cc b/chrome/browser/download/download_crx_util.cc index 28ba4ab6b047..6a2ed6374fe2 100644 --- a/chrome/browser/download/download_crx_util.cc +++ b/chrome/browser/download/download_crx_util.cc @@ -94,7 +94,7 @@ scoped_refptr CreateCrxInstaller( scoped_refptr OpenChromeExtension( Profile* profile, const DownloadItem& download_item) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); scoped_refptr installer( CreateCrxInstaller(profile, download_item)); diff --git a/chrome/browser/download/download_history.cc b/chrome/browser/download/download_history.cc index 05c5a5d7df9c..becc0e55a9b1 100644 --- a/chrome/browser/download/download_history.cc +++ b/chrome/browser/download/download_history.cc @@ -212,7 +212,7 @@ DownloadHistory::DownloadHistory(content::DownloadManager* manager, loading_id_(content::DownloadItem::kInvalidId), history_size_(0), weak_ptr_factory_(this) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); content::DownloadManager::DownloadVector items; notifier_.GetManager()->GetAllDownloads(&items); for (content::DownloadManager::DownloadVector::const_iterator @@ -224,24 +224,24 @@ DownloadHistory::DownloadHistory(content::DownloadManager* manager, } DownloadHistory::~DownloadHistory() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); FOR_EACH_OBSERVER(Observer, observers_, OnDownloadHistoryDestroyed()); observers_.Clear(); } void DownloadHistory::AddObserver(DownloadHistory::Observer* observer) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); observers_.AddObserver(observer); } void DownloadHistory::RemoveObserver(DownloadHistory::Observer* observer) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); observers_.RemoveObserver(observer); } bool DownloadHistory::WasRestoredFromHistory( const content::DownloadItem* download) const { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); const DownloadHistoryData* data = DownloadHistoryData::Get(download); // The OnDownloadCreated handler sets the was_restored_from_history flag when @@ -253,7 +253,7 @@ bool DownloadHistory::WasRestoredFromHistory( } void DownloadHistory::QueryCallback(scoped_ptr infos) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // ManagerGoingDown() may have happened before the history loaded. if (!notifier_.GetManager()) return; @@ -293,7 +293,7 @@ void DownloadHistory::QueryCallback(scoped_ptr infos) { } void DownloadHistory::MaybeAddToHistory(content::DownloadItem* item) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); uint32 download_id = item->GetId(); DownloadHistoryData* data = DownloadHistoryData::Get(item); @@ -371,7 +371,7 @@ void DownloadHistory::ItemAdded(uint32 download_id, bool success) { void DownloadHistory::OnDownloadCreated( content::DownloadManager* manager, content::DownloadItem* item) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // All downloads should pass through OnDownloadCreated exactly once. CHECK(!DownloadHistoryData::Get(item)); @@ -389,7 +389,7 @@ void DownloadHistory::OnDownloadCreated( void DownloadHistory::OnDownloadUpdated( content::DownloadManager* manager, content::DownloadItem* item) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DownloadHistoryData* data = DownloadHistoryData::Get(item); if (data->state() == DownloadHistoryData::NOT_PERSISTED) { @@ -424,7 +424,7 @@ void DownloadHistory::OnDownloadOpened( void DownloadHistory::OnDownloadRemoved( content::DownloadManager* manager, content::DownloadItem* item) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DownloadHistoryData* data = DownloadHistoryData::Get(item); if (data->state() != DownloadHistoryData::PERSISTED) { @@ -445,7 +445,7 @@ void DownloadHistory::OnDownloadRemoved( } void DownloadHistory::ScheduleRemoveDownload(uint32 download_id) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // For database efficiency, batch removals together if they happen all at // once. @@ -458,7 +458,7 @@ void DownloadHistory::ScheduleRemoveDownload(uint32 download_id) { } void DownloadHistory::RemoveDownloadsBatch() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); IdSet remove_ids; removing_ids_.swap(remove_ids); history_->RemoveDownloads(remove_ids); diff --git a/chrome/browser/download/download_history_unittest.cc b/chrome/browser/download/download_history_unittest.cc index 2ffdb948e2ad..db441eda7875 100644 --- a/chrome/browser/download/download_history_unittest.cc +++ b/chrome/browser/download/download_history_unittest.cc @@ -75,7 +75,7 @@ class FakeHistoryAdapter : public DownloadHistory::HistoryAdapter { void QueryDownloads( const history::HistoryService::DownloadQueryCallback& callback) override { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, base::Bind(&FakeHistoryAdapter::QueryDownloadsDone, base::Unretained(this), callback)); @@ -83,7 +83,7 @@ class FakeHistoryAdapter : public DownloadHistory::HistoryAdapter { void QueryDownloadsDone( const history::HistoryService::DownloadQueryCallback& callback) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); CHECK(expect_query_downloads_.get()); callback.Run(expect_query_downloads_.Pass()); } @@ -93,7 +93,7 @@ class FakeHistoryAdapter : public DownloadHistory::HistoryAdapter { void CreateDownload(const history::DownloadRow& info, const history::HistoryService::DownloadCreateCallback& callback) override { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); create_download_info_ = info; // Must not call CreateDownload() again before FinishCreateDownload()! DCHECK(create_download_callback_.is_null()); @@ -104,18 +104,18 @@ class FakeHistoryAdapter : public DownloadHistory::HistoryAdapter { } void FinishCreateDownload() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); create_download_callback_.Run(); create_download_callback_.Reset(); } void UpdateDownload(const history::DownloadRow& info) override { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); update_download_ = info; } void RemoveDownloads(const IdSet& ids) override { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); for (IdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { remove_downloads_.insert(*it); @@ -123,55 +123,55 @@ class FakeHistoryAdapter : public DownloadHistory::HistoryAdapter { } void ExpectWillQueryDownloads(scoped_ptr infos) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); expect_query_downloads_ = infos.Pass(); } void ExpectQueryDownloadsDone() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); EXPECT_TRUE(NULL == expect_query_downloads_.get()); } void FailCreateDownload() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); fail_create_download_ = true; } void ExpectDownloadCreated( const history::DownloadRow& info) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); content::RunAllPendingInMessageLoop(content::BrowserThread::UI); CheckInfoEqual(info, create_download_info_); create_download_info_ = history::DownloadRow(); } void ExpectNoDownloadCreated() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); content::RunAllPendingInMessageLoop(content::BrowserThread::UI); CheckInfoEqual(history::DownloadRow(), create_download_info_); } void ExpectDownloadUpdated(const history::DownloadRow& info) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); content::RunAllPendingInMessageLoop(content::BrowserThread::UI); CheckInfoEqual(update_download_, info); update_download_ = history::DownloadRow(); } void ExpectNoDownloadUpdated() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); content::RunAllPendingInMessageLoop(content::BrowserThread::UI); CheckInfoEqual(history::DownloadRow(), update_download_); } void ExpectNoDownloadsRemoved() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); content::RunAllPendingInMessageLoop(content::BrowserThread::UI); EXPECT_EQ(0, static_cast(remove_downloads_.size())); } void ExpectDownloadsRemoved(const IdSet& ids) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); content::RunAllPendingInMessageLoop(content::BrowserThread::UI); IdSet differences = base::STLSetDifference(ids, remove_downloads_); for (IdSet::const_iterator different = differences.begin(); @@ -222,7 +222,7 @@ class DownloadHistoryTest : public testing::Test { } void CreateDownloadHistory(scoped_ptr infos) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); CHECK(infos.get()); EXPECT_CALL(manager(), AddObserver(_)).WillOnce(WithArg<0>(Invoke( this, &DownloadHistoryTest::SetManagerObserver))); @@ -265,7 +265,7 @@ class DownloadHistoryTest : public testing::Test { } void CallOnDownloadCreated(size_t index) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); if (!pre_on_create_handler_.is_null()) pre_on_create_handler_.Run(&item(index)); manager_observer()->OnDownloadCreated(&manager(), &item(index)); @@ -274,60 +274,60 @@ class DownloadHistoryTest : public testing::Test { } void CallOnDownloadCreatedInOrder() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // Gmock doesn't appear to support something like InvokeWithTheseArgs. Maybe // gmock needs to learn about base::Callback. CallOnDownloadCreated(download_created_index_++); } void set_slow_create_download(bool slow) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); history_->set_slow_create_download(slow); } void FinishCreateDownload() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); history_->FinishCreateDownload(); } void FailCreateDownload() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); history_->FailCreateDownload(); } void ExpectDownloadCreated( const history::DownloadRow& info) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); history_->ExpectDownloadCreated(info); } void ExpectNoDownloadCreated() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); history_->ExpectNoDownloadCreated(); } void ExpectDownloadUpdated(const history::DownloadRow& info) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); history_->ExpectDownloadUpdated(info); } void ExpectNoDownloadUpdated() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); history_->ExpectNoDownloadUpdated(); } void ExpectNoDownloadsRemoved() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); history_->ExpectNoDownloadsRemoved(); } void ExpectDownloadsRemoved(const IdSet& ids) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); history_->ExpectDownloadsRemoved(ids); } void ExpectDownloadsRestoredFromHistory(bool expected_value) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); pre_on_create_handler_ = base::Bind(&DownloadHistoryTest::CheckDownloadWasRestoredFromHistory, base::Unretained(this), @@ -389,7 +389,7 @@ class DownloadHistoryTest : public testing::Test { const std::string& by_extension_id, const std::string& by_extension_name, history::DownloadRow* info) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); size_t index = items_.size(); StrictMockDownloadItem* mock_item = new StrictMockDownloadItem(); diff --git a/chrome/browser/download/download_path_reservation_tracker.cc b/chrome/browser/download/download_path_reservation_tracker.cc index 8ced0eeecf6a..8492b85f81ea 100644 --- a/chrome/browser/download/download_path_reservation_tracker.cc +++ b/chrome/browser/download/download_path_reservation_tracker.cc @@ -70,7 +70,7 @@ class DownloadItemObserver : public DownloadItem::Observer { // Returns true if the given path is in use by a path reservation. bool IsPathReserved(const base::FilePath& path) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); + DCHECK_CURRENTLY_ON(BrowserThread::FILE); // No reservation map => no reservations. if (g_reservation_map == NULL) return false; @@ -89,7 +89,7 @@ bool IsPathReserved(const base::FilePath& path) { // Returns true if the given path is in use by any path reservation or the // file system. Called on the FILE thread. bool IsPathInUse(const base::FilePath& path) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); + DCHECK_CURRENTLY_ON(BrowserThread::FILE); // If there is a reservation, then the path is in use. if (IsPathReserved(path)) return true; @@ -155,7 +155,7 @@ bool CreateReservation( bool create_directory, DownloadPathReservationTracker::FilenameConflictAction conflict_action, base::FilePath* reserved_path) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); + DCHECK_CURRENTLY_ON(BrowserThread::FILE); DCHECK(suggested_path.IsAbsolute()); // Create a reservation map if one doesn't exist. It will be automatically @@ -249,7 +249,7 @@ bool CreateReservation( // Called on the FILE thread to update the path of the reservation associated // with |key| to |new_path|. void UpdateReservation(ReservationKey key, const base::FilePath& new_path) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); + DCHECK_CURRENTLY_ON(BrowserThread::FILE); DCHECK(g_reservation_map != NULL); ReservationMap::iterator iter = g_reservation_map->find(key); if (iter != g_reservation_map->end()) { @@ -265,7 +265,7 @@ void UpdateReservation(ReservationKey key, const base::FilePath& new_path) { // Called on the FILE thread to remove the path reservation associated with // |key|. void RevokeReservation(ReservationKey key) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); + DCHECK_CURRENTLY_ON(BrowserThread::FILE); DCHECK(g_reservation_map != NULL); DCHECK(ContainsKey(*g_reservation_map, key)); g_reservation_map->erase(key); @@ -280,14 +280,14 @@ void RunGetReservedPathCallback( const DownloadPathReservationTracker::ReservedPathCallback& callback, const base::FilePath* reserved_path, bool verified) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); callback.Run(*reserved_path, verified); } DownloadItemObserver::DownloadItemObserver(DownloadItem* download_item) : download_item_(download_item), last_target_path_(download_item->GetTargetFilePath()) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); download_item_->AddObserver(this); } @@ -350,7 +350,7 @@ void DownloadPathReservationTracker::GetReservedPath( bool create_directory, FilenameConflictAction conflict_action, const ReservedPathCallback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); // Attach an observer to the download item so that we know when the target // path changes and/or the download is no longer active. new DownloadItemObserver(download_item); diff --git a/chrome/browser/download/download_request_limiter.cc b/chrome/browser/download/download_request_limiter.cc index 9d2117d6c15f..39e3cd0a3b47 100644 --- a/chrome/browser/download/download_request_limiter.cc +++ b/chrome/browser/download/download_request_limiter.cc @@ -287,7 +287,7 @@ void DownloadRequestLimiter::CanDownloadOnIOThread( const Callback& callback) { // This is invoked on the IO thread. Schedule the task to run on the UI // thread so that we can query UI state. - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + DCHECK_CURRENTLY_ON(BrowserThread::IO); BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind(&DownloadRequestLimiter::CanDownload, this, @@ -319,7 +319,7 @@ void DownloadRequestLimiter::CanDownload(int render_process_host_id, const GURL& url, const std::string& request_method, const Callback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); content::WebContents* originating_contents = tab_util::GetWebContentsByID(render_process_host_id, render_view_id); @@ -357,7 +357,7 @@ void DownloadRequestLimiter::OnCanDownloadDecided( int render_view_id, const std::string& request_method, const Callback& orig_callback, bool allow) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); content::WebContents* originating_contents = tab_util::GetWebContentsByID(render_process_host_id, render_view_id); if (!originating_contents || !allow) { diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/browser/download/download_target_determiner.cc index f1f6e652c889..7a7dfb88a73c 100644 --- a/chrome/browser/download/download_target_determiner.cc +++ b/chrome/browser/download/download_target_determiner.cc @@ -100,7 +100,7 @@ DownloadTargetDeterminer::DownloadTargetDeterminer( delegate_(delegate), completion_callback_(callback), weak_ptr_factory_(this) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(download_); DCHECK(delegate); download_->AddObserver(this); @@ -109,7 +109,7 @@ DownloadTargetDeterminer::DownloadTargetDeterminer( } DownloadTargetDeterminer::~DownloadTargetDeterminer() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(download_); DCHECK(completion_callback_.is_null()); download_->RemoveObserver(this); @@ -170,7 +170,7 @@ void DownloadTargetDeterminer::DoLoop() { DownloadTargetDeterminer::Result DownloadTargetDeterminer::DoGenerateTargetPath() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(local_path_.empty()); DCHECK(!should_prompt_); DCHECK(!should_notify_extensions_); @@ -240,7 +240,7 @@ DownloadTargetDeterminer::Result DownloadTargetDeterminer::Result DownloadTargetDeterminer::DoNotifyExtensions() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!virtual_path_.empty()); next_state_ = STATE_RESERVE_VIRTUAL_PATH; @@ -257,7 +257,7 @@ DownloadTargetDeterminer::Result void DownloadTargetDeterminer::NotifyExtensionsDone( const base::FilePath& suggested_path, DownloadPathReservationTracker::FilenameConflictAction conflict_action) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DVLOG(20) << "Extension suggested path: " << suggested_path.AsUTF8Unsafe(); // Extensions should not call back here more than once. @@ -289,7 +289,7 @@ void DownloadTargetDeterminer::NotifyExtensionsDone( DownloadTargetDeterminer::Result DownloadTargetDeterminer::DoReserveVirtualPath() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!virtual_path_.empty()); next_state_ = STATE_PROMPT_USER_FOR_DOWNLOAD_PATH; @@ -303,7 +303,7 @@ DownloadTargetDeterminer::Result void DownloadTargetDeterminer::ReserveVirtualPathDone( const base::FilePath& path, bool verified) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DVLOG(20) << "Reserved path: " << path.AsUTF8Unsafe() << " Verified:" << verified; DCHECK_EQ(STATE_PROMPT_USER_FOR_DOWNLOAD_PATH, next_state_); @@ -315,7 +315,7 @@ void DownloadTargetDeterminer::ReserveVirtualPathDone( DownloadTargetDeterminer::Result DownloadTargetDeterminer::DoPromptUserForDownloadPath() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!virtual_path_.empty()); next_state_ = STATE_DETERMINE_LOCAL_PATH; @@ -333,7 +333,7 @@ DownloadTargetDeterminer::Result void DownloadTargetDeterminer::PromptUserForDownloadPathDone( const base::FilePath& virtual_path) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DVLOG(20) << "User selected path:" << virtual_path.AsUTF8Unsafe(); if (virtual_path.empty()) { CancelOnFailureAndDeleteSelf(); @@ -348,7 +348,7 @@ void DownloadTargetDeterminer::PromptUserForDownloadPathDone( DownloadTargetDeterminer::Result DownloadTargetDeterminer::DoDetermineLocalPath() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!virtual_path_.empty()); DCHECK(local_path_.empty()); @@ -364,7 +364,7 @@ DownloadTargetDeterminer::Result void DownloadTargetDeterminer::DetermineLocalPathDone( const base::FilePath& local_path) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DVLOG(20) << "Local path: " << local_path.AsUTF8Unsafe(); if (local_path.empty()) { // Path subsitution failed. @@ -379,7 +379,7 @@ void DownloadTargetDeterminer::DetermineLocalPathDone( DownloadTargetDeterminer::Result DownloadTargetDeterminer::DoDetermineMimeType() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!virtual_path_.empty()); DCHECK(!local_path_.empty()); DCHECK(mime_type_.empty()); @@ -398,7 +398,7 @@ DownloadTargetDeterminer::Result void DownloadTargetDeterminer::DetermineMimeTypeDone( const std::string& mime_type) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DVLOG(20) << "MIME type: " << mime_type; DCHECK_EQ(STATE_DETERMINE_IF_HANDLED_SAFELY_BY_BROWSER, next_state_); @@ -427,7 +427,7 @@ void IsHandledBySafePlugin(content::ResourceContext* resource_context, const std::string& mime_type, ActionOnStalePluginList stale_plugin_action, const base::Callback& callback) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK(!mime_type.empty()); using content::WebPluginInfo; @@ -472,7 +472,7 @@ void IsHandledBySafePlugin(content::ResourceContext* resource_context, DownloadTargetDeterminer::Result DownloadTargetDeterminer::DoDetermineIfHandledSafely() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!virtual_path_.empty()); DCHECK(!local_path_.empty()); DCHECK(!is_filetype_handled_safely_); @@ -508,7 +508,7 @@ DownloadTargetDeterminer::Result #if defined(ENABLE_PLUGINS) void DownloadTargetDeterminer::DetermineIfHandledSafelyDone( bool is_handled_safely) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DVLOG(20) << "Is file type handled safely: " << is_filetype_handled_safely_; DCHECK_EQ(STATE_DETERMINE_IF_ADOBE_READER_UP_TO_DATE, next_state_); is_filetype_handled_safely_ = is_handled_safely; @@ -518,7 +518,7 @@ void DownloadTargetDeterminer::DetermineIfHandledSafelyDone( DownloadTargetDeterminer::Result DownloadTargetDeterminer::DoDetermineIfAdobeReaderUpToDate() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); next_state_ = STATE_CHECK_DOWNLOAD_URL; @@ -545,7 +545,7 @@ DownloadTargetDeterminer::Result #if defined(OS_WIN) void DownloadTargetDeterminer::DetermineIfAdobeReaderUpToDateDone( bool adobe_reader_up_to_date) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DVLOG(20) << "Is Adobe Reader Up To Date: " << adobe_reader_up_to_date; DCHECK_EQ(STATE_CHECK_DOWNLOAD_URL, next_state_); g_is_adobe_reader_up_to_date_ = adobe_reader_up_to_date; @@ -555,7 +555,7 @@ void DownloadTargetDeterminer::DetermineIfAdobeReaderUpToDateDone( DownloadTargetDeterminer::Result DownloadTargetDeterminer::DoCheckDownloadUrl() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!virtual_path_.empty()); next_state_ = STATE_CHECK_VISITED_REFERRER_BEFORE; delegate_->CheckDownloadUrl( @@ -568,7 +568,7 @@ DownloadTargetDeterminer::Result void DownloadTargetDeterminer::CheckDownloadUrlDone( content::DownloadDangerType danger_type) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DVLOG(20) << "URL Check Result:" << danger_type; DCHECK_EQ(STATE_CHECK_VISITED_REFERRER_BEFORE, next_state_); danger_type_ = danger_type; @@ -577,7 +577,7 @@ void DownloadTargetDeterminer::CheckDownloadUrlDone( DownloadTargetDeterminer::Result DownloadTargetDeterminer::DoCheckVisitedReferrerBefore() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); next_state_ = STATE_DETERMINE_INTERMEDIATE_PATH; @@ -625,7 +625,7 @@ DownloadTargetDeterminer::Result void DownloadTargetDeterminer::CheckVisitedReferrerBeforeDone( bool visited_referrer_before) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_EQ(STATE_DETERMINE_INTERMEDIATE_PATH, next_state_); if (IsDangerousFile(visited_referrer_before ? VISITED_REFERRER : NO_VISITS_TO_REFERRER)) { @@ -638,7 +638,7 @@ void DownloadTargetDeterminer::CheckVisitedReferrerBeforeDone( DownloadTargetDeterminer::Result DownloadTargetDeterminer::DoDetermineIntermediatePath() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!virtual_path_.empty()); DCHECK(!local_path_.empty()); DCHECK(intermediate_path_.empty()); @@ -810,7 +810,7 @@ bool DownloadTargetDeterminer::HasPromptedForPath() const { } bool DownloadTargetDeterminer::IsDangerousFile(PriorVisitsToReferrer visits) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); // If the user has has been prompted or will be, assume that the user has // approved the download. A programmatic download is considered safe unless it @@ -869,7 +869,7 @@ bool DownloadTargetDeterminer::IsDangerousFile(PriorVisitsToReferrer visits) { void DownloadTargetDeterminer::OnDownloadDestroyed( DownloadItem* download) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_EQ(download_, download); CancelOnFailureAndDeleteSelf(); } -- 2.11.4.GIT