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

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

Issue 2578583002: Provide a mechanism for the GCM driver to send message receipts to GCM.
Patch Set: Adding new file I missed previously. Created 3 years, 11 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 <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 20 matching lines...) Expand all
31 void OnRegisterFinished(const std::string& app_id, 31 void OnRegisterFinished(const std::string& app_id,
32 const std::string& registration_id, 32 const std::string& registration_id,
33 GCMClient::Result result); 33 GCMClient::Result result);
34 void OnUnregisterFinished(const std::string& app_id, 34 void OnUnregisterFinished(const std::string& app_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(const std::string& app_id,
41 const IncomingMessage& message); 41 const IncomingMessage& message,
42 const GCMClient::MessageReceiptCallback& callback);
42 43
43 protected: 44 protected:
44 // FakeGCMDriverForInstanceID overrides: 45 // FakeGCMDriverForInstanceID overrides:
45 void RegisterImpl(const std::string& app_id, 46 void RegisterImpl(const std::string& app_id,
46 const std::vector<std::string>& sender_ids) override; 47 const std::vector<std::string>& sender_ids) override;
47 void UnregisterImpl(const std::string& app_id) override; 48 void UnregisterImpl(const std::string& app_id) override;
48 void UnregisterWithSenderIdImpl(const std::string& app_id, 49 void UnregisterWithSenderIdImpl(const std::string& app_id,
49 const std::string& sender_id) override; 50 const std::string& sender_id) override;
50 void SendImpl(const std::string& app_id, 51 void SendImpl(const std::string& app_id,
51 const std::string& receiver_id, 52 const std::string& receiver_id,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 GCMClient::Result result) { 104 GCMClient::Result result) {
104 UnregisterFinished(app_id, result); 105 UnregisterFinished(app_id, result);
105 } 106 }
106 107
107 void CustomFakeGCMDriver::OnSendFinished(const std::string& app_id, 108 void CustomFakeGCMDriver::OnSendFinished(const std::string& app_id,
108 const std::string& message_id, 109 const std::string& message_id,
109 GCMClient::Result result) { 110 GCMClient::Result result) {
110 SendFinished(app_id, message_id, result); 111 SendFinished(app_id, message_id, result);
111 } 112 }
112 113
113 void CustomFakeGCMDriver::OnDispatchMessage(const std::string& app_id, 114 void CustomFakeGCMDriver::OnDispatchMessage(
114 const IncomingMessage& message) { 115 const std::string& app_id,
115 DispatchMessage(app_id, message); 116 const IncomingMessage& message,
117 const GCMClient::MessageReceiptCallback& callback) {
118 DispatchMessage(app_id, message, callback);
116 } 119 }
117 120
118 } // namespace 121 } // namespace
119 122
120 // static 123 // static
121 std::unique_ptr<KeyedService> FakeGCMProfileService::Build( 124 std::unique_ptr<KeyedService> FakeGCMProfileService::Build(
122 content::BrowserContext* context) { 125 content::BrowserContext* context) {
123 Profile* profile = static_cast<Profile*>(context); 126 Profile* profile = static_cast<Profile*>(context);
124 std::unique_ptr<FakeGCMProfileService> service( 127 std::unique_ptr<FakeGCMProfileService> service(
125 new FakeGCMProfileService(profile)); 128 new FakeGCMProfileService(profile));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 void FakeGCMProfileService::AddExpectedUnregisterResponse( 190 void FakeGCMProfileService::AddExpectedUnregisterResponse(
188 GCMClient::Result result) { 191 GCMClient::Result result) {
189 unregister_responses_.push_back(result); 192 unregister_responses_.push_back(result);
190 } 193 }
191 194
192 void FakeGCMProfileService::SetUnregisterCallback( 195 void FakeGCMProfileService::SetUnregisterCallback(
193 const UnregisterCallback& callback) { 196 const UnregisterCallback& callback) {
194 unregister_callback_ = callback; 197 unregister_callback_ = callback;
195 } 198 }
196 199
197 void FakeGCMProfileService::DispatchMessage(const std::string& app_id, 200 void FakeGCMProfileService::DispatchMessage(
198 const IncomingMessage& message) { 201 const std::string& app_id,
202 const IncomingMessage& message,
203 const GCMClient::MessageReceiptCallback& callback) {
199 CustomFakeGCMDriver* custom_driver = 204 CustomFakeGCMDriver* custom_driver =
200 static_cast<CustomFakeGCMDriver*>(driver()); 205 static_cast<CustomFakeGCMDriver*>(driver());
201 custom_driver->OnDispatchMessage(app_id, message); 206 custom_driver->OnDispatchMessage(app_id, message, callback);
202 } 207 }
203 208
204 } // namespace gcm 209 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698