diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-26 00:28:07 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-26 00:28:07 +0000 |
commit | 137e7cd989d44bf12e57bf4d554fd36e3278f68f (patch) | |
tree | 690dc5e743becae2009b6bf7fbe35ae65c6b79b2 /remoting/jingle_glue/iq_sender.h | |
parent | 76ff037d061c897dce0794628a8c6a442b2777c4 (diff) | |
download | chromium_src-137e7cd989d44bf12e57bf4d554fd36e3278f68f.zip chromium_src-137e7cd989d44bf12e57bf4d554fd36e3278f68f.tar.gz chromium_src-137e7cd989d44bf12e57bf4d554fd36e3278f68f.tar.bz2 |
Implement timeouts for IQ requests.
Now the IqRequest class supports setting timeouts for each request, and
JingleSession uses it to disconnect if no response is receive within 10
secons from a request.
BUG=107925
Review URL: http://codereview.chromium.org/9452038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123680 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/jingle_glue/iq_sender.h')
-rw-r--r-- | remoting/jingle_glue/iq_sender.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/remoting/jingle_glue/iq_sender.h b/remoting/jingle_glue/iq_sender.h index 5244584..e90e766 100644 --- a/remoting/jingle_glue/iq_sender.h +++ b/remoting/jingle_glue/iq_sender.h @@ -12,8 +12,13 @@ #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" #include "remoting/jingle_glue/signal_strategy.h" +namespace base { +class TimeDelta; +} // namespace base + namespace buzz { class XmlElement; } // namespace buzz @@ -27,7 +32,10 @@ class SignalStrategy; // those requests. class IqSender : public SignalStrategy::Listener { public: - typedef base::Callback<void(const buzz::XmlElement*)> ReplyCallback; + // Callback that is called when an Iq response is received. Called + // with the |response| set to NULL in case of a timeout. + typedef base::Callback<void(IqRequest* request, + const buzz::XmlElement* response)> ReplyCallback; explicit IqSender(SignalStrategy* signal_strategy); virtual ~IqSender(); @@ -72,19 +80,28 @@ class IqSender : public SignalStrategy::Listener { }; // This call must only be used on the thread it was created on. -class IqRequest { +class IqRequest : public base::SupportsWeakPtr<IqRequest> { public: - IqRequest(IqSender* sender, const IqSender::ReplyCallback& callback); + IqRequest(IqSender* sender, const IqSender::ReplyCallback& callback, + const std::string& addressee); ~IqRequest(); + // Sets timeout for the request. When the timeout expires the + // callback is called with the |response| set to NULL. + void SetTimeout(base::TimeDelta timeout); + private: friend class IqSender; + void CallCallback(const buzz::XmlElement* stanza); + void OnTimeout(); + // Called by IqSender when a response is received. void OnResponse(const buzz::XmlElement* stanza); IqSender* sender_; IqSender::ReplyCallback callback_; + std::string addressee_; DISALLOW_COPY_AND_ASSIGN(IqRequest); }; |