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

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: fix release build 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
« no previous file with comments | « remoting/host/register_support_host_request_unittest.cc ('k') | remoting/jingle_glue/iq_sender.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e90e766a17d678e4730cd7e43429df5ac04b9443 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);
};
« no previous file with comments | « remoting/host/register_support_host_request_unittest.cc ('k') | remoting/jingle_glue/iq_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698