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

Side by Side 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 3 years, 12 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2004 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "third_party/libjingle_xmpp/xmpp/xmpppump.h"
6
7 #include "third_party/libjingle_xmpp/xmpp/xmppauth.h"
8
9 namespace buzz {
10
11 XmppPump::XmppPump(XmppPumpNotify * notify) {
12 state_ = buzz::XmppEngine::STATE_NONE;
13 notify_ = notify;
14 client_ = new buzz::XmppClient(this); // NOTE: deleted by TaskRunner
15 }
16
17 void XmppPump::DoLogin(const buzz::XmppClientSettings & xcs,
18 buzz::AsyncSocket* socket,
19 buzz::PreXmppAuth* auth) {
20 OnStateChange(buzz::XmppEngine::STATE_START);
21 if (!AllChildrenDone()) {
22 client_->SignalStateChange.connect(this, &XmppPump::OnStateChange);
23 client_->Connect(xcs, "", socket, auth);
24 client_->Start();
25 }
26 }
27
28 void XmppPump::DoDisconnect() {
29 if (!AllChildrenDone())
30 client_->Disconnect();
31 OnStateChange(buzz::XmppEngine::STATE_CLOSED);
32 }
33
34 void XmppPump::OnStateChange(buzz::XmppEngine::State state) {
35 if (state_ == state)
36 return;
37 state_ = state;
38 if (notify_ != NULL)
39 notify_->OnStateChange(state);
40 }
41
42 void XmppPump::WakeTasks() {
43 rtc::Thread::Current()->Post(RTC_FROM_HERE, this);
44 }
45
46 int64_t XmppPump::CurrentTime() {
47 return (int64_t)rtc::TimeMillis();
48 }
49
50 void XmppPump::OnMessage(rtc::Message *pmsg) {
51 RunTasks();
52 }
53
54 buzz::XmppReturnStatus XmppPump::SendStanza(const buzz::XmlElement *stanza) {
55 if (!AllChildrenDone())
56 return client_->SendStanza(stanza);
57 return buzz::XMPP_RETURN_BADSTATE;
58 }
59
60 } // namespace buzz
61
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698