diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 23:31:33 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 23:31:33 +0000 |
commit | cf988f0ea873f575519ae551c5db5f426b06cc6d (patch) | |
tree | 9b6fa805b7b042ade23c21f1480696c595117e2c /remoting/jingle_glue/iq_sender.cc | |
parent | af9d895f38546f9e7c756f77db3d272132e829de (diff) | |
download | chromium_src-cf988f0ea873f575519ae551c5db5f426b06cc6d.zip chromium_src-cf988f0ea873f575519ae551c5db5f426b06cc6d.tar.gz chromium_src-cf988f0ea873f575519ae551c5db5f426b06cc6d.tar.bz2 |
Handle IQ responses asynchronously.
Previously IqRequest was calling response callback synchronously. The callback
is allowed to delete SignalStrategy object, but it may be unsafe to delete
XmppSignalStrategy when handling an incoming message. Fixed IqRequest to
invoke response callback asynchronously, so that the callback is called with
a clean stack.
BUG=124430
Review URL: https://chromiumcodereview.appspot.com/10161010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133302 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/jingle_glue/iq_sender.cc')
-rw-r--r-- | remoting/jingle_glue/iq_sender.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/remoting/jingle_glue/iq_sender.cc b/remoting/jingle_glue/iq_sender.cc index 6bc7810..797db2a 100644 --- a/remoting/jingle_glue/iq_sender.cc +++ b/remoting/jingle_glue/iq_sender.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/location.h" #include "base/logging.h" +#include "base/memory/scoped_ptr.h" #include "base/message_loop_proxy.h" #include "base/string_number_conversions.h" #include "base/time.h" @@ -162,7 +163,16 @@ void IqRequest::OnTimeout() { } void IqRequest::OnResponse(const buzz::XmlElement* stanza) { - CallCallback(stanza); + // It's unsafe to delete signal strategy here, and the callback may + // want to do that, so we post task to invoke the callback later. + scoped_ptr<buzz::XmlElement> stanza_copy(new buzz::XmlElement(*stanza)); + base::MessageLoopProxy::current()->PostTask( + FROM_HERE, base::Bind(&IqRequest::DeliverResponse, AsWeakPtr(), + base::Passed(&stanza_copy))); +} + +void IqRequest::DeliverResponse(scoped_ptr<buzz::XmlElement> stanza) { + CallCallback(stanza.get()); } } // namespace remoting |