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

Side by Side Diff: chrome/browser/services/gcm/fake_gcm_profile_service.cc

Issue 785983002: Have FakeGCMProfileService return different registration IDs each time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/services/gcm/fake_gcm_profile_service.h" 5 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 // static 105 // static
106 KeyedService* FakeGCMProfileService::Build(content::BrowserContext* context) { 106 KeyedService* FakeGCMProfileService::Build(content::BrowserContext* context) {
107 Profile* profile = static_cast<Profile*>(context); 107 Profile* profile = static_cast<Profile*>(context);
108 FakeGCMProfileService* service = new FakeGCMProfileService(profile); 108 FakeGCMProfileService* service = new FakeGCMProfileService(profile);
109 service->SetDriverForTesting(new CustomFakeGCMDriver(service)); 109 service->SetDriverForTesting(new CustomFakeGCMDriver(service));
110 return service; 110 return service;
111 } 111 }
112 112
113 FakeGCMProfileService::FakeGCMProfileService(Profile* profile) 113 FakeGCMProfileService::FakeGCMProfileService(Profile* profile)
114 : collect_(false) { 114 : collect_(false),
115 registration_count_(0) {
115 static_cast<PushMessagingServiceImpl*>(push_messaging_service()) 116 static_cast<PushMessagingServiceImpl*>(push_messaging_service())
116 ->SetProfileForTesting(profile); 117 ->SetProfileForTesting(profile);
117 } 118 }
118 119
119 FakeGCMProfileService::~FakeGCMProfileService() {} 120 FakeGCMProfileService::~FakeGCMProfileService() {}
120 121
121 void FakeGCMProfileService::RegisterFinished( 122 void FakeGCMProfileService::RegisterFinished(
122 const std::string& app_id, 123 const std::string& app_id,
123 const std::vector<std::string>& sender_ids) { 124 const std::vector<std::string>& sender_ids) {
124 if (collect_) { 125 if (collect_) {
125 last_registered_app_id_ = app_id; 126 last_registered_app_id_ = app_id;
126 last_registered_sender_ids_ = sender_ids; 127 last_registered_sender_ids_ = sender_ids;
127 } 128 }
128 129
129 CustomFakeGCMDriver* custom_driver = 130 CustomFakeGCMDriver* custom_driver =
130 static_cast<CustomFakeGCMDriver*>(driver()); 131 static_cast<CustomFakeGCMDriver*>(driver());
131 custom_driver->OnRegisterFinished(app_id, 132 custom_driver->OnRegisterFinished(app_id,
132 base::UintToString(sender_ids.size()), 133 base::UintToString(1000 * (sender_ids.size() - 1)
134 + (++registration_count_)),
Avi (use Gerrit) 2014/12/08 19:08:43 Put your explanation for this directly into the co
johnme 2014/12/08 20:30:28 Done.
133 GCMClient::SUCCESS); 135 GCMClient::SUCCESS);
134 } 136 }
135 137
136 void FakeGCMProfileService::UnregisterFinished(const std::string& app_id) { 138 void FakeGCMProfileService::UnregisterFinished(const std::string& app_id) {
137 GCMClient::Result result = GCMClient::SUCCESS; 139 GCMClient::Result result = GCMClient::SUCCESS;
138 if (!unregister_responses_.empty()) { 140 if (!unregister_responses_.empty()) {
139 result = unregister_responses_.front(); 141 result = unregister_responses_.front();
140 unregister_responses_.pop_front(); 142 unregister_responses_.pop_front();
141 } 143 }
142 144
(...skipping 23 matching lines...) Expand all
166 GCMClient::Result result) { 168 GCMClient::Result result) {
167 unregister_responses_.push_back(result); 169 unregister_responses_.push_back(result);
168 } 170 }
169 171
170 void FakeGCMProfileService::SetUnregisterCallback( 172 void FakeGCMProfileService::SetUnregisterCallback(
171 const UnregisterCallback& callback) { 173 const UnregisterCallback& callback) {
172 unregister_callback_ = callback; 174 unregister_callback_ = callback;
173 } 175 }
174 176
175 } // namespace gcm 177 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698