From f3b63c0bab333186be5848b3e0afc72d417d14cf Mon Sep 17 00:00:00 2001 From: sdefresne Date: Fri, 6 Feb 2015 07:42:17 -0800 Subject: [PATCH] Remove dependency of HistoryService on WebHistoryServiceFactory Change HistoryService::ExpireLocalAndRemoteHistoryBetween() to receive the history::WebHistoryService instance to use in order to remove a dependency of HistoryService on Profile. It is not possible to pass the WebHistoryService instance to the HistoryService constructor and add a dependency between the two factories due to http://crbug.com/171406 (as WebHistoryService depends on a KeyedService calling Profile::GetRequestContext()). BUG=453790 Review URL: https://codereview.chromium.org/901803005 Cr-Commit-Position: refs/heads/master@{#315038} --- chrome/browser/browsing_data/browsing_data_remover.cc | 2 ++ chrome/browser/history/history_service.cc | 7 +------ chrome/browser/history/history_service.h | 19 ++++++++++--------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc index e61b27d038a0..4e3b3653e819 100644 --- a/chrome/browser/browsing_data/browsing_data_remover.cc +++ b/chrome/browser/browsing_data/browsing_data_remover.cc @@ -22,6 +22,7 @@ #include "chrome/browser/download/download_service_factory.h" #include "chrome/browser/history/history_service.h" #include "chrome/browser/history/history_service_factory.h" +#include "chrome/browser/history/web_history_service_factory.h" #include "chrome/browser/io_thread.h" #include "chrome/browser/media/media_device_id_salt.h" #include "chrome/browser/net/predictor.h" @@ -308,6 +309,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask, waiting_for_clear_history_ = true; history_service->ExpireLocalAndRemoteHistoryBetween( + WebHistoryServiceFactory::GetForProfile(profile_), restrict_urls, delete_begin_, delete_end_, base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone, base::Unretained(this)), diff --git a/chrome/browser/history/history_service.cc b/chrome/browser/history/history_service.cc index c07d4f328415..306408ccebc6 100644 --- a/chrome/browser/history/history_service.cc +++ b/chrome/browser/history/history_service.cc @@ -32,7 +32,6 @@ #include "chrome/browser/history/in_memory_history_backend.h" #include "chrome/browser/history/in_memory_url_index.h" #include "chrome/browser/history/web_history_service.h" -#include "chrome/browser/history/web_history_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/importer/imported_favicon_usage.h" #include "chrome/common/url_constants.h" @@ -217,7 +216,6 @@ class HistoryService::BackendDelegate : public HistoryBackend::Delegate { HistoryService::HistoryService() : thread_(new base::Thread(kHistoryThreadName)), history_client_(NULL), - profile_(NULL), backend_loaded_(false), no_db_(false), weak_ptr_factory_(this) { @@ -227,7 +225,6 @@ HistoryService::HistoryService( history::HistoryClient* history_client, Profile* profile) : thread_(new base::Thread(kHistoryThreadName)), history_client_(history_client), - profile_(profile), visitedlink_master_(new visitedlink::VisitedLinkMaster( profile, this, true)), backend_loaded_(false), @@ -1154,6 +1151,7 @@ void HistoryService::ExpireHistory( } void HistoryService::ExpireLocalAndRemoteHistoryBetween( + history::WebHistoryService* web_history, const std::set& restrict_urls, Time begin_time, Time end_time, @@ -1161,9 +1159,6 @@ void HistoryService::ExpireLocalAndRemoteHistoryBetween( base::CancelableTaskTracker* tracker) { // TODO(dubroy): This should be factored out into a separate class that // dispatches deletions to the proper places. - - history::WebHistoryService* web_history = - WebHistoryServiceFactory::GetForProfile(profile_); if (web_history) { // TODO(dubroy): This API does not yet support deletion of specific URLs. DCHECK(restrict_urls.empty()); diff --git a/chrome/browser/history/history_service.h b/chrome/browser/history/history_service.h index e38b78cc8ac4..23c8e4b3eca3 100644 --- a/chrome/browser/history/history_service.h +++ b/chrome/browser/history/history_service.h @@ -39,9 +39,10 @@ class AndroidHistoryProviderService; #endif class GURL; +class HistoryService; +struct ImportedFaviconUsage; class PageUsageRequest; class Profile; -struct ImportedFaviconUsage; class SkBitmap; namespace base { @@ -72,6 +73,7 @@ struct KeywordSearchTermVisit; class PageUsageData; class URLDatabase; class VisitFilter; +class WebHistoryService; } // namespace history @@ -354,11 +356,13 @@ class HistoryService : public syncer::SyncableService, // Removes all visits to the given URLs in the specified time range. Calls // ExpireHistoryBetween() to delete local visits, and handles deletion of // synced visits if appropriate. - void ExpireLocalAndRemoteHistoryBetween(const std::set& restrict_urls, - base::Time begin_time, - base::Time end_time, - const base::Closure& callback, - base::CancelableTaskTracker* tracker); + void ExpireLocalAndRemoteHistoryBetween( + history::WebHistoryService* web_history, + const std::set& restrict_urls, + base::Time begin_time, + base::Time end_time, + const base::Closure& callback, + base::CancelableTaskTracker* tracker); // Processes the given |delete_directive| and sends it to the // SyncChangeProcessor (if it exists). Returns any error resulting @@ -816,9 +820,6 @@ class HistoryService : public syncer::SyncableService, // outlive |HistoryService|. history::HistoryClient* history_client_; - // The profile, may be null when testing. - Profile* profile_; - // Used for propagating link highlighting data across renderers. May be null // in tests. scoped_ptr visitedlink_master_; -- 2.11.4.GIT