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

Side by Side Diff: components/proximity_auth/cryptauth/cryptauth_gcm_manager_impl.cc

Issue 2473813002: Notify GCMAppHandlers when the store is reset, so they clear cached IDs (Closed)
Patch Set: 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/proximity_auth/cryptauth/cryptauth_gcm_manager_impl.h" 5 #include "components/proximity_auth/cryptauth/cryptauth_gcm_manager_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "components/gcm_driver/gcm_driver.h" 9 #include "components/gcm_driver/gcm_driver.h"
10 #include "components/prefs/pref_service.h" 10 #include "components/prefs/pref_service.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 observers_.AddObserver(observer); 76 observers_.AddObserver(observer);
77 } 77 }
78 78
79 void CryptAuthGCMManagerImpl::RemoveObserver(Observer* observer) { 79 void CryptAuthGCMManagerImpl::RemoveObserver(Observer* observer) {
80 observers_.RemoveObserver(observer); 80 observers_.RemoveObserver(observer);
81 } 81 }
82 82
83 void CryptAuthGCMManagerImpl::ShutdownHandler() { 83 void CryptAuthGCMManagerImpl::ShutdownHandler() {
84 } 84 }
85 85
86 void CryptAuthGCMManagerImpl::OnStoreReset() {
87 pref_service_->ClearPref(prefs::kCryptAuthGCMRegistrationId);
88 }
89
86 void CryptAuthGCMManagerImpl::OnMessage(const std::string& app_id, 90 void CryptAuthGCMManagerImpl::OnMessage(const std::string& app_id,
87 const gcm::IncomingMessage& message) { 91 const gcm::IncomingMessage& message) {
88 std::vector<std::string> fields; 92 std::vector<std::string> fields;
89 for (const auto& kv : message.data) { 93 for (const auto& kv : message.data) {
90 fields.push_back(std::string(kv.first) + ": " + std::string(kv.second)); 94 fields.push_back(std::string(kv.first) + ": " + std::string(kv.second));
91 } 95 }
92 96
93 PA_LOG(INFO) << "GCM message received:\n" 97 PA_LOG(INFO) << "GCM message received:\n"
94 << " sender_id: " << message.sender_id << "\n" 98 << " sender_id: " << message.sender_id << "\n"
95 << " collapse_key: " << message.collapse_key << "\n" 99 << " collapse_key: " << message.collapse_key << "\n"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 145 }
142 146
143 PA_LOG(INFO) << "GCM registration success, registration_id=" 147 PA_LOG(INFO) << "GCM registration success, registration_id="
144 << registration_id; 148 << registration_id;
145 pref_service_->SetString(prefs::kCryptAuthGCMRegistrationId, registration_id); 149 pref_service_->SetString(prefs::kCryptAuthGCMRegistrationId, registration_id);
146 for (auto& observer : observers_) 150 for (auto& observer : observers_)
147 observer.OnGCMRegistrationResult(true); 151 observer.OnGCMRegistrationResult(true);
148 } 152 }
149 153
150 } // namespace proximity_auth 154 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698