Commit 173da821 authored by sdefresne's avatar sdefresne Committed by Commit bot

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
R=droger@chromium.org

Review URL: https://codereview.chromium.org/891763002

Cr-Commit-Position: refs/heads/master@{#314152}
parent 241e6870
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "chrome/browser/download/download_service_factory.h" #include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/history/history_service.h" #include "chrome/browser/history/history_service.h"
#include "chrome/browser/history/history_service_factory.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/io_thread.h"
#include "chrome/browser/media/media_device_id_salt.h" #include "chrome/browser/media/media_device_id_salt.h"
#include "chrome/browser/net/predictor.h" #include "chrome/browser/net/predictor.h"
...@@ -45,6 +46,7 @@ ...@@ -45,6 +46,7 @@
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/domain_reliability/service.h" #include "components/domain_reliability/service.h"
#include "components/history/core/browser/web_history_service.h"
#include "components/nacl/browser/nacl_browser.h" #include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/browser/pnacl_host.h" #include "components/nacl/browser/pnacl_host.h"
#include "components/password_manager/core/browser/password_store.h" #include "components/password_manager/core/browser/password_store.h"
...@@ -308,7 +310,8 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask, ...@@ -308,7 +310,8 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
waiting_for_clear_history_ = true; waiting_for_clear_history_ = true;
history_service->ExpireLocalAndRemoteHistoryBetween( history_service->ExpireLocalAndRemoteHistoryBetween(
restrict_urls, delete_begin_, delete_end_, WebHistoryServiceFactory::GetForProfile(profile_), restrict_urls,
delete_begin_, delete_end_,
base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone, base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone,
base::Unretained(this)), base::Unretained(this)),
&history_task_tracker_); &history_task_tracker_);
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "chrome/browser/history/history_backend.h" #include "chrome/browser/history/history_backend.h"
#include "chrome/browser/history/in_memory_history_backend.h" #include "chrome/browser/history/in_memory_history_backend.h"
#include "chrome/browser/history/in_memory_url_index.h" #include "chrome/browser/history/in_memory_url_index.h"
#include "chrome/browser/history/web_history_service_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
...@@ -1166,6 +1165,7 @@ void HistoryService::ExpireHistory( ...@@ -1166,6 +1165,7 @@ void HistoryService::ExpireHistory(
} }
void HistoryService::ExpireLocalAndRemoteHistoryBetween( void HistoryService::ExpireLocalAndRemoteHistoryBetween(
history::WebHistoryService* web_history,
const std::set<GURL>& restrict_urls, const std::set<GURL>& restrict_urls,
Time begin_time, Time begin_time,
Time end_time, Time end_time,
...@@ -1174,8 +1174,6 @@ void HistoryService::ExpireLocalAndRemoteHistoryBetween( ...@@ -1174,8 +1174,6 @@ void HistoryService::ExpireLocalAndRemoteHistoryBetween(
// TODO(dubroy): This should be factored out into a separate class that // TODO(dubroy): This should be factored out into a separate class that
// dispatches deletions to the proper places. // dispatches deletions to the proper places.
history::WebHistoryService* web_history =
WebHistoryServiceFactory::GetForProfile(profile_);
if (web_history) { if (web_history) {
// TODO(dubroy): This API does not yet support deletion of specific URLs. // TODO(dubroy): This API does not yet support deletion of specific URLs.
DCHECK(restrict_urls.empty()); DCHECK(restrict_urls.empty());
...@@ -1188,9 +1186,8 @@ void HistoryService::ExpireLocalAndRemoteHistoryBetween( ...@@ -1188,9 +1186,8 @@ void HistoryService::ExpireLocalAndRemoteHistoryBetween(
// //
// TODO(davidben): |callback| should not run until this operation completes // TODO(davidben): |callback| should not run until this operation completes
// too. // too.
web_history->ExpireHistoryBetween( web_history->ExpireHistoryBetween(restrict_urls, begin_time, end_time,
restrict_urls, begin_time, end_time, base::Bind(&ExpireWebHistoryComplete));
base::Bind(&ExpireWebHistoryComplete));
} }
ExpireHistoryBetween(restrict_urls, begin_time, end_time, callback, tracker); ExpireHistoryBetween(restrict_urls, begin_time, end_time, callback, tracker);
} }
......
...@@ -73,6 +73,7 @@ class VisitFilter; ...@@ -73,6 +73,7 @@ class VisitFilter;
struct DownloadRow; struct DownloadRow;
struct HistoryAddPageArgs; struct HistoryAddPageArgs;
struct KeywordSearchTermVisit; struct KeywordSearchTermVisit;
class WebHistoryService;
} // namespace history } // namespace history
...@@ -353,11 +354,13 @@ class HistoryService : public syncer::SyncableService, ...@@ -353,11 +354,13 @@ class HistoryService : public syncer::SyncableService,
// Removes all visits to the given URLs in the specified time range. Calls // Removes all visits to the given URLs in the specified time range. Calls
// ExpireHistoryBetween() to delete local visits, and handles deletion of // ExpireHistoryBetween() to delete local visits, and handles deletion of
// synced visits if appropriate. // synced visits if appropriate.
void ExpireLocalAndRemoteHistoryBetween(const std::set<GURL>& restrict_urls, void ExpireLocalAndRemoteHistoryBetween(
base::Time begin_time, history::WebHistoryService* web_history,
base::Time end_time, const std::set<GURL>& restrict_urls,
const base::Closure& callback, base::Time begin_time,
base::CancelableTaskTracker* tracker); base::Time end_time,
const base::Closure& callback,
base::CancelableTaskTracker* tracker);
// Processes the given |delete_directive| and sends it to the // Processes the given |delete_directive| and sends it to the
// SyncChangeProcessor (if it exists). Returns any error resulting // SyncChangeProcessor (if it exists). Returns any error resulting
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment