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

Side by Side Diff: remoting/jingle_glue/iq_request.h

Issue 7744041: Use new callbacks in the IqRequest interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
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_
OLDNEW
« no previous file with comments | « remoting/host/register_support_host_request_unittest.cc ('k') | remoting/jingle_glue/javascript_iq_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698