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

Unified Diff: remoting/jingle_glue/iq_sender.cc

Issue 10161010: Handle IQ responses asynchronously. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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/jingle_glue/iq_sender.h ('k') | remoting/jingle_glue/iq_sender_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/jingle_glue/iq_sender.cc
diff --git a/remoting/jingle_glue/iq_sender.cc b/remoting/jingle_glue/iq_sender.cc
index 6bc7810dc92d4ca09c7f407b8533bed5bd2d6114..797db2af1d3eaebc4cb5bacadfec71fd4dc217fc 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
« no previous file with comments | « remoting/jingle_glue/iq_sender.h ('k') | remoting/jingle_glue/iq_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698