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

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

Issue 8432009: Refactor IqRequest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month 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/task.h" 11 #include "base/task.h"
12 #include "base/threading/non_thread_safe.h" 12 #include "base/threading/non_thread_safe.h"
13 #include "remoting/jingle_glue/iq_request.h" 13 #include "remoting/jingle_glue/iq_sender.h"
14 #include "remoting/jingle_glue/signal_strategy.h" 14 #include "remoting/jingle_glue/signal_strategy.h"
15 15
16 namespace remoting { 16 namespace remoting {
17 17
18 class FakeSignalStrategy : public SignalStrategy, 18 class FakeSignalStrategy : public SignalStrategy,
19 public base::NonThreadSafe { 19 public base::NonThreadSafe {
20 public: 20 public:
21 static void Connect(FakeSignalStrategy* peer1, FakeSignalStrategy* peer2); 21 static void Connect(FakeSignalStrategy* peer1, FakeSignalStrategy* peer2);
22 22
23 FakeSignalStrategy(const std::string& jid); 23 FakeSignalStrategy(const std::string& jid);
24 virtual ~FakeSignalStrategy(); 24 virtual ~FakeSignalStrategy();
25 25
26 // SignalStrategy interface. 26 // SignalStrategy interface.
27 virtual void Init(StatusObserver* observer) OVERRIDE; 27 virtual void Init(StatusObserver* observer) OVERRIDE;
28 virtual void Close() OVERRIDE; 28 virtual void Close() OVERRIDE;
29 virtual void SetListener(Listener* listener) OVERRIDE; 29 virtual void AddListener(Listener* listener) OVERRIDE;
30 virtual void SendStanza(buzz::XmlElement* stanza) OVERRIDE; 30 virtual void RemoveListener(Listener* listener) OVERRIDE;
31 virtual bool SendStanza(buzz::XmlElement* stanza) OVERRIDE;
31 virtual std::string GetNextId() OVERRIDE; 32 virtual std::string GetNextId() OVERRIDE;
32 virtual IqRequest* CreateIqRequest() OVERRIDE;
33 33
34 private: 34 private:
35 // Called by the |peer_|. Takes ownership of |stanza|. 35 // Called by the |peer_|. Takes ownership of |stanza|.
36 void OnIncomingMessage(buzz::XmlElement* stanza); 36 void OnIncomingMessage(buzz::XmlElement* stanza);
37 37
38 void DeliverIncomingMessages(); 38 void DeliverIncomingMessages();
39 39
40 std::string jid_; 40 std::string jid_;
41 FakeSignalStrategy* peer_; 41 FakeSignalStrategy* peer_;
42 Listener* listener_; 42 std::vector<Listener*> listeners_;
43 IqRegistry iq_registry_;
44 43
45 int last_id_; 44 int last_id_;
46 45
47 std::queue<buzz::XmlElement*> pending_messages_; 46 std::queue<buzz::XmlElement*> pending_messages_;
48 47
49 ScopedRunnableMethodFactory<FakeSignalStrategy> task_factory_; 48 ScopedRunnableMethodFactory<FakeSignalStrategy> task_factory_;
50 49
51 DISALLOW_COPY_AND_ASSIGN(FakeSignalStrategy); 50 DISALLOW_COPY_AND_ASSIGN(FakeSignalStrategy);
52 }; 51 };
53 52
54 } // namespace remoting 53 } // namespace remoting
55 54
56 #endif // REMOTING_JINGLE_GLUE_FAKE_SIGNAL_STRATEGY_H_ 55 #endif // REMOTING_JINGLE_GLUE_FAKE_SIGNAL_STRATEGY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698