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

Unified Diff: chrome/browser/browsing_data/history_counter.cc

Issue 2084903002: Moved BrowsingDataCounter and part of BrowsingDataCounterUtils to components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data/history_counter.cc
diff --git a/chrome/browser/browsing_data/history_counter.cc b/chrome/browser/browsing_data/history_counter.cc
index edb03723d2d3b147bc742503ff601ca034143f35..cbe9021f0497a3a603ba061563731e2c291440e3 100644
--- a/chrome/browser/browsing_data/history_counter.cc
+++ b/chrome/browser/browsing_data/history_counter.cc
@@ -11,6 +11,7 @@
#include "base/timer/timer.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/history/web_history_service_factory.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/pref_names.h"
#include "components/browser_sync/browser/profile_sync_service.h"
@@ -22,15 +23,16 @@ namespace {
static const int64_t kWebHistoryTimeoutSeconds = 10;
}
-HistoryCounter::HistoryCounter() : pref_name_(prefs::kDeleteBrowsingHistory),
- has_synced_visits_(false),
- local_counting_finished_(false),
- web_counting_finished_(false),
- testing_web_history_service_(nullptr),
- sync_service_(nullptr),
- history_sync_enabled_(false),
- weak_ptr_factory_(this) {
-}
+HistoryCounter::HistoryCounter(Profile* profile)
+ : BrowsingDataCounter(prefs::kDeleteBrowsingHistory),
+ profile_(profile),
+ has_synced_visits_(false),
+ local_counting_finished_(false),
+ web_counting_finished_(false),
+ testing_web_history_service_(nullptr),
+ sync_service_(nullptr),
+ history_sync_enabled_(false),
+ weak_ptr_factory_(this) {}
HistoryCounter::~HistoryCounter() {
if (sync_service_)
@@ -38,15 +40,10 @@ HistoryCounter::~HistoryCounter() {
}
void HistoryCounter::OnInitialized() {
- sync_service_ = ProfileSyncServiceFactory::GetForProfile(GetProfile());
+ sync_service_ = ProfileSyncServiceFactory::GetForProfile(profile_);
if (sync_service_)
sync_service_->AddObserver(this);
- history_sync_enabled_ =
- !!WebHistoryServiceFactory::GetForProfile(GetProfile());
-}
-
-const std::string& HistoryCounter::GetPrefName() const {
- return pref_name_;
+ history_sync_enabled_ = !!WebHistoryServiceFactory::GetForProfile(profile_);
}
bool HistoryCounter::HasTrackedTasks() {
@@ -67,9 +64,8 @@ void HistoryCounter::Count() {
// Count the locally stored items.
local_counting_finished_ = false;
- history::HistoryService* service =
- HistoryServiceFactory::GetForProfile(
- GetProfile(), ServiceAccessType::EXPLICIT_ACCESS);
+ history::HistoryService* service = HistoryServiceFactory::GetForProfile(
+ profile_, ServiceAccessType::EXPLICIT_ACCESS);
service->GetHistoryCount(
GetPeriodStart(),
@@ -80,9 +76,10 @@ void HistoryCounter::Count() {
// If the history sync is enabled, test if there is at least one synced item.
// If the testing web history service is present, use that one instead.
- history::WebHistoryService* web_history = testing_web_history_service_
- ? testing_web_history_service_
- : WebHistoryServiceFactory::GetForProfile(GetProfile());
+ history::WebHistoryService* web_history =
+ testing_web_history_service_
+ ? testing_web_history_service_
+ : WebHistoryServiceFactory::GetForProfile(profile_);
if (!web_history) {
web_counting_finished_ = true;
@@ -184,7 +181,7 @@ HistoryCounter::HistoryResult::~HistoryResult() {
void HistoryCounter::OnStateChanged() {
bool history_sync_enabled_new_state =
- !!WebHistoryServiceFactory::GetForProfile(GetProfile());
+ !!WebHistoryServiceFactory::GetForProfile(profile_);
// If the history sync was just enabled or disabled, restart the counter
// so that we update the result accordingly.
« no previous file with comments | « chrome/browser/browsing_data/history_counter.h ('k') | chrome/browser/browsing_data/history_counter_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698