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

Unified Diff: chrome/browser/invalidation/invalidator_storage.cc

Issue 59793008: sync: don't allow NULL profile in ProfileSyncService and friends (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 7 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 | « chrome/browser/invalidation/invalidator_storage.h ('k') | chrome/browser/sync/backend_migrator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/invalidation/invalidator_storage.cc
diff --git a/chrome/browser/invalidation/invalidator_storage.cc b/chrome/browser/invalidation/invalidator_storage.cc
index 2c6c2ae0444a2ee089760397455200d82a40f014..042f942b08dac8f877911a3a0692fc0bb148f7c4 100644
--- a/chrome/browser/invalidation/invalidator_storage.cc
+++ b/chrome/browser/invalidation/invalidator_storage.cc
@@ -114,11 +114,8 @@ void InvalidatorStorage::RegisterProfilePrefs(
InvalidatorStorage::InvalidatorStorage(PrefService* pref_service)
: pref_service_(pref_service) {
- // TODO(tim): Create a Mock instead of maintaining the if(!pref_service_) case
- // throughout this file. This is a problem now due to lack of injection at
- // ProfileSyncService. Bug 130176.
- if (pref_service_)
- MigrateMaxInvalidationVersionsPref();
+ DCHECK(pref_service);
+ MigrateMaxInvalidationVersionsPref();
}
InvalidatorStorage::~InvalidatorStorage() {
@@ -127,9 +124,6 @@ InvalidatorStorage::~InvalidatorStorage() {
InvalidationStateMap InvalidatorStorage::GetAllInvalidationStates() const {
DCHECK(thread_checker_.CalledOnValidThread());
InvalidationStateMap state_map;
- if (!pref_service_) {
- return state_map;
- }
const base::ListValue* state_map_list =
pref_service_->GetList(prefs::kInvalidatorMaxInvalidationVersions);
CHECK(state_map_list);
@@ -142,7 +136,6 @@ void InvalidatorStorage::SetMaxVersionAndPayload(
int64 max_version,
const std::string& payload) {
DCHECK(thread_checker_.CalledOnValidThread());
- CHECK(pref_service_);
InvalidationStateMap state_map = GetAllInvalidationStates();
InvalidationStateMap::iterator it = state_map.find(id);
if ((it != state_map.end()) && (max_version <= it->second.version)) {
@@ -160,7 +153,6 @@ void InvalidatorStorage::SetMaxVersionAndPayload(
void InvalidatorStorage::Forget(const syncer::ObjectIdSet& ids) {
DCHECK(thread_checker_.CalledOnValidThread());
- CHECK(pref_service_);
InvalidationStateMap state_map = GetAllInvalidationStates();
for (syncer::ObjectIdSet::const_iterator it = ids.begin(); it != ids.end();
++it) {
@@ -272,9 +264,7 @@ void InvalidatorStorage::SetInvalidatorClientId(const std::string& client_id) {
}
std::string InvalidatorStorage::GetInvalidatorClientId() const {
- return pref_service_ ?
- pref_service_->GetString(prefs::kInvalidatorClientId) :
- std::string();
+ return pref_service_->GetString(prefs::kInvalidatorClientId);
}
void InvalidatorStorage::SetBootstrapData(const std::string& data) {
@@ -287,9 +277,7 @@ void InvalidatorStorage::SetBootstrapData(const std::string& data) {
std::string InvalidatorStorage::GetBootstrapData() const {
std::string base64_data(
- pref_service_
- ? pref_service_->GetString(prefs::kInvalidatorInvalidationState)
- : std::string());
+ pref_service_->GetString(prefs::kInvalidatorInvalidationState));
std::string data;
base::Base64Decode(base64_data, &data);
return data;
@@ -307,7 +295,6 @@ void InvalidatorStorage::GenerateAckHandles(
const scoped_refptr<base::TaskRunner>& task_runner,
const base::Callback<void(const syncer::AckHandleMap&)> callback) {
DCHECK(thread_checker_.CalledOnValidThread());
- CHECK(pref_service_);
InvalidationStateMap state_map = GetAllInvalidationStates();
syncer::AckHandleMap ack_handles;
@@ -329,7 +316,6 @@ void InvalidatorStorage::GenerateAckHandles(
void InvalidatorStorage::Acknowledge(const invalidation::ObjectId& id,
const syncer::AckHandle& ack_handle) {
DCHECK(thread_checker_.CalledOnValidThread());
- CHECK(pref_service_);
InvalidationStateMap state_map = GetAllInvalidationStates();
InvalidationStateMap::iterator it = state_map.find(id);
« no previous file with comments | « chrome/browser/invalidation/invalidator_storage.h ('k') | chrome/browser/sync/backend_migrator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698