OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_JINGLE_GLUE_IQ_REQUEST_H_ | 5 #ifndef REMOTING_JINGLE_GLUE_IQ_REQUEST_H_ |
6 #define REMOTING_JINGLE_GLUE_IQ_REQUEST_H_ | 6 #define REMOTING_JINGLE_GLUE_IQ_REQUEST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback_old.h" | 10 #include "base/callback.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 | 12 |
13 namespace buzz { | 13 namespace buzz { |
14 class XmlElement; | 14 class XmlElement; |
15 } // namespace buzz | 15 } // namespace buzz |
16 | 16 |
17 namespace remoting { | 17 namespace remoting { |
18 | 18 |
19 // IqRequest class can be used to send an IQ stanza and then receive reply | 19 // IqRequest class can be used to send an IQ stanza and then receive reply |
20 // stanza for that request. It sends outgoing stanza when SendIq() is called, | 20 // stanza for that request. It sends outgoing stanza when SendIq() is called, |
21 // after that it forwards incoming reply stanza to the callback set with | 21 // after that it forwards incoming reply stanza to the callback set with |
22 // set_callback(). If each call to SendIq() will yield one invocation of the | 22 // set_callback(). If each call to SendIq() will yield one invocation of the |
23 // callback with the response. | 23 // callback with the response. |
24 class IqRequest { | 24 class IqRequest { |
25 public: | 25 public: |
26 typedef Callback1<const buzz::XmlElement*>::Type ReplyCallback; | 26 typedef base::Callback<void(const buzz::XmlElement*)> ReplyCallback; |
27 | 27 |
28 IqRequest() {} | 28 IqRequest() {} |
29 virtual ~IqRequest() {} | 29 virtual ~IqRequest() {} |
30 | 30 |
31 // Sends stanza of type |type| to |addressee|. |iq_body| contains body of | 31 // Sends stanza of type |type| to |addressee|. |iq_body| contains body of |
32 // the stanza. Ownership of |iq_body| is transfered to IqRequest. Must | 32 // the stanza. Takes pwnership of |iq_body|. |
33 // be called on the jingle thread. | |
34 virtual void SendIq(const std::string& type, const std::string& addressee, | 33 virtual void SendIq(const std::string& type, const std::string& addressee, |
35 buzz::XmlElement* iq_body) = 0; | 34 buzz::XmlElement* iq_body) = 0; |
36 | 35 |
37 // Sets callback that is called when reply stanza is received. Callback | 36 // Sets callback that is called when reply stanza is received. |
38 // is called on the jingle thread. | 37 virtual void set_callback(const ReplyCallback& callback) = 0; |
39 virtual void set_callback(ReplyCallback* callback) = 0; | |
40 | 38 |
41 protected: | 39 protected: |
42 static buzz::XmlElement* MakeIqStanza(const std::string& type, | 40 static buzz::XmlElement* MakeIqStanza(const std::string& type, |
43 const std::string& addressee, | 41 const std::string& addressee, |
44 buzz::XmlElement* iq_body, | 42 buzz::XmlElement* iq_body, |
45 const std::string& id); | 43 const std::string& id); |
46 | 44 |
47 private: | 45 private: |
48 FRIEND_TEST_ALL_PREFIXES(IqRequestTest, MakeIqStanza); | 46 FRIEND_TEST_ALL_PREFIXES(IqRequestTest, MakeIqStanza); |
49 | 47 |
50 DISALLOW_COPY_AND_ASSIGN(IqRequest); | 48 DISALLOW_COPY_AND_ASSIGN(IqRequest); |
51 }; | 49 }; |
52 | 50 |
53 } // namespace remoting | 51 } // namespace remoting |
54 | 52 |
55 #endif // REMOTING_JINGLE_GLUE_IQ_REQUEST_H_ | 53 #endif // REMOTING_JINGLE_GLUE_IQ_REQUEST_H_ |
OLD | NEW |