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

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

Issue 3087003: Added HostKeyPair class, signatures for heartbeat messages. (Closed)
Patch Set: - Created 10 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
« no previous file with comments | « remoting/host/test_key_pair.h ('k') | remoting/jingle_glue/jingle_channel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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.h" 10 #include "base/callback.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "third_party/libjingle/source/talk/xmpp/xmppengine.h" 12 #include "third_party/libjingle/source/talk/xmpp/xmppengine.h"
13 13
14 namespace remoting { 14 namespace remoting {
15 15
16 class JingleClient; 16 class JingleClient;
17 17
18 // IqRequest class can be used to send an IQ stanza and then receive reply 18 // IqRequest class can be used to send an IQ stanza and then receive reply
19 // stanza for that request. It sends outgoing stanza when SendIq() is called, 19 // stanza for that request. It sends outgoing stanza when SendIq() is called,
20 // after that it forwards incoming reply stanza to the callback set with 20 // after that it forwards incoming reply stanza to the callback set with
21 // set_callback(). If multiple IQ stanzas are send with SendIq() then only reply 21 // set_callback(). If multiple IQ stanzas are send with SendIq() then only reply
22 // to the last one will be received. 22 // to the last one will be received.
23 // The class must be used on the jingle thread only. 23 // The class must be used on the jingle thread only.
24 // TODO(sergeyu): Implement unittests for this class.
25 class IqRequest : private buzz::XmppIqHandler { 24 class IqRequest : private buzz::XmppIqHandler {
26 public: 25 public:
27 typedef Callback1<const buzz::XmlElement*>::Type ReplyCallback; 26 typedef Callback1<const buzz::XmlElement*>::Type ReplyCallback;
28 27
29 explicit IqRequest(JingleClient* jingle_client); 28 explicit IqRequest(JingleClient* jingle_client);
30 virtual ~IqRequest(); 29 virtual ~IqRequest();
31 30
32 // 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
33 // the stanza. Ownership of |iq_body| is transfered to IqRequest. Must 32 // the stanza. Ownership of |iq_body| is transfered to IqRequest. Must
34 // be called on the jingle thread. 33 // be called on the jingle thread.
35 void SendIq(const std::string& type, const std::string& addressee, 34 virtual void SendIq(const std::string& type, const std::string& addressee,
36 buzz::XmlElement* iq_body); 35 buzz::XmlElement* iq_body);
37 36
38 // Sets callback that is called when reply stanza is received. Callback 37 // Sets callback that is called when reply stanza is received. Callback
39 // is called on the jingle thread. 38 // is called on the jingle thread.
40 void set_callback(ReplyCallback* callback) { 39 void set_callback(ReplyCallback* callback) {
41 callback_.reset(callback); 40 callback_.reset(callback);
42 } 41 }
43 42
44 private: 43 private:
45 FRIEND_TEST_ALL_PREFIXES(IqRequestTest, MakeIqStanza); 44 FRIEND_TEST_ALL_PREFIXES(IqRequestTest, MakeIqStanza);
46 45
47 // XmppIqHandler interface. 46 // XmppIqHandler interface.
48 virtual void IqResponse(buzz::XmppIqCookie cookie, 47 virtual void IqResponse(buzz::XmppIqCookie cookie,
49 const buzz::XmlElement* stanza); 48 const buzz::XmlElement* stanza);
50 49
51 static buzz::XmlElement* MakeIqStanza(const std::string& type, 50 static buzz::XmlElement* MakeIqStanza(const std::string& type,
52 const std::string& addressee, 51 const std::string& addressee,
53 buzz::XmlElement* iq_body, 52 buzz::XmlElement* iq_body,
54 const std::string& id); 53 const std::string& id);
55 54
56 void Unregister(); 55 void Unregister();
57 56
58 scoped_refptr<JingleClient> jingle_client_; 57 scoped_refptr<JingleClient> jingle_client_;
59 buzz::XmppIqCookie cookie_; 58 buzz::XmppIqCookie cookie_;
60 scoped_ptr<ReplyCallback> callback_; 59 scoped_ptr<ReplyCallback> callback_;
61 }; 60 };
62 61
63 } // namespace remoting 62 } // namespace remoting
64 63
65 #endif // REMOTING_JINGLE_GLUE_IQ_REQUEST_H_ 64 #endif // REMOTING_JINGLE_GLUE_IQ_REQUEST_H_
OLDNEW
« no previous file with comments | « remoting/host/test_key_pair.h ('k') | remoting/jingle_glue/jingle_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698