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

Unified Diff: jingle/notifier/listener/send_ping_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: added missing files 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/send_ping_task.cc
diff --git a/jingle/notifier/listener/send_ping_task.cc b/jingle/notifier/listener/send_ping_task.cc
new file mode 100644
index 0000000000000000000000000000000000000000..44ca252648a07006bead716a97ca950e1e8952f9
--- /dev/null
+++ b/jingle/notifier/listener/send_ping_task.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "jingle/notifier/listener/send_ping_task.h"
+
+#include <string>
+
+#include "base/base64.h"
akalin 2012/10/24 21:45:35 no need for base64
gene 2012/10/24 22:30:09 Done.
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "jingle/notifier/listener/notification_constants.h"
akalin 2012/10/24 21:45:35 no need for notification_constants?
gene 2012/10/24 22:30:09 Done.
+#include "jingle/notifier/listener/xml_element_util.h"
+#include "talk/xmllite/qname.h"
+#include "talk/xmllite/xmlelement.h"
+#include "talk/xmpp/constants.h"
+#include "talk/xmpp/jid.h"
+#include "talk/xmpp/xmppclient.h"
+
+namespace notifier {
+
+SendPingTask::SendPingTask(buzz::XmppTaskParentInterface* parent)
+ : XmppTask(parent) {
+}
+
+SendPingTask::~SendPingTask() {
+}
+
+int SendPingTask::ProcessStart() {
+ scoped_ptr<buzz::XmlElement> stanza;
akalin 2012/10/24 21:45:35 just initialize stanza directly from MakePingStanz
gene 2012/10/24 22:30:09 Done.
+ stanza.reset(MakePingStanza(task_id()));
+
+ DVLOG(1) << "Sending ping stanza " << XmlElementToString(*stanza);
+ if (SendStanza(stanza.get()) != buzz::XMPP_RETURN_OK) {
+ LOG(WARNING) << "Could not send stanza " << XmlElementToString(*stanza);
+ }
+ return STATE_DONE;
+}
+
+buzz::XmlElement* SendPingTask::MakePingStanza(const std::string& task_id) {
+ 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