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

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

Issue 2423353002: Reduce usage of FOR_EACH_OBSERVER macro in components/ (Closed)
Patch Set: Created 4 years, 2 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 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 << " collapse_key: " << message.collapse_key << "\n" 95 << " collapse_key: " << message.collapse_key << "\n"
96 << " data:\n " << base::JoinString(fields, "\n "); 96 << " data:\n " << base::JoinString(fields, "\n ");
97 97
98 if (message.data.find(kRegistrationTickleTypeKey) == message.data.end()) { 98 if (message.data.find(kRegistrationTickleTypeKey) == message.data.end()) {
99 PA_LOG(WARNING) << "GCM message does not contain 'registrationTickleType'."; 99 PA_LOG(WARNING) << "GCM message does not contain 'registrationTickleType'.";
100 } else { 100 } else {
101 std::string tickle_type = message.data.at(kRegistrationTickleTypeKey); 101 std::string tickle_type = message.data.at(kRegistrationTickleTypeKey);
102 if (tickle_type == kRegistrationTickleTypeForceEnrollment || 102 if (tickle_type == kRegistrationTickleTypeForceEnrollment ||
103 tickle_type == kRegistrationTickleTypeUpdateEnrollment) { 103 tickle_type == kRegistrationTickleTypeUpdateEnrollment) {
104 // These tickle types correspond to re-enrollment messages. 104 // These tickle types correspond to re-enrollment messages.
105 FOR_EACH_OBSERVER(Observer, observers_, OnReenrollMessage()); 105 for (auto& observer : observers_)
106 observer.OnReenrollMessage();
106 } else if (tickle_type == kRegistrationTickleTypeDevicesSync) { 107 } else if (tickle_type == kRegistrationTickleTypeDevicesSync) {
107 FOR_EACH_OBSERVER(Observer, observers_, OnResyncMessage()); 108 for (auto& observer : observers_)
109 observer.OnResyncMessage();
108 } else { 110 } else {
109 PA_LOG(WARNING) << "Unknown tickle type in GCM message."; 111 PA_LOG(WARNING) << "Unknown tickle type in GCM message.";
110 } 112 }
111 } 113 }
112 } 114 }
113 115
114 void CryptAuthGCMManagerImpl::OnMessagesDeleted(const std::string& app_id) { 116 void CryptAuthGCMManagerImpl::OnMessagesDeleted(const std::string& app_id) {
115 } 117 }
116 118
117 void CryptAuthGCMManagerImpl::OnSendError( 119 void CryptAuthGCMManagerImpl::OnSendError(
118 const std::string& app_id, 120 const std::string& app_id,
119 const gcm::GCMClient::SendErrorDetails& details) { 121 const gcm::GCMClient::SendErrorDetails& details) {
120 NOTREACHED(); 122 NOTREACHED();
121 } 123 }
122 124
123 void CryptAuthGCMManagerImpl::OnSendAcknowledged( 125 void CryptAuthGCMManagerImpl::OnSendAcknowledged(
124 const std::string& app_id, 126 const std::string& app_id,
125 const std::string& message_id) { 127 const std::string& message_id) {
126 NOTREACHED(); 128 NOTREACHED();
127 } 129 }
128 130
129 void CryptAuthGCMManagerImpl::OnRegistrationCompleted( 131 void CryptAuthGCMManagerImpl::OnRegistrationCompleted(
130 const std::string& registration_id, 132 const std::string& registration_id,
131 gcm::GCMClient::Result result) { 133 gcm::GCMClient::Result result) {
132 registration_in_progress_ = false; 134 registration_in_progress_ = false;
133 if (result != gcm::GCMClient::SUCCESS) { 135 if (result != gcm::GCMClient::SUCCESS) {
134 PA_LOG(WARNING) << "GCM registration failed with result=" 136 PA_LOG(WARNING) << "GCM registration failed with result="
135 << static_cast<int>(result); 137 << static_cast<int>(result);
136 FOR_EACH_OBSERVER(Observer, observers_, OnGCMRegistrationResult(false)); 138 for (auto& observer : observers_)
139 observer.OnGCMRegistrationResult(false);
137 return; 140 return;
138 } 141 }
139 142
140 PA_LOG(INFO) << "GCM registration success, registration_id=" 143 PA_LOG(INFO) << "GCM registration success, registration_id="
141 << registration_id; 144 << registration_id;
142 pref_service_->SetString(prefs::kCryptAuthGCMRegistrationId, registration_id); 145 pref_service_->SetString(prefs::kCryptAuthGCMRegistrationId, registration_id);
143 FOR_EACH_OBSERVER(Observer, observers_, OnGCMRegistrationResult(true)); 146 for (auto& observer : observers_)
147 observer.OnGCMRegistrationResult(true);
144 } 148 }
145 149
146 } // namespace proximity_auth 150 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698