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

Side by Side Diff: remoting/signaling/delegating_signal_strategy.h

Issue 2384063008: Enables delegating signal strategy for It2Me Host. (Closed)
Patch Set: Fix typos 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 unified diff | Download patch
« no previous file with comments | « remoting/signaling/BUILD.gn ('k') | remoting/signaling/delegating_signal_strategy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_CLIENT_PLUGIN_DELEGATING_SIGNAL_STRATEGY_H_ 5 #ifndef REMOTING_CLIENT_PLUGIN_DELEGATING_SIGNAL_STRATEGY_H_
6 #define REMOTING_CLIENT_PLUGIN_DELEGATING_SIGNAL_STRATEGY_H_ 6 #define REMOTING_CLIENT_PLUGIN_DELEGATING_SIGNAL_STRATEGY_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/observer_list.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/observer_list_threadsafe.h"
11 #include "remoting/signaling/signal_strategy.h" 12 #include "remoting/signaling/signal_strategy.h"
12 13
13 namespace base { 14 namespace base {
14 class SingleThreadTaskRunner; 15 class SingleThreadTaskRunner;
15 } // namespace base 16 } // namespace base
16 17
17 namespace remoting { 18 namespace remoting {
18 19
20 // A signaling strategy class that delegates IQ sending and receiving.
21 //
22 // Notes on thread safety:
23 // 1. This object can be created on any thread.
24 // 2. OnIncomingMessage() must be called on the same thread on which this object
25 // is created.
26 // 3. |send_iq_callback| will always be called on the thread that it is created.
27 // Note that |send_iq_callback| may be called after this object is destroyed.
28 // 4. The caller should invoke all methods on the SignalStrategy interface on
29 // the |client_task_runner|.
30 // 5. All listeners will be called on |client_task_runner| as well.
31 // 6. The destructor should always be called on the |client_task_runner|.
19 class DelegatingSignalStrategy : public SignalStrategy { 32 class DelegatingSignalStrategy : public SignalStrategy {
20 public: 33 public:
21 typedef base::Callback<void(const std::string&)> SendIqCallback; 34 typedef base::Callback<void(const std::string&)> SendIqCallback;
22 35
23 DelegatingSignalStrategy(std::string local_jid, 36 DelegatingSignalStrategy(
24 const SendIqCallback& send_iq_callback); 37 std::string local_jid,
38 scoped_refptr<base::SingleThreadTaskRunner> client_task_runner,
39 const SendIqCallback& send_iq_callback);
25 ~DelegatingSignalStrategy() override; 40 ~DelegatingSignalStrategy() override;
26 41
27 void OnIncomingMessage(const std::string& message); 42 void OnIncomingMessage(const std::string& message);
28 43
29 // SignalStrategy interface. 44 // SignalStrategy interface.
30 void Connect() override; 45 void Connect() override;
31 void Disconnect() override; 46 void Disconnect() override;
32 State GetState() const override; 47 State GetState() const override;
33 Error GetError() const override; 48 Error GetError() const override;
34 std::string GetLocalJid() const override; 49 std::string GetLocalJid() const override;
35 void AddListener(Listener* listener) override; 50 void AddListener(Listener* listener) override;
36 void RemoveListener(Listener* listener) override; 51 void RemoveListener(Listener* listener) override;
37 bool SendStanza(std::unique_ptr<buzz::XmlElement> stanza) override; 52 bool SendStanza(std::unique_ptr<buzz::XmlElement> stanza) override;
38 std::string GetNextId() override; 53 std::string GetNextId() override;
39 54
40 private: 55 private:
41 std::string local_jid_; 56 std::string local_jid_;
57 scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_;
58 scoped_refptr<base::SingleThreadTaskRunner> client_task_runner_;
59
42 SendIqCallback send_iq_callback_; 60 SendIqCallback send_iq_callback_;
61 base::ObserverList<Listener> listeners_;
43 62
44 base::ObserverList<Listener> listeners_; 63 base::WeakPtrFactory<DelegatingSignalStrategy> weak_factory_;
45 64
46 DISALLOW_COPY_AND_ASSIGN(DelegatingSignalStrategy); 65 DISALLOW_COPY_AND_ASSIGN(DelegatingSignalStrategy);
47 }; 66 };
48 67
49 } // namespace remoting 68 } // namespace remoting
50 69
51 #endif // REMOTING_CLIENT_PLUGIN_DELEGATING_SIGNAL_STRATEGY_H_ 70 #endif // REMOTING_CLIENT_PLUGIN_DELEGATING_SIGNAL_STRATEGY_H_
OLDNEW
« no previous file with comments | « remoting/signaling/BUILD.gn ('k') | remoting/signaling/delegating_signal_strategy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698