Chromium Code Reviews| Index: components/gcm_driver/gcm_client_impl.cc |
| diff --git a/components/gcm_driver/gcm_client_impl.cc b/components/gcm_driver/gcm_client_impl.cc |
| index 5420646009c631e2568e754586fe0e6360884ad9..a609cc902adc33728364bd77e8bd9e93afba6661 100644 |
| --- a/components/gcm_driver/gcm_client_impl.cc |
| +++ b/components/gcm_driver/gcm_client_impl.cc |
| @@ -999,6 +999,41 @@ void GCMClientImpl::OnRegisterCompleted( |
| pending_registration_requests_.erase(iter); |
| } |
| +bool GCMClientImpl::ValidateRegistration( |
| + const linked_ptr<RegistrationInfo>& registration_info, |
| + const std::string& registration_id) { |
| + DCHECK_EQ(state_, READY); |
| + |
| + // Must have a cached registration. |
| + RegistrationInfoMap::const_iterator registrations_iter = |
| + registrations_.find(registration_info); |
| + if (registrations_iter == registrations_.end()) |
| + return false; |
| + |
| + // Cached registration ID must match. |
| + const std::string& cached_registration_id = registrations_iter->second; |
| + if (registration_id != cached_registration_id) |
| + return false; |
| + |
| + // For GCM registration, we also match the sender IDs since multiple |
| + // registrations are not supported. |
| + const GCMRegistrationInfo* gcm_registration_info = |
| + GCMRegistrationInfo::FromRegistrationInfo(registration_info.get()); |
| + if (gcm_registration_info) { |
| + const GCMRegistrationInfo* cached_gcm_registration_info = |
| + GCMRegistrationInfo::FromRegistrationInfo( |
| + registrations_iter->first.get()); |
| + DCHECK(cached_gcm_registration_info); |
| + if (cached_gcm_registration_info && |
|
Peter Beverloo
2017/03/20 23:50:13
nit: don't have to be nice for |!cached_gcm_regist
johnme
2017/03/30 18:36:38
M'ok. In that case I'll also remove the niceness f
|
| + gcm_registration_info->sender_ids != |
| + cached_gcm_registration_info->sender_ids) { |
| + return false; |
| + } |
| + } |
| + |
| + return true; |
| +} |
| + |
| void GCMClientImpl::Unregister( |
| const linked_ptr<RegistrationInfo>& registration_info) { |
| DCHECK_EQ(state_, READY); |