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

Unified Diff: remoting/signaling/delegating_signal_strategy.h

Issue 2384063008: Enables delegating signal strategy for It2Me Host. (Closed)
Patch Set: Fix unit tests 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
Index: remoting/signaling/delegating_signal_strategy.h
diff --git a/remoting/client/plugin/delegating_signal_strategy.h b/remoting/signaling/delegating_signal_strategy.h
similarity index 57%
rename from remoting/client/plugin/delegating_signal_strategy.h
rename to remoting/signaling/delegating_signal_strategy.h
index 9a9096f44a5d1cb49fbeb7891a2fccb8269d5339..184394db95f9f89df1b0e187b4046fb288a3762b 100644
--- a/remoting/client/plugin/delegating_signal_strategy.h
+++ b/remoting/signaling/delegating_signal_strategy.h
@@ -7,7 +7,8 @@
#include "base/callback.h"
#include "base/macros.h"
-#include "base/observer_list.h"
+#include "base/memory/weak_ptr.h"
+#include "base/observer_list_threadsafe.h"
#include "remoting/signaling/signal_strategy.h"
namespace base {
@@ -16,12 +17,24 @@ class SingleThreadTaskRunner;
namespace remoting {
+// A signaling strategy class that delegates IQ sending and receiving.
+//
+// Notes on thread safety:
+// 1. This object can be created on any thread.
+// 2. OnIncomingMessage() and |send_iq_callback| will always be called on the
Sergey Ulanov 2016/10/06 18:28:57 Suggest separating this statement into two. |send_
kelvinp 2016/10/06 20:30:28 Done.
+// thread that it is created on. Note that |send_iq_callback| may be called
+// after the instance is destroyed.
+// 3. The caller should invoke all methods on the |client_task_runner|.
Sergey Ulanov 2016/10/06 18:28:57 Maybe rephrase this as "SignalStrategy interface m
kelvinp 2016/10/06 20:30:28 Done.
+// 4. All listeners will be called on |client_task_runner| as well.
+// 5. The destructor should always be called on the |client_task_runner|.
class DelegatingSignalStrategy : public SignalStrategy {
public:
typedef base::Callback<void(const std::string&)> SendIqCallback;
- DelegatingSignalStrategy(std::string local_jid,
- const SendIqCallback& send_iq_callback);
+ DelegatingSignalStrategy(
+ std::string local_jid,
+ scoped_refptr<base::SingleThreadTaskRunner> client_task_runner,
+ const SendIqCallback& send_iq_callback);
~DelegatingSignalStrategy() override;
void OnIncomingMessage(const std::string& message);
@@ -39,10 +52,14 @@ class DelegatingSignalStrategy : public SignalStrategy {
private:
std::string local_jid_;
- SendIqCallback send_iq_callback_;
+ scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> client_task_runner_;
+ SendIqCallback send_iq_callback_;
base::ObserverList<Listener> listeners_;
+ base::WeakPtrFactory<DelegatingSignalStrategy> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(DelegatingSignalStrategy);
};

Powered by Google App Engine
This is Rietveld 408576698