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

Side by Side Diff: remoting/jingle_glue/fake_signal_strategy.h

Issue 9005034: Refactor SignalStrategy so that it can be reused for multiple connections. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef REMOTING_JINGLE_GLUE_FAKE_SIGNAL_STRATEGY_H_ 5 #ifndef REMOTING_JINGLE_GLUE_FAKE_SIGNAL_STRATEGY_H_
6 #define REMOTING_JINGLE_GLUE_FAKE_SIGNAL_STRATEGY_H_ 6 #define REMOTING_JINGLE_GLUE_FAKE_SIGNAL_STRATEGY_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
11 #include "base/observer_list.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/threading/non_thread_safe.h" 13 #include "base/threading/non_thread_safe.h"
13 #include "remoting/jingle_glue/iq_sender.h" 14 #include "remoting/jingle_glue/iq_sender.h"
14 #include "remoting/jingle_glue/signal_strategy.h" 15 #include "remoting/jingle_glue/signal_strategy.h"
15 16
16 namespace remoting { 17 namespace remoting {
17 18
18 class FakeSignalStrategy : public SignalStrategy, 19 class FakeSignalStrategy : public SignalStrategy,
19 public base::NonThreadSafe { 20 public base::NonThreadSafe {
20 public: 21 public:
21 static void Connect(FakeSignalStrategy* peer1, FakeSignalStrategy* peer2); 22 static void Connect(FakeSignalStrategy* peer1, FakeSignalStrategy* peer2);
22 23
23 FakeSignalStrategy(const std::string& jid); 24 FakeSignalStrategy(const std::string& jid);
24 virtual ~FakeSignalStrategy(); 25 virtual ~FakeSignalStrategy();
25 26
26 // SignalStrategy interface. 27 // SignalStrategy interface.
27 virtual void Init(StatusObserver* observer) OVERRIDE; 28 virtual void Connect() OVERRIDE;
28 virtual void Close() OVERRIDE; 29 virtual void Disconnect() OVERRIDE;
30 virtual State GetState() const OVERRIDE;
31 virtual std::string GetLocalJid() const OVERRIDE;
29 virtual void AddListener(Listener* listener) OVERRIDE; 32 virtual void AddListener(Listener* listener) OVERRIDE;
30 virtual void RemoveListener(Listener* listener) OVERRIDE; 33 virtual void RemoveListener(Listener* listener) OVERRIDE;
31 virtual bool SendStanza(buzz::XmlElement* stanza) OVERRIDE; 34 virtual bool SendStanza(buzz::XmlElement* stanza) OVERRIDE;
32 virtual std::string GetNextId() OVERRIDE; 35 virtual std::string GetNextId() OVERRIDE;
33 36
34 private: 37 private:
35 // Called by the |peer_|. Takes ownership of |stanza|. 38 // Called by the |peer_|. Takes ownership of |stanza|.
36 void OnIncomingMessage(buzz::XmlElement* stanza); 39 void OnIncomingMessage(buzz::XmlElement* stanza);
37 40
38 void DeliverIncomingMessages(); 41 void DeliverIncomingMessages();
39 42
40 std::string jid_; 43 std::string jid_;
41 FakeSignalStrategy* peer_; 44 FakeSignalStrategy* peer_;
42 std::vector<Listener*> listeners_; 45 ObserverList<Listener, true> listeners_;
43 46
44 int last_id_; 47 int last_id_;
45 48
46 std::queue<buzz::XmlElement*> pending_messages_; 49 std::queue<buzz::XmlElement*> pending_messages_;
47 50
48 base::WeakPtrFactory<FakeSignalStrategy> weak_factory_; 51 base::WeakPtrFactory<FakeSignalStrategy> weak_factory_;
49 52
50 DISALLOW_COPY_AND_ASSIGN(FakeSignalStrategy); 53 DISALLOW_COPY_AND_ASSIGN(FakeSignalStrategy);
51 }; 54 };
52 55
53 } // namespace remoting 56 } // namespace remoting
54 57
55 #endif // REMOTING_JINGLE_GLUE_FAKE_SIGNAL_STRATEGY_H_ 58 #endif // REMOTING_JINGLE_GLUE_FAKE_SIGNAL_STRATEGY_H_
OLDNEW
« no previous file with comments | « remoting/host/register_support_host_request_unittest.cc ('k') | remoting/jingle_glue/fake_signal_strategy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698