| 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..a0b30d5f9cbd1d9a2016b7bf01b36e1a776aac34 100644
|
| --- a/components/gcm_driver/gcm_client_impl.cc
|
| +++ b/components/gcm_driver/gcm_client_impl.cc
|
| @@ -878,9 +878,8 @@ void GCMClientImpl::Register(
|
| GCMRegistrationInfo::FromRegistrationInfo(
|
| registrations_iter->first.get());
|
| DCHECK(cached_gcm_registration_info);
|
| - if (cached_gcm_registration_info &&
|
| - gcm_registration_info->sender_ids !=
|
| - cached_gcm_registration_info->sender_ids) {
|
| + if (gcm_registration_info->sender_ids !=
|
| + cached_gcm_registration_info->sender_ids) {
|
| matched = false;
|
| }
|
| }
|
| @@ -999,6 +998,40 @@ 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 (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);
|
|
|