From b39e182dca78d0c165ba75bb04878f4eb71b3625 Mon Sep 17 00:00:00 2001 From: "sergeyu@chromium.org" Date: Fri, 4 Nov 2011 01:00:49 +0000 Subject: Refactor IqRequest. Remove CreateIqRequest from SignalStrategy interface. Intead to send an Iq stanza the new IqSender now need to be used. IqSender creats of IqRequest objects and handling iq responses. BUG=None TEST=Unittests. Review URL: http://codereview.chromium.org/8432009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108606 0039d316-1c4b-4281-b951-d872f2087c98 --- remoting/host/heartbeat_sender.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'remoting/host/heartbeat_sender.cc') diff --git a/remoting/host/heartbeat_sender.cc b/remoting/host/heartbeat_sender.cc index ecd35ca..c4e3a23 100644 --- a/remoting/host/heartbeat_sender.cc +++ b/remoting/host/heartbeat_sender.cc @@ -11,7 +11,7 @@ #include "base/time.h" #include "remoting/base/constants.h" #include "remoting/host/host_config.h" -#include "remoting/jingle_glue/iq_request.h" +#include "remoting/jingle_glue/iq_sender.h" #include "remoting/jingle_glue/jingle_thread.h" #include "remoting/jingle_glue/signal_strategy.h" #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" @@ -72,9 +72,8 @@ void HeartbeatSender::OnSignallingConnected(SignalStrategy* signal_strategy, state_ = STARTED; full_jid_ = full_jid; - request_.reset(signal_strategy->CreateIqRequest()); - request_->set_callback(base::Bind(&HeartbeatSender::ProcessResponse, - base::Unretained(this))); + + iq_sender_.reset(new IqSender(signal_strategy)); DoSendStanza(); timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(interval_ms_), this, @@ -84,7 +83,8 @@ void HeartbeatSender::OnSignallingConnected(SignalStrategy* signal_strategy, void HeartbeatSender::OnSignallingDisconnected() { DCHECK(message_loop_->BelongsToCurrentThread()); state_ = STOPPED; - request_.reset(NULL); + request_.reset(); + iq_sender_.reset(); } // Ignore any notifications other than signalling @@ -99,8 +99,10 @@ void HeartbeatSender::DoSendStanza() { DCHECK_EQ(state_, STARTED); VLOG(1) << "Sending heartbeat stanza to " << kChromotingBotJid; - request_->SendIq(IqRequest::MakeIqStanza( - buzz::STR_SET, kChromotingBotJid, CreateHeartbeatMessage())); + request_.reset(iq_sender_->SendIq( + buzz::STR_SET, kChromotingBotJid, CreateHeartbeatMessage(), + base::Bind(&HeartbeatSender::ProcessResponse, + base::Unretained(this)))); } void HeartbeatSender::ProcessResponse(const XmlElement* response) { -- cgit v1.1