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

Unified Diff: remoting/signaling/fake_signal_strategy.cc

Issue 2417913002: Process incoming IQs in the same order that they were sent. (Closed)
Patch Set: Reviewer's feedback Created 4 years, 2 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/signaling/fake_signal_strategy.cc
diff --git a/remoting/signaling/fake_signal_strategy.cc b/remoting/signaling/fake_signal_strategy.cc
index 12cd2c12ffdd78aca62cadee1bc5d760894983d5..2a5df524eeaa8d4b92923a059ba795a2d4e23fba 100644
--- a/remoting/signaling/fake_signal_strategy.cc
+++ b/remoting/signaling/fake_signal_strategy.cc
@@ -63,6 +63,11 @@ void FakeSignalStrategy::SetLocalJid(const std::string& jid) {
jid_ = jid;
}
+void FakeSignalStrategy::SimulatePackgeReordering() {
+ DCHECK(CalledOnValidThread());
+ simulate_reorder_ = true;
+}
+
void FakeSignalStrategy::Connect() {
DCHECK(CalledOnValidThread());
FOR_EACH_OBSERVER(Listener, listeners_,
@@ -135,6 +140,35 @@ void FakeSignalStrategy::OnIncomingMessage(
std::unique_ptr<buzz::XmlElement> stanza) {
DCHECK(CalledOnValidThread());
+ if (!simulate_reorder_) {
+ NotifyListeners(std::move(stanza));
+ return;
+ }
+
+ // Simulate IQ messages re-ordering by swapping the delivery order of
+ // transport-info messages.
+ const buzz::XmlElement* jingle =
+ stanza->FirstNamed(buzz::QName("urn:xmpp:jingle:1", "jingle"));
+ std::string action = jingle->Attr(buzz::QName("", "action"));
+
+ if (action != "transport-info") {
Sergey Ulanov 2016/10/21 19:19:39 Updated the test to reorder messages only after ha
kelvinp 2016/10/21 22:41:27 Done.
+ NotifyListeners(std::move(stanza));
+ return;
+ }
+
+ if (pending_transport_info_) {
+ NotifyListeners(std::move(stanza));
+ NotifyListeners(std::move(pending_transport_info_));
+ pending_transport_info_.reset();
+ } else {
+ pending_transport_info_ = std::move(stanza);
+ }
+}
+
+void FakeSignalStrategy::NotifyListeners(
+ std::unique_ptr<buzz::XmlElement> stanza) {
+ DCHECK(CalledOnValidThread());
+
buzz::XmlElement* stanza_ptr = stanza.get();
received_messages_.push_back(stanza.release());

Powered by Google App Engine
This is Rietveld 408576698