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

Unified Diff: chrome/browser/services/gcm/gcm_client_mock.cc

Issue 183923006: [GCM] API update to allow only a single sender in registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/services/gcm/gcm_client_mock.cc
diff --git a/chrome/browser/services/gcm/gcm_client_mock.cc b/chrome/browser/services/gcm/gcm_client_mock.cc
index 656fe558b366fe9eb15284a6bcef253227a7f59f..365a04d412a8542453e6e98b4f045d7a426f6f33 100644
--- a/chrome/browser/services/gcm/gcm_client_mock.cc
+++ b/chrome/browser/services/gcm/gcm_client_mock.cc
@@ -60,12 +60,12 @@ void GCMClientMock::CheckOut() {
void GCMClientMock::Register(const std::string& app_id,
const std::string& cert,
- const std::vector<std::string>& sender_ids) {
+ const std::string& sender_id) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
std::string registration_id;
if (error_simulation_ == ALWAYS_SUCCEED)
- registration_id = GetRegistrationIdFromSenderIds(sender_ids);
+ registration_id = GetRegistrationIdFromSenderIds(sender_id);
base::MessageLoop::current()->PostTask(
FROM_HERE,
@@ -126,24 +126,13 @@ void GCMClientMock::DeleteMessages(const std::string& app_id) {
// static
std::string GCMClientMock::GetRegistrationIdFromSenderIds(
- const std::vector<std::string>& sender_ids) {
- // GCMProfileService normalizes the sender IDs by making them sorted.
- std::vector<std::string> normalized_sender_ids = sender_ids;
- std::sort(normalized_sender_ids.begin(), normalized_sender_ids.end());
-
- // Simulate the registration_id by concaternating all sender IDs.
- // Set registration_id to empty to denote an error if sender_ids contains a
+ const std::string& sender_id) {
+ // Simulate the registration_id by appending reg_id to the sender ID.
+ // Set registration_id to empty to denote an error if sender_id contains a
// hint.
- std::string registration_id;
- if (sender_ids.size() != 1 ||
- sender_ids[0].find("error") == std::string::npos) {
- for (size_t i = 0; i < normalized_sender_ids.size(); ++i) {
- if (i > 0)
- registration_id += ",";
- registration_id += normalized_sender_ids[i];
- }
- }
- return registration_id;
+ if (sender_id.find("error") == std::string::npos)
+ return sender_id + "_reg_id";
+ return std::string();
}
void GCMClientMock::CheckinFinished() {

Powered by Google App Engine
This is Rietveld 408576698