| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SIGNALING_IQ_SENDER_H_ | 5 #ifndef REMOTING_SIGNALING_IQ_SENDER_H_ |
| 6 #define REMOTING_SIGNALING_IQ_SENDER_H_ | 6 #define REMOTING_SIGNALING_IQ_SENDER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // IqSender handles sending iq requests and routing of responses to | 31 // IqSender handles sending iq requests and routing of responses to |
| 32 // those requests. | 32 // those requests. |
| 33 class IqSender : public SignalStrategy::Listener { | 33 class IqSender : public SignalStrategy::Listener { |
| 34 public: | 34 public: |
| 35 // Callback that is called when an Iq response is received. Called | 35 // Callback that is called when an Iq response is received. Called |
| 36 // with the |response| set to NULL in case of a timeout. | 36 // with the |response| set to NULL in case of a timeout. |
| 37 typedef base::Callback<void(IqRequest* request, | 37 typedef base::Callback<void(IqRequest* request, |
| 38 const buzz::XmlElement* response)> ReplyCallback; | 38 const buzz::XmlElement* response)> ReplyCallback; |
| 39 | 39 |
| 40 explicit IqSender(SignalStrategy* signal_strategy); | 40 explicit IqSender(SignalStrategy* signal_strategy); |
| 41 virtual ~IqSender(); | 41 ~IqSender() override; |
| 42 | 42 |
| 43 // Send an iq stanza. Returns an IqRequest object that represends | 43 // Send an iq stanza. Returns an IqRequest object that represends |
| 44 // the request. |callback| is called when response to |stanza| is | 44 // the request. |callback| is called when response to |stanza| is |
| 45 // received. Destroy the returned IqRequest to cancel the callback. | 45 // received. Destroy the returned IqRequest to cancel the callback. |
| 46 // Caller must take ownership of the result. Result must be | 46 // Caller must take ownership of the result. Result must be |
| 47 // destroyed before sender is destroyed. | 47 // destroyed before sender is destroyed. |
| 48 scoped_ptr<IqRequest> SendIq(scoped_ptr<buzz::XmlElement> stanza, | 48 scoped_ptr<IqRequest> SendIq(scoped_ptr<buzz::XmlElement> stanza, |
| 49 const ReplyCallback& callback); | 49 const ReplyCallback& callback); |
| 50 | 50 |
| 51 // Same as above, but also formats the message. | 51 // Same as above, but also formats the message. |
| 52 scoped_ptr<IqRequest> SendIq(const std::string& type, | 52 scoped_ptr<IqRequest> SendIq(const std::string& type, |
| 53 const std::string& addressee, | 53 const std::string& addressee, |
| 54 scoped_ptr<buzz::XmlElement> iq_body, | 54 scoped_ptr<buzz::XmlElement> iq_body, |
| 55 const ReplyCallback& callback); | 55 const ReplyCallback& callback); |
| 56 | 56 |
| 57 // SignalStrategy::Listener implementation. | 57 // SignalStrategy::Listener implementation. |
| 58 virtual void OnSignalStrategyStateChange( | 58 void OnSignalStrategyStateChange(SignalStrategy::State state) override; |
| 59 SignalStrategy::State state) override; | 59 bool OnSignalStrategyIncomingStanza(const buzz::XmlElement* stanza) override; |
| 60 virtual bool OnSignalStrategyIncomingStanza( | |
| 61 const buzz::XmlElement* stanza) override; | |
| 62 | 60 |
| 63 private: | 61 private: |
| 64 typedef std::map<std::string, IqRequest*> IqRequestMap; | 62 typedef std::map<std::string, IqRequest*> IqRequestMap; |
| 65 friend class IqRequest; | 63 friend class IqRequest; |
| 66 | 64 |
| 67 // Helper function used to create iq stanzas. | 65 // Helper function used to create iq stanzas. |
| 68 static scoped_ptr<buzz::XmlElement> MakeIqStanza( | 66 static scoped_ptr<buzz::XmlElement> MakeIqStanza( |
| 69 const std::string& type, | 67 const std::string& type, |
| 70 const std::string& addressee, | 68 const std::string& addressee, |
| 71 scoped_ptr<buzz::XmlElement> iq_body); | 69 scoped_ptr<buzz::XmlElement> iq_body); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 IqSender* sender_; | 102 IqSender* sender_; |
| 105 IqSender::ReplyCallback callback_; | 103 IqSender::ReplyCallback callback_; |
| 106 std::string addressee_; | 104 std::string addressee_; |
| 107 | 105 |
| 108 DISALLOW_COPY_AND_ASSIGN(IqRequest); | 106 DISALLOW_COPY_AND_ASSIGN(IqRequest); |
| 109 }; | 107 }; |
| 110 | 108 |
| 111 } // namespace remoting | 109 } // namespace remoting |
| 112 | 110 |
| 113 #endif // REMOTING_SIGNALING_IQ_SENDER_H_ | 111 #endif // REMOTING_SIGNALING_IQ_SENDER_H_ |
| OLD | NEW |