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

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

Issue 1413373012: Sanitize access to services in HistoryCounter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bad51a2a5b93a49a952bef264fe943f2e16aa6d6..58ede7365a6a2c8b2ebde8dce82c04323373b05d 100644
--- a/chrome/browser/browsing_data/history_counter.cc
+++ b/chrome/browser/browsing_data/history_counter.cc
@@ -30,14 +30,14 @@ HistoryCounter::HistoryCounter() : pref_name_(prefs::kDeleteBrowsingHistory),
}
HistoryCounter::~HistoryCounter() {
- DCHECK(sync_service_);
- sync_service_->RemoveObserver(this);
+ if (sync_service_)
+ sync_service_->RemoveObserver(this);
}
void HistoryCounter::OnInitialized() {
sync_service_ = ProfileSyncServiceFactory::GetForProfile(GetProfile());
- DCHECK(sync_service_);
- sync_service_->AddObserver(this);
+ if (sync_service_)
+ sync_service_->AddObserver(this);
history_sync_enabled_ =
!!WebHistoryServiceFactory::GetForProfile(GetProfile());
}
@@ -65,7 +65,8 @@ void HistoryCounter::Count() {
local_counting_finished_ = false;
history::HistoryService* service =
- HistoryServiceFactory::GetForProfileWithoutCreating(GetProfile());
+ HistoryServiceFactory::GetForProfile(
+ GetProfile(), ServiceAccessType::EXPLICIT_ACCESS);
service->GetHistoryCount(
GetPeriodStart(),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698