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

Unified Diff: third_party/libjingle_xmpp/xmpp/xmpppump.cc

Issue 2443903004: Add xmllite and xmpp sources to third_party/ (Closed)
Patch Set: Fix GN and sort includes Created 4 years 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: third_party/libjingle_xmpp/xmpp/xmpppump.cc
diff --git a/third_party/libjingle_xmpp/xmpp/xmpppump.cc b/third_party/libjingle_xmpp/xmpp/xmpppump.cc
new file mode 100644
index 0000000000000000000000000000000000000000..980cf0000bef41f94a3fd977129baf30b5a68e61
--- /dev/null
+++ b/third_party/libjingle_xmpp/xmpp/xmpppump.cc
@@ -0,0 +1,61 @@
+// Copyright 2004 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 "third_party/libjingle_xmpp/xmpp/xmpppump.h"
+
+#include "third_party/libjingle_xmpp/xmpp/xmppauth.h"
+
+namespace buzz {
+
+XmppPump::XmppPump(XmppPumpNotify * notify) {
+ state_ = buzz::XmppEngine::STATE_NONE;
+ notify_ = notify;
+ client_ = new buzz::XmppClient(this); // NOTE: deleted by TaskRunner
+}
+
+void XmppPump::DoLogin(const buzz::XmppClientSettings & xcs,
+ buzz::AsyncSocket* socket,
+ buzz::PreXmppAuth* auth) {
+ OnStateChange(buzz::XmppEngine::STATE_START);
+ if (!AllChildrenDone()) {
+ client_->SignalStateChange.connect(this, &XmppPump::OnStateChange);
+ client_->Connect(xcs, "", socket, auth);
+ client_->Start();
+ }
+}
+
+void XmppPump::DoDisconnect() {
+ if (!AllChildrenDone())
+ client_->Disconnect();
+ OnStateChange(buzz::XmppEngine::STATE_CLOSED);
+}
+
+void XmppPump::OnStateChange(buzz::XmppEngine::State state) {
+ if (state_ == state)
+ return;
+ state_ = state;
+ if (notify_ != NULL)
+ notify_->OnStateChange(state);
+}
+
+void XmppPump::WakeTasks() {
+ rtc::Thread::Current()->Post(RTC_FROM_HERE, this);
+}
+
+int64_t XmppPump::CurrentTime() {
+ return (int64_t)rtc::TimeMillis();
+}
+
+void XmppPump::OnMessage(rtc::Message *pmsg) {
+ RunTasks();
+}
+
+buzz::XmppReturnStatus XmppPump::SendStanza(const buzz::XmlElement *stanza) {
+ if (!AllChildrenDone())
+ return client_->SendStanza(stanza);
+ return buzz::XMPP_RETURN_BADSTATE;
+}
+
+} // namespace buzz
+

Powered by Google App Engine
This is Rietveld 408576698