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

Unified Diff: jingle/notifier/listener/push_notifications_send_update_task.cc

Issue 11232048: Adding XMPP ping functionality to CLoudPrint. XMPP ping and timeout is controlled thorugh Service S… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed value Created 8 years, 2 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: jingle/notifier/listener/push_notifications_send_update_task.cc
diff --git a/jingle/notifier/listener/push_notifications_send_update_task.cc b/jingle/notifier/listener/push_notifications_send_update_task.cc
index 50ec15e3cf45ab58336d26730ba77e533cc07b25..166db2330160ab29c5678ef0f8742833115d0605 100644
--- a/jingle/notifier/listener/push_notifications_send_update_task.cc
+++ b/jingle/notifier/listener/push_notifications_send_update_task.cc
@@ -26,9 +26,14 @@ PushNotificationsSendUpdateTask::PushNotificationsSendUpdateTask(
PushNotificationsSendUpdateTask::~PushNotificationsSendUpdateTask() {}
int PushNotificationsSendUpdateTask::ProcessStart() {
- scoped_ptr<buzz::XmlElement> stanza(
- MakeUpdateMessage(notification_,
- GetClient()->jid().BareJid()));
+ scoped_ptr<buzz::XmlElement> stanza;
+ if (notification_.ping) {
+ stanza.reset(MakePingStanza(notification_, task_id()));
akalin 2012/10/23 00:37:21 i think it's better to have a separate PingTask cl
+ } else {
+ stanza.reset(MakeUpdateMessage(notification_,
+ GetClient()->jid().BareJid()));
+ }
+
DVLOG(1) << "Sending notification " << notification_.ToString()
<< " as stanza " << XmlElementToString(*stanza);
if (SendStanza(stanza.get()) != buzz::XMPP_RETURN_OK) {
@@ -91,4 +96,14 @@ buzz::XmlElement* PushNotificationsSendUpdateTask::MakeUpdateMessage(
return message;
}
+buzz::XmlElement* PushNotificationsSendUpdateTask::MakePingStanza(
+ const Notification& notification, const std::string& task_id) {
+ DCHECK(notification.ping);
+ buzz::XmlElement* stanza = MakeIq(buzz::STR_GET,
+ buzz::Jid(buzz::STR_EMPTY),
+ task_id);
+ stanza->AddElement(new buzz::XmlElement(buzz::QN_PING));
+ return stanza;
+}
+
} // namespace notifier

Powered by Google App Engine
This is Rietveld 408576698