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

Side by Side Diff: components/gcm_driver/fake_gcm_client.cc

Issue 442123003: [GCM] Adding the OnSendAcknowledgement event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing code review comments. Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « components/gcm_driver/fake_gcm_client.h ('k') | components/gcm_driver/gcm_app_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/gcm_driver/fake_gcm_client.h" 5 #include "components/gcm_driver/fake_gcm_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 send_error_details.message_id = message.id; 196 send_error_details.message_id = message.id;
197 send_error_details.result = NETWORK_ERROR; 197 send_error_details.result = NETWORK_ERROR;
198 send_error_details.additional_data = message.data; 198 send_error_details.additional_data = message.data;
199 base::MessageLoop::current()->PostDelayedTask( 199 base::MessageLoop::current()->PostDelayedTask(
200 FROM_HERE, 200 FROM_HERE,
201 base::Bind(&FakeGCMClient::MessageSendError, 201 base::Bind(&FakeGCMClient::MessageSendError,
202 weak_ptr_factory_.GetWeakPtr(), 202 weak_ptr_factory_.GetWeakPtr(),
203 app_id, 203 app_id,
204 send_error_details), 204 send_error_details),
205 base::TimeDelta::FromMilliseconds(200)); 205 base::TimeDelta::FromMilliseconds(200));
206 } else if(message.id.find("ack") != std::string::npos) {
207 base::MessageLoop::current()->PostDelayedTask(
208 FROM_HERE,
209 base::Bind(&FakeGCMClient::SendAcknowledgement,
210 weak_ptr_factory_.GetWeakPtr(),
211 app_id,
212 message.id),
213 base::TimeDelta::FromMilliseconds(200));
214
206 } 215 }
207 } 216 }
208 217
209 void FakeGCMClient::MessageReceived(const std::string& app_id, 218 void FakeGCMClient::MessageReceived(const std::string& app_id,
210 const IncomingMessage& message) { 219 const IncomingMessage& message) {
211 if (delegate_) 220 if (delegate_)
212 delegate_->OnMessageReceived(app_id, message); 221 delegate_->OnMessageReceived(app_id, message);
213 } 222 }
214 223
215 void FakeGCMClient::MessagesDeleted(const std::string& app_id) { 224 void FakeGCMClient::MessagesDeleted(const std::string& app_id) {
216 if (delegate_) 225 if (delegate_)
217 delegate_->OnMessagesDeleted(app_id); 226 delegate_->OnMessagesDeleted(app_id);
218 } 227 }
219 228
220 void FakeGCMClient::MessageSendError( 229 void FakeGCMClient::MessageSendError(
221 const std::string& app_id, 230 const std::string& app_id,
222 const GCMClient::SendErrorDetails& send_error_details) { 231 const GCMClient::SendErrorDetails& send_error_details) {
223 if (delegate_) 232 if (delegate_)
224 delegate_->OnMessageSendError(app_id, send_error_details); 233 delegate_->OnMessageSendError(app_id, send_error_details);
225 } 234 }
226 235
236 void FakeGCMClient::SendAcknowledgement(const std::string& app_id,
237 const std::string& message_id) {
238 if (delegate_)
239 delegate_->OnSendAcknowledged(app_id, message_id);
240 }
241
227 } // namespace gcm 242 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/fake_gcm_client.h ('k') | components/gcm_driver/gcm_app_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698