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

Unified Diff: components/gcm_driver/gcm_driver_desktop.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/gcm_driver/gcm_driver_desktop.h ('k') | components/gcm_driver/gcm_driver_desktop_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/gcm_driver/gcm_driver_desktop.cc
diff --git a/components/gcm_driver/gcm_driver_desktop.cc b/components/gcm_driver/gcm_driver_desktop.cc
index 599957d2a5979fced996c2440031f4cee4344b7c..4d7cf9beb8b9ea696e8e289be6dc7602d783b978 100644
--- a/components/gcm_driver/gcm_driver_desktop.cc
+++ b/components/gcm_driver/gcm_driver_desktop.cc
@@ -53,8 +53,10 @@ class GCMDriverDesktop::IOWorker : public GCMClient::Delegate {
void OnSendFinished(const std::string& app_id,
const std::string& message_id,
GCMClient::Result result) override;
- void OnMessageReceived(const std::string& app_id,
- const IncomingMessage& message) override;
+ void OnMessageReceived(
+ const std::string& app_id,
+ const IncomingMessage& message,
+ const MessageReceiptCallback& optional_receipt_callback) override;
void OnMessagesDeleted(const std::string& app_id) override;
void OnMessageSendError(
const std::string& app_id,
@@ -233,15 +235,13 @@ void GCMDriverDesktop::IOWorker::OnSendFinished(const std::string& app_id,
void GCMDriverDesktop::IOWorker::OnMessageReceived(
const std::string& app_id,
- const IncomingMessage& message) {
+ const IncomingMessage& message,
+ const MessageReceiptCallback& optional_receipt_callback) {
DCHECK(io_thread_->RunsTasksOnCurrentThread());
- ui_thread_->PostTask(
- FROM_HERE,
- base::Bind(&GCMDriverDesktop::MessageReceived,
- service_,
- app_id,
- message));
+ ui_thread_->PostTask(FROM_HERE,
+ base::Bind(&GCMDriverDesktop::MessageReceived, service_,
+ app_id, message, optional_receipt_callback));
}
void GCMDriverDesktop::IOWorker::OnMessagesDeleted(const std::string& app_id) {
@@ -1215,15 +1215,22 @@ void GCMDriverDesktop::RemoveCachedData() {
ClearCallbacks();
}
-void GCMDriverDesktop::MessageReceived(const std::string& app_id,
- const IncomingMessage& message) {
+void GCMDriverDesktop::MessageReceived(
+ const std::string& app_id,
+ const IncomingMessage& message,
+ const MessageReceiptCallback& optional_receipt_callback) {
DCHECK(ui_thread_->RunsTasksOnCurrentThread());
// Drop the event if the service has been stopped.
if (!gcm_started_)
return;
- DispatchMessage(app_id, message);
+ // Dispatch the message to the GCMDriver, but wrap the IO bound callback in a
+ // new callback which should be called on the UI thread.
+ DispatchMessage(
+ app_id, message,
+ base::Bind(&GCMDriverDesktop::DoSendMessageReceipt,
+ weak_ptr_factory_.GetWeakPtr(), optional_receipt_callback));
}
void GCMDriverDesktop::MessagesDeleted(const std::string& app_id) {
@@ -1342,4 +1349,12 @@ bool GCMDriverDesktop::TokenTupleComparer::operator()(
return std::get<2>(a) < std::get<2>(b);
}
+void GCMDriverDesktop::DoSendMessageReceipt(
+ const MessageReceiptCallback& optional_receipt_callback,
+ GCMMessageStatus status) {
+ DCHECK(ui_thread_->RunsTasksOnCurrentThread());
+
+ io_thread_->PostTask(FROM_HERE,
+ base::Bind(optional_receipt_callback, status));
+}
} // namespace gcm
« no previous file with comments | « components/gcm_driver/gcm_driver_desktop.h ('k') | components/gcm_driver/gcm_driver_desktop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698