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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_app_identifier.cc

Issue 2473813002: Notify GCMAppHandlers when the store is reset, so they clear cached IDs (Closed)
Patch Set: Update Cryptauth comment Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" 5 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 profile->GetPrefs()->GetDictionary(prefs::kPushMessagingAppIdentifierMap); 153 profile->GetPrefs()->GetDictionary(prefs::kPushMessagingAppIdentifierMap);
154 for (auto it = base::DictionaryValue::Iterator(*map); !it.IsAtEnd(); 154 for (auto it = base::DictionaryValue::Iterator(*map); !it.IsAtEnd();
155 it.Advance()) { 155 it.Advance()) {
156 result.push_back(FindByAppId(profile, it.key())); 156 result.push_back(FindByAppId(profile, it.key()));
157 } 157 }
158 158
159 return result; 159 return result;
160 } 160 }
161 161
162 // static 162 // static
163 void PushMessagingAppIdentifier::DeleteAllFromPrefs(Profile* profile) {
164 DictionaryPrefUpdate update(profile->GetPrefs(),
165 prefs::kPushMessagingAppIdentifierMap);
166 base::DictionaryValue* map = update.Get();
167 map->Clear();
168 }
169
170 // static
163 size_t PushMessagingAppIdentifier::GetCount(Profile* profile) { 171 size_t PushMessagingAppIdentifier::GetCount(Profile* profile) {
164 return profile->GetPrefs() 172 return profile->GetPrefs()
165 ->GetDictionary(prefs::kPushMessagingAppIdentifierMap) 173 ->GetDictionary(prefs::kPushMessagingAppIdentifierMap)
166 ->size(); 174 ->size();
167 } 175 }
168 176
169 PushMessagingAppIdentifier::PushMessagingAppIdentifier() 177 PushMessagingAppIdentifier::PushMessagingAppIdentifier()
170 : origin_(GURL::EmptyGURL()), service_worker_registration_id_(-1) {} 178 : origin_(GURL::EmptyGURL()), service_worker_registration_id_(-1) {}
171 179
172 PushMessagingAppIdentifier::PushMessagingAppIdentifier( 180 PushMessagingAppIdentifier::PushMessagingAppIdentifier(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 if (UseInstanceID(app_id_)) { 243 if (UseInstanceID(app_id_)) {
236 DCHECK(!base::IsValidGUID(guid)); 244 DCHECK(!base::IsValidGUID(guid));
237 245
238 // Replace suffix with valid hex so we can validate the rest of the string. 246 // Replace suffix with valid hex so we can validate the rest of the string.
239 guid = guid.replace(guid.size() - kGuidSuffixLength, kGuidSuffixLength, 247 guid = guid.replace(guid.size() - kGuidSuffixLength, kGuidSuffixLength,
240 kGuidSuffixLength, 'C'); 248 kGuidSuffixLength, 'C');
241 } 249 }
242 DCHECK(base::IsValidGUID(guid)); 250 DCHECK(base::IsValidGUID(guid));
243 #endif // DCHECK_IS_ON() 251 #endif // DCHECK_IS_ON()
244 } 252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698