blob: 015d2db9458191bcdb3d6a7dc74665ac6aeeedd0 (
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
46
47
48
49
50
51
52
53
|
// Copyright (c) 2011 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_JINGLE_GLUE_IQ_REQUEST_H_
#define REMOTING_JINGLE_GLUE_IQ_REQUEST_H_
#include <string>
#include "base/callback.h"
#include "base/gtest_prod_util.h"
namespace buzz {
class XmlElement;
} // namespace buzz
namespace remoting {
// IqRequest class can be used to send an IQ stanza and then receive reply
// stanza for that request. It sends outgoing stanza when SendIq() is called,
// after that it forwards incoming reply stanza to the callback set with
// set_callback(). If each call to SendIq() will yield one invocation of the
// callback with the response.
class IqRequest {
public:
typedef base::Callback<void(const buzz::XmlElement*)> ReplyCallback;
IqRequest() {}
virtual ~IqRequest() {}
// Sends stanza of type |type| to |addressee|. |iq_body| contains body of
// the stanza. Takes pwnership of |iq_body|.
virtual void SendIq(const std::string& type, const std::string& addressee,
buzz::XmlElement* iq_body) = 0;
// Sets callback that is called when reply stanza is received.
virtual void set_callback(const ReplyCallback& callback) = 0;
protected:
static buzz::XmlElement* MakeIqStanza(const std::string& type,
const std::string& addressee,
buzz::XmlElement* iq_body,
const std::string& id);
private:
FRIEND_TEST_ALL_PREFIXES(IqRequestTest, MakeIqStanza);
DISALLOW_COPY_AND_ASSIGN(IqRequest);
};
} // namespace remoting
#endif // REMOTING_JINGLE_GLUE_IQ_REQUEST_H_
|