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

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

Issue 2578583002: Provide a mechanism for the GCM driver to send message receipts to GCM.
Patch Set: Fix issue with rebase Created 3 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 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/gcm/fake_gcm_profile_service.h" 5 #include "chrome/browser/gcm/fake_gcm_profile_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 19 matching lines...) Expand all
30 explicit CustomFakeGCMDriver(FakeGCMProfileService* service); 30 explicit CustomFakeGCMDriver(FakeGCMProfileService* service);
31 ~CustomFakeGCMDriver() override; 31 ~CustomFakeGCMDriver() override;
32 32
33 void OnRegisterFinished(const std::string& app_id, 33 void OnRegisterFinished(const std::string& app_id,
34 const std::string& registration_id, 34 const std::string& registration_id,
35 GCMClient::Result result); 35 GCMClient::Result result);
36 void OnSendFinished(const std::string& app_id, 36 void OnSendFinished(const std::string& app_id,
37 const std::string& message_id, 37 const std::string& message_id,
38 GCMClient::Result result); 38 GCMClient::Result result);
39 39
40 void OnDispatchMessage(const std::string& app_id, 40 void OnDispatchMessage(
41 const IncomingMessage& message); 41 const std::string& app_id,
42 const IncomingMessage& message,
43 const MessageReceiptCallback& optional_receipt_callback);
42 44
43 protected: 45 protected:
44 // FakeGCMDriver overrides: 46 // FakeGCMDriver overrides:
45 void RegisterImpl(const std::string& app_id, 47 void RegisterImpl(const std::string& app_id,
46 const std::vector<std::string>& sender_ids) override; 48 const std::vector<std::string>& sender_ids) override;
47 void UnregisterImpl(const std::string& app_id) override; 49 void UnregisterImpl(const std::string& app_id) override;
48 void UnregisterWithSenderIdImpl(const std::string& app_id, 50 void UnregisterWithSenderIdImpl(const std::string& app_id,
49 const std::string& sender_id) override; 51 const std::string& sender_id) override;
50 void SendImpl(const std::string& app_id, 52 void SendImpl(const std::string& app_id,
51 const std::string& receiver_id, 53 const std::string& receiver_id,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 const DeleteTokenCallback& callback) { 187 const DeleteTokenCallback& callback) {
186 if (service_->is_offline_) 188 if (service_->is_offline_)
187 return; // Drop request. 189 return; // Drop request.
188 190
189 instance_id::FakeGCMDriverForInstanceID::DeleteToken( 191 instance_id::FakeGCMDriverForInstanceID::DeleteToken(
190 app_id, authorized_entity, scope, callback); 192 app_id, authorized_entity, scope, callback);
191 } 193 }
192 194
193 void FakeGCMProfileService::CustomFakeGCMDriver::OnDispatchMessage( 195 void FakeGCMProfileService::CustomFakeGCMDriver::OnDispatchMessage(
194 const std::string& app_id, 196 const std::string& app_id,
195 const IncomingMessage& message) { 197 const IncomingMessage& message,
196 DispatchMessage(app_id, message); 198 const MessageReceiptCallback& optional_receipt_callback) {
199 DispatchMessage(app_id, message, optional_receipt_callback);
197 } 200 }
198 201
199 // static 202 // static
200 std::unique_ptr<KeyedService> FakeGCMProfileService::Build( 203 std::unique_ptr<KeyedService> FakeGCMProfileService::Build(
201 content::BrowserContext* context) { 204 content::BrowserContext* context) {
202 Profile* profile = static_cast<Profile*>(context); 205 Profile* profile = static_cast<Profile*>(context);
203 std::unique_ptr<FakeGCMProfileService> service( 206 std::unique_ptr<FakeGCMProfileService> service(
204 new FakeGCMProfileService(profile)); 207 new FakeGCMProfileService(profile));
205 service->SetDriverForTesting(new CustomFakeGCMDriver(service.get())); 208 service->SetDriverForTesting(new CustomFakeGCMDriver(service.get()));
206 return std::move(service); 209 return std::move(service);
207 } 210 }
208 211
209 FakeGCMProfileService::FakeGCMProfileService(Profile* profile) {} 212 FakeGCMProfileService::FakeGCMProfileService(Profile* profile) {}
210 213
211 FakeGCMProfileService::~FakeGCMProfileService() {} 214 FakeGCMProfileService::~FakeGCMProfileService() {}
212 215
213 void FakeGCMProfileService::AddExpectedUnregisterResponse( 216 void FakeGCMProfileService::AddExpectedUnregisterResponse(
214 GCMClient::Result result) { 217 GCMClient::Result result) {
215 unregister_responses_.push_back(result); 218 unregister_responses_.push_back(result);
216 } 219 }
217 220
218 void FakeGCMProfileService::DispatchMessage(const std::string& app_id, 221 void FakeGCMProfileService::DispatchMessage(
219 const IncomingMessage& message) { 222 const std::string& app_id,
223 const IncomingMessage& message,
224 const MessageReceiptCallback& optional_receipt_callback) {
220 CustomFakeGCMDriver* custom_driver = 225 CustomFakeGCMDriver* custom_driver =
221 static_cast<CustomFakeGCMDriver*>(driver()); 226 static_cast<CustomFakeGCMDriver*>(driver());
222 custom_driver->OnDispatchMessage(app_id, message); 227 custom_driver->OnDispatchMessage(app_id, message, optional_receipt_callback);
223 } 228 }
224 229
225 } // namespace gcm 230 } // namespace gcm
OLDNEW
« no previous file with comments | « chrome/browser/gcm/fake_gcm_profile_service.h ('k') | chrome/browser/push_messaging/push_messaging_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698