Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // TODO(crbug.com/661660): Tell server the registration ID is no longer valid. | |
|
Tim Song
2016/11/16 22:28:09
Can you change this comment to:
"We will automatic
johnme
2016/11/17 12:57:25
Done.
| |
| 88 pref_service_->ClearPref(prefs::kCryptAuthGCMRegistrationId); | |
| 89 } | |
| 90 | |
| 86 void CryptAuthGCMManagerImpl::OnMessage(const std::string& app_id, | 91 void CryptAuthGCMManagerImpl::OnMessage(const std::string& app_id, |
| 87 const gcm::IncomingMessage& message) { | 92 const gcm::IncomingMessage& message) { |
| 88 std::vector<std::string> fields; | 93 std::vector<std::string> fields; |
| 89 for (const auto& kv : message.data) { | 94 for (const auto& kv : message.data) { |
| 90 fields.push_back(std::string(kv.first) + ": " + std::string(kv.second)); | 95 fields.push_back(std::string(kv.first) + ": " + std::string(kv.second)); |
| 91 } | 96 } |
| 92 | 97 |
| 93 PA_LOG(INFO) << "GCM message received:\n" | 98 PA_LOG(INFO) << "GCM message received:\n" |
| 94 << " sender_id: " << message.sender_id << "\n" | 99 << " sender_id: " << message.sender_id << "\n" |
| 95 << " collapse_key: " << message.collapse_key << "\n" | 100 << " collapse_key: " << message.collapse_key << "\n" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 } | 146 } |
| 142 | 147 |
| 143 PA_LOG(INFO) << "GCM registration success, registration_id=" | 148 PA_LOG(INFO) << "GCM registration success, registration_id=" |
| 144 << registration_id; | 149 << registration_id; |
| 145 pref_service_->SetString(prefs::kCryptAuthGCMRegistrationId, registration_id); | 150 pref_service_->SetString(prefs::kCryptAuthGCMRegistrationId, registration_id); |
| 146 for (auto& observer : observers_) | 151 for (auto& observer : observers_) |
| 147 observer.OnGCMRegistrationResult(true); | 152 observer.OnGCMRegistrationResult(true); |
| 148 } | 153 } |
| 149 | 154 |
| 150 } // namespace proximity_auth | 155 } // namespace proximity_auth |
| OLD | NEW |