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

Side by Side Diff: third_party/libjingle_xmpp/xmpp/xmppstanzaparser.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 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/xmppstanzaparser.h"
6
7 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h"
8 #include "third_party/libjingle_xmpp/xmpp/constants.h"
9 #include "webrtc/base/common.h"
10 #ifdef EXPAT_RELATIVE_PATH
11 #include "expat.h"
12 #else
13 #include "third_party/expat/v2_0_1/Source/lib/expat.h"
14 #endif
15
16 namespace buzz {
17
18 XmppStanzaParser::XmppStanzaParser(XmppStanzaParseHandler *psph) :
19 psph_(psph),
20 innerHandler_(this),
21 parser_(&innerHandler_),
22 depth_(0),
23 builder_() {
24 }
25
26 void
27 XmppStanzaParser::Reset() {
28 parser_.Reset();
29 depth_ = 0;
30 builder_.Reset();
31 }
32
33 void
34 XmppStanzaParser::IncomingStartElement(
35 XmlParseContext * pctx, const char * name, const char ** atts) {
36 if (depth_++ == 0) {
37 XmlElement * pelStream = XmlBuilder::BuildElement(pctx, name, atts);
38 if (pelStream == NULL) {
39 pctx->RaiseError(XML_ERROR_SYNTAX);
40 return;
41 }
42 psph_->StartStream(pelStream);
43 delete pelStream;
44 return;
45 }
46
47 builder_.StartElement(pctx, name, atts);
48 }
49
50 void
51 XmppStanzaParser::IncomingCharacterData(
52 XmlParseContext * pctx, const char * text, int len) {
53 if (depth_ > 1) {
54 builder_.CharacterData(pctx, text, len);
55 }
56 }
57
58 void
59 XmppStanzaParser::IncomingEndElement(
60 XmlParseContext * pctx, const char * name) {
61 if (--depth_ == 0) {
62 psph_->EndStream();
63 return;
64 }
65
66 builder_.EndElement(pctx, name);
67
68 if (depth_ == 1) {
69 XmlElement *element = builder_.CreateElement();
70 psph_->Stanza(element);
71 delete element;
72 }
73 }
74
75 void
76 XmppStanzaParser::IncomingError(
77 XmlParseContext * pctx, XML_Error errCode) {
78 RTC_UNUSED(pctx);
79 RTC_UNUSED(errCode);
80 psph_->XmlError();
81 }
82
83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698