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

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

Issue 955673004: Move gcm-independent parts of push messaging out of gcm namespace and directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: buildfix push_messaging_application_id_unittest Created 5 years, 9 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 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/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 KeyedService* FakeGCMProfileService::Build(content::BrowserContext* context) { 108 KeyedService* FakeGCMProfileService::Build(content::BrowserContext* context) {
109 Profile* profile = static_cast<Profile*>(context); 109 Profile* profile = static_cast<Profile*>(context);
110 FakeGCMProfileService* service = new FakeGCMProfileService(profile); 110 FakeGCMProfileService* service = new FakeGCMProfileService(profile);
111 service->SetDriverForTesting(new CustomFakeGCMDriver(service)); 111 service->SetDriverForTesting(new CustomFakeGCMDriver(service));
112 return service; 112 return service;
113 } 113 }
114 114
115 FakeGCMProfileService::FakeGCMProfileService(Profile* profile) 115 FakeGCMProfileService::FakeGCMProfileService(Profile* profile)
116 : collect_(false), 116 : collect_(false),
117 registration_count_(0) { 117 registration_count_(0) {
118 static_cast<PushMessagingServiceImpl*>(push_messaging_service())
119 ->SetProfileForTesting(profile);
120 } 118 }
121 119
122 FakeGCMProfileService::~FakeGCMProfileService() {} 120 FakeGCMProfileService::~FakeGCMProfileService() {}
123 121
122 FakeGCMProfileService* FakeGCMProfileService::AsFakeGCMProfileService() {
123 return this;
124 }
125
124 void FakeGCMProfileService::RegisterFinished( 126 void FakeGCMProfileService::RegisterFinished(
125 const std::string& app_id, 127 const std::string& app_id,
126 const std::vector<std::string>& sender_ids) { 128 const std::vector<std::string>& sender_ids) {
127 if (collect_) { 129 if (collect_) {
128 last_registered_app_id_ = app_id; 130 last_registered_app_id_ = app_id;
129 last_registered_sender_ids_ = sender_ids; 131 last_registered_sender_ids_ = sender_ids;
130 } 132 }
131 133
132 // Generate fake registration IDs, encoding the number of sender IDs (used by 134 // Generate fake registration IDs, encoding the number of sender IDs (used by
133 // GcmApiTest.RegisterValidation), then an incrementing count (even for the 135 // GcmApiTest.RegisterValidation), then an incrementing count (even for the
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 GCMClient::Result result) { 178 GCMClient::Result result) {
177 unregister_responses_.push_back(result); 179 unregister_responses_.push_back(result);
178 } 180 }
179 181
180 void FakeGCMProfileService::SetUnregisterCallback( 182 void FakeGCMProfileService::SetUnregisterCallback(
181 const UnregisterCallback& callback) { 183 const UnregisterCallback& callback) {
182 unregister_callback_ = callback; 184 unregister_callback_ = callback;
183 } 185 }
184 186
185 } // namespace gcm 187 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698