summaryrefslogtreecommitdiffstats
path: root/remoting/signaling/xmpp_stream_parser.h
blob: d98bf0e786800d23b28c976f7543b9229e7c0213 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2015 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.

#ifndef REMOTING_SIGNALING_XMPP_STREAM_PARSER_H_
#define REMOTING_SIGNALING_XMPP_STREAM_PARSER_H_

#include <string>

#include "base/callback.h"
#include "base/macros.h"

namespace buzz {
class XmlElement;
}  // namespace buzz

namespace remoting {

// XmppStreamParser is used to parse XMPP stream. Data is fed to the parser
// using appendData() method and it calls |on_stanza_callback\ and
// |on_error_callback| specified using SetCallbacks().
class XmppStreamParser {
 public:
  typedef base::Callback<void(scoped_ptr<buzz::XmlElement> stanza)>
      OnStanzaCallback;

  XmppStreamParser();
  ~XmppStreamParser();

  void SetCallbacks(const OnStanzaCallback& on_stanza_callback,
                    const base::Closure& on_error_callback);

  void AppendData(const std::string& data);

 private:
  class Core;

  scoped_ptr<Core> core_;

  DISALLOW_COPY_AND_ASSIGN(XmppStreamParser);
};

}  // namespace remoting

#endif  // REMOTING_SIGNALING_XMPP_STREAM_PARSER_H_