OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_HOST_SIGNALING_CONNECTOR_H_ | 5 #ifndef REMOTING_HOST_SIGNALING_CONNECTOR_H_ |
6 #define REMOTING_HOST_SIGNALING_CONNECTOR_H_ | 6 #define REMOTING_HOST_SIGNALING_CONNECTOR_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/sequence_checker.h" |
11 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
12 #include "net/base/network_change_notifier.h" | 12 #include "net/base/network_change_notifier.h" |
13 #include "remoting/base/oauth_token_getter.h" | 13 #include "remoting/base/oauth_token_getter.h" |
14 #include "remoting/signaling/xmpp_signal_strategy.h" | 14 #include "remoting/signaling/xmpp_signal_strategy.h" |
15 | 15 |
16 namespace remoting { | 16 namespace remoting { |
17 | 17 |
18 class DnsBlackholeChecker; | 18 class DnsBlackholeChecker; |
19 | 19 |
20 // SignalingConnector listens for SignalStrategy status notifications | 20 // SignalingConnector listens for SignalStrategy status notifications |
21 // and attempts to keep it connected when possible. When signalling is | 21 // and attempts to keep it connected when possible. When signalling is |
22 // not connected it keeps trying to reconnect it until it is | 22 // not connected it keeps trying to reconnect it until it is |
23 // connected. It limits connection attempt rate using exponential | 23 // connected. It limits connection attempt rate using exponential |
24 // backoff. It also monitors network state and reconnects signalling | 24 // backoff. It also monitors network state and reconnects signalling |
25 // whenever connection type changes or IP address changes. | 25 // whenever connection type changes or IP address changes. |
26 class SignalingConnector | 26 class SignalingConnector |
27 : public base::SupportsWeakPtr<SignalingConnector>, | 27 : public base::SupportsWeakPtr<SignalingConnector>, |
28 public base::NonThreadSafe, | |
29 public SignalStrategy::Listener, | 28 public SignalStrategy::Listener, |
30 public net::NetworkChangeNotifier::ConnectionTypeObserver, | 29 public net::NetworkChangeNotifier::ConnectionTypeObserver, |
31 public net::NetworkChangeNotifier::IPAddressObserver { | 30 public net::NetworkChangeNotifier::IPAddressObserver { |
32 public: | 31 public: |
33 // The |auth_failed_callback| is called when authentication fails. | 32 // The |auth_failed_callback| is called when authentication fails. |
34 SignalingConnector(XmppSignalStrategy* signal_strategy, | 33 SignalingConnector(XmppSignalStrategy* signal_strategy, |
35 std::unique_ptr<DnsBlackholeChecker> dns_blackhole_checker, | 34 std::unique_ptr<DnsBlackholeChecker> dns_blackhole_checker, |
36 OAuthTokenGetter* oauth_token_getter, | 35 OAuthTokenGetter* oauth_token_getter, |
37 const base::Closure& auth_failed_callback); | 36 const base::Closure& auth_failed_callback); |
38 ~SignalingConnector() override; | 37 ~SignalingConnector() override; |
(...skipping 25 matching lines...) Expand all Loading... |
64 base::Closure auth_failed_callback_; | 63 base::Closure auth_failed_callback_; |
65 std::unique_ptr<DnsBlackholeChecker> dns_blackhole_checker_; | 64 std::unique_ptr<DnsBlackholeChecker> dns_blackhole_checker_; |
66 | 65 |
67 OAuthTokenGetter* oauth_token_getter_; | 66 OAuthTokenGetter* oauth_token_getter_; |
68 | 67 |
69 // Number of times we tried to connect without success. | 68 // Number of times we tried to connect without success. |
70 int reconnect_attempts_; | 69 int reconnect_attempts_; |
71 | 70 |
72 base::OneShotTimer timer_; | 71 base::OneShotTimer timer_; |
73 | 72 |
| 73 SEQUENCE_CHECKER(sequence_checker_); |
| 74 |
74 DISALLOW_COPY_AND_ASSIGN(SignalingConnector); | 75 DISALLOW_COPY_AND_ASSIGN(SignalingConnector); |
75 }; | 76 }; |
76 | 77 |
77 } // namespace remoting | 78 } // namespace remoting |
78 | 79 |
79 #endif // REMOTING_HOST_SIGNALING_CONNECTOR_H_ | 80 #endif // REMOTING_HOST_SIGNALING_CONNECTOR_H_ |
OLD | NEW |