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

Unified Diff: remoting/signaling/fake_signal_strategy.h

Issue 414443009: Update ProtocolPerfTest to run host and client on different threads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « no previous file | remoting/signaling/fake_signal_strategy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/signaling/fake_signal_strategy.h
diff --git a/remoting/signaling/fake_signal_strategy.h b/remoting/signaling/fake_signal_strategy.h
index 2decda6ffd0970c6704586c21dac4cadb81e076e..05c5ba5152549e43be5b58e72b99d2665c341ebe 100644
--- a/remoting/signaling/fake_signal_strategy.h
+++ b/remoting/signaling/fake_signal_strategy.h
@@ -15,11 +15,17 @@
#include "remoting/signaling/iq_sender.h"
#include "remoting/signaling/signal_strategy.h"
+namespace base {
+class SingleThreadTaskRunner;
+} // namespace base
+
namespace remoting {
class FakeSignalStrategy : public SignalStrategy,
public base::NonThreadSafe {
public:
+ // Calls ConenctTo() to connect |peer1| and |peer2|. Both |peer1| and |peer2|
+ // must belong to the current thread.
static void Connect(FakeSignalStrategy* peer1, FakeSignalStrategy* peer2);
FakeSignalStrategy(const std::string& jid);
@@ -29,6 +35,9 @@ class FakeSignalStrategy : public SignalStrategy,
return received_messages_;
}
+ // Connects current FakeSignalStrategy to receive messages from |peer|.
+ void ConnectTo(FakeSignalStrategy* peer);
+
// SignalStrategy interface.
virtual void Connect() OVERRIDE;
virtual void Disconnect() OVERRIDE;
@@ -41,13 +50,22 @@ class FakeSignalStrategy : public SignalStrategy,
virtual std::string GetNextId() OVERRIDE;
private:
+ typedef base::Callback<void(scoped_ptr<buzz::XmlElement> message)>
+ PeerCallback;
+
+ static void DeliverMessageOnThread(
+ scoped_refptr<base::SingleThreadTaskRunner> thread,
+ base::WeakPtr<FakeSignalStrategy> target,
+ scoped_ptr<buzz::XmlElement> stanza);
+
// Called by the |peer_|. Takes ownership of |stanza|.
void OnIncomingMessage(scoped_ptr<buzz::XmlElement> stanza);
+ void SetPeerCallback(const PeerCallback& peer_callback);
- void DeliverIncomingMessages();
+ scoped_refptr<base::SingleThreadTaskRunner> main_thread_;
std::string jid_;
- FakeSignalStrategy* peer_;
+ PeerCallback peer_callback_;
ObserverList<Listener, true> listeners_;
int last_id_;
@@ -55,9 +73,6 @@ class FakeSignalStrategy : public SignalStrategy,
// All received messages, includes thouse still in |pending_messages_|.
std::list<buzz::XmlElement*> received_messages_;
- // Queue of messages that have yet to be delivered to observers.
- std::queue<buzz::XmlElement*> pending_messages_;
-
base::WeakPtrFactory<FakeSignalStrategy> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(FakeSignalStrategy);
« no previous file with comments | « no previous file | remoting/signaling/fake_signal_strategy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698