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

Unified Diff: components/gcm_driver/fake_gcm_client.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 side-by-side diff with in-line comments
Download patch
Index: components/gcm_driver/fake_gcm_client.cc
diff --git a/components/gcm_driver/fake_gcm_client.cc b/components/gcm_driver/fake_gcm_client.cc
index eaa66c894d182fea831ea919e8b275cdc9edd992..0f36ebaf1cf47688cde72322b9af51e54f4bc739 100644
--- a/components/gcm_driver/fake_gcm_client.cc
+++ b/components/gcm_driver/fake_gcm_client.cc
@@ -18,6 +18,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
+#include "components/sync/base/bind_to_task_runner.h"
#include "google_apis/gcm/base/encryptor.h"
#include "google_apis/gcm/engine/account_mapping.h"
#include "net/base/ip_endpoint.h"
@@ -238,15 +239,26 @@ void FakeGCMClient::PerformDelayedStart() {
}
void FakeGCMClient::ReceiveMessage(const std::string& app_id,
+ const std::string& message_id,
const IncomingMessage& message) {
DCHECK(ui_thread_->RunsTasksOnCurrentThread());
io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&FakeGCMClient::MessageReceived,
- weak_ptr_factory_.GetWeakPtr(),
- app_id,
- message));
+ FROM_HERE, base::Bind(&FakeGCMClient::MessageReceived,
+ weak_ptr_factory_.GetWeakPtr(), app_id, message,
+ base::Bind(&FakeGCMClient::SendMessageReceipt,
+ weak_ptr_factory_.GetWeakPtr(),
+ message_id, app_id)));
+}
+
+void FakeGCMClient::SendMessageReceipt(const std::string& message_id,
+ const std::string& app_id,
+ GCMMessageStatus status) {
+ DCHECK(io_thread_->RunsTasksOnCurrentThread());
+
+ receipt_message_id_ = message_id;
+ receipt_app_id_ = app_id;
+ receipt_status_ = status;
}
void FakeGCMClient::DeleteMessages(const std::string& app_id) {
@@ -302,10 +314,13 @@ void FakeGCMClient::SendFinished(const std::string& app_id,
}
}
-void FakeGCMClient::MessageReceived(const std::string& app_id,
- const IncomingMessage& message) {
+void FakeGCMClient::MessageReceived(
+ const std::string& app_id,
+ const IncomingMessage& message,
+ const GCMClient::MessageReceiptCallback& callback) {
if (delegate_)
- delegate_->OnMessageReceived(app_id, message);
+ delegate_->OnMessageReceived(app_id, message,
+ syncer::BindToCurrentThread(callback));
}
void FakeGCMClient::MessagesDeleted(const std::string& app_id) {

Powered by Google App Engine
This is Rietveld 408576698