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

Unified Diff: remoting/signaling/fake_signal_strategy.cc

Issue 2417913002: Process incoming IQs in the same order that they were sent. (Closed)
Patch Set: Rebase 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
« no previous file with comments | « remoting/signaling/fake_signal_strategy.h ('k') | remoting/signaling/iq_sender.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/signaling/fake_signal_strategy.cc
diff --git a/remoting/signaling/fake_signal_strategy.cc b/remoting/signaling/fake_signal_strategy.cc
index fffc047661422acb6e9c090de04f43c834579e63..132ce1b9ef86fa4009f94bfd8d3cbbbfa832f2cd 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 (auto& observer : listeners_)
@@ -135,6 +140,26 @@ 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
+ // next pair of messages.
+ if (pending_stanza_) {
+ NotifyListeners(std::move(stanza));
+ NotifyListeners(std::move(pending_stanza_));
+ pending_stanza_.reset();
+ } else {
+ pending_stanza_ = 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());
« no previous file with comments | « remoting/signaling/fake_signal_strategy.h ('k') | remoting/signaling/iq_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698