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

Unified Diff: remoting/jingle_glue/iq_sender.h

Issue 9452038: Implement timeouts for IQ requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: remoting/jingle_glue/iq_sender.h
diff --git a/remoting/jingle_glue/iq_sender.h b/remoting/jingle_glue/iq_sender.h
index 5244584dbab3e3458831acac9b8c5161da9d0454..e056e4e0ee5d6aecf228e2ea487885eaa962beaf 100644
--- a/remoting/jingle_glue/iq_sender.h
+++ b/remoting/jingle_glue/iq_sender.h
@@ -12,6 +12,7 @@
#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 buzz {
@@ -27,7 +28,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 +76,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& jid);
simonmorris 2012/02/24 00:11:31 |jid| is called "addressee" elsewhere. I'd suggest
Sergey Ulanov 2012/02/24 21:56:31 Done.
~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);
};

Powered by Google App Engine
This is Rietveld 408576698