OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_HOST_SIGNALING_MANAGER_H_ | 5 #ifndef REMOTING_HOST_HOST_SIGNALING_MANAGER_H_ |
6 #define REMOTING_HOST_HOST_SIGNALING_MANAGER_H_ | 6 #define REMOTING_HOST_HOST_SIGNALING_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
13 #include "remoting/base/rsa_key_pair.h" | 13 #include "remoting/base/rsa_key_pair.h" |
14 #include "remoting/host/oauth_token_getter.h" | 14 #include "remoting/host/oauth_token_getter.h" |
15 #include "remoting/signaling/xmpp_signal_strategy.h" | 15 #include "remoting/signaling/xmpp_signal_strategy.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class TimeDelta; | 18 class TimeDelta; |
19 } | 19 } |
20 | 20 |
21 namespace remoting { | 21 namespace remoting { |
22 | 22 |
23 class GcdNotificationSubscriber; | |
24 class GcdRestClient; | |
25 class GcdStateUpdater; | |
23 class HeartbeatSender; | 26 class HeartbeatSender; |
24 class OAuthTokenGetter; | 27 class OAuthTokenGetter; |
25 class SignalStrategy; | 28 class SignalStrategy; |
26 class SignalingConnector; | 29 class SignalingConnector; |
27 | 30 |
28 // HostSignalingManager manages objects needed for sending regular heartbeats to | 31 // HostSignalingManager manages objects needed for sending regular heartbeats to |
29 // the Chromoting Directory. | 32 // the Chromoting Directory. |
30 class HostSignalingManager { | 33 class HostSignalingManager { |
Sergey Ulanov
2015/05/07 21:49:55
This class doesn't exist anymore. Please sync with
John Williams
2015/05/20 00:22:44
Done.
| |
31 public: | 34 public: |
32 class Listener { | 35 class Listener { |
33 public: | 36 public: |
34 virtual ~Listener() {} | 37 virtual ~Listener() {} |
35 | 38 |
36 // Invoked after the first successful heartbeat. | 39 // Invoked after the first successful heartbeat. |
37 virtual void OnHeartbeatSuccessful() = 0; | 40 virtual void OnHeartbeatSuccessful() = 0; |
38 | 41 |
39 // Invoked when the host ID is permanently not recognized by the server. | 42 // Invoked when the host ID is permanently not recognized by the server. |
40 virtual void OnUnknownHostIdError() = 0; | 43 virtual void OnUnknownHostIdError() = 0; |
(...skipping 10 matching lines...) Expand all Loading... | |
51 // destroyed. | 54 // destroyed. |
52 static scoped_ptr<HostSignalingManager> Create( | 55 static scoped_ptr<HostSignalingManager> Create( |
53 Listener* listener, | 56 Listener* listener, |
54 const scoped_refptr<net::URLRequestContextGetter>& | 57 const scoped_refptr<net::URLRequestContextGetter>& |
55 url_request_context_getter, | 58 url_request_context_getter, |
56 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 59 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
57 const std::string& talkgadget_prefix_policy, | 60 const std::string& talkgadget_prefix_policy, |
58 const std::string& host_id, | 61 const std::string& host_id, |
59 const scoped_refptr<const RsaKeyPair>& host_key_pair, | 62 const scoped_refptr<const RsaKeyPair>& host_key_pair, |
60 const std::string& directory_bot_jid, | 63 const std::string& directory_bot_jid, |
61 scoped_ptr<OAuthTokenGetter::OAuthCredentials> oauth_credentials, | 64 OAuthTokenGetter* oauth_token_getter, |
62 bool verify_email); | 65 GcdRestClient* gcd_client_); |
63 | 66 |
64 ~HostSignalingManager(); | 67 ~HostSignalingManager(); |
65 | 68 |
66 // Get the SignalStrategy to use for talking to the Chromoting bot. | 69 // Get the SignalStrategy to use for talking to the Chromoting bot. |
67 // Returned SignalStrategy remains owned by the HostSignalingManager. | 70 // Returned SignalStrategy remains owned by the HostSignalingManager. |
68 SignalStrategy* signal_strategy() { return signal_strategy_.get(); } | 71 SignalStrategy* signal_strategy() { return signal_strategy_.get(); } |
69 | 72 |
70 // Kicks off sending a heartbeat containing a host-offline-reason attribute. | 73 // Kicks off sending a heartbeat containing a host-offline-reason attribute. |
71 // Will call |ack_callback| once either the bot acks receiving the | 74 // Will call |ack_callback| once either the bot acks receiving the |
72 // |host_offline_reason|, or the |timeout| is reached. | 75 // |host_offline_reason|, or the |timeout| is reached. |
73 // | 76 // |
74 // For discussion of allowed values for |host_offline_reason| argument, | 77 // For discussion of allowed values for |host_offline_reason| argument, |
75 // please see the description of rem:host-offline-reason xml attribute in | 78 // please see the description of rem:host-offline-reason xml attribute in |
76 // the class-level comments for HeartbeatReasonSender. | 79 // the class-level comments for HeartbeatReasonSender. |
77 void SendHostOfflineReason( | 80 void SendHostOfflineReason( |
78 const std::string& host_offline_reason, | 81 const std::string& host_offline_reason, |
79 const base::TimeDelta& timeout, | 82 const base::TimeDelta& timeout, |
80 const base::Callback<void(bool success)>& ack_callback); | 83 const base::Callback<void(bool success)>& ack_callback); |
81 | 84 |
82 private: | 85 private: |
83 HostSignalingManager( | 86 HostSignalingManager(scoped_ptr<SignalStrategy> signal_strategy, |
84 scoped_ptr<SignalStrategy> signal_strategy, | 87 scoped_ptr<SignalingConnector> signaling_connector, |
85 scoped_ptr<SignalingConnector> signaling_connector, | 88 scoped_ptr<HeartbeatSender> heartbeat_sender, |
86 scoped_ptr<HeartbeatSender> heartbeat_sender); | 89 scoped_ptr<GcdStateUpdater> gcd_state_updater, |
90 scoped_ptr<GcdNotificationSubscriber> gcd_subscriber); | |
87 | 91 |
88 // |heartbeat_sender_| and |signaling_connector_| have to be destroyed before | 92 // |heartbeat_sender_| and |signaling_connector_| have to be destroyed before |
89 // |signal_strategy_| because their destructors need to call | 93 // |signal_strategy_| because their destructors need to call |
90 // signal_strategy_->RemoveListener(this) | 94 // signal_strategy_->RemoveListener(this) |
91 scoped_ptr<SignalStrategy> signal_strategy_; | 95 scoped_ptr<SignalStrategy> signal_strategy_; |
92 scoped_ptr<SignalingConnector> signaling_connector_; | 96 scoped_ptr<SignalingConnector> signaling_connector_; |
93 scoped_ptr<HeartbeatSender> heartbeat_sender_; | 97 scoped_ptr<HeartbeatSender> heartbeat_sender_; |
98 scoped_ptr<GcdStateUpdater> gcd_state_updater_; | |
99 scoped_ptr<GcdNotificationSubscriber> gcd_subscriber_; | |
94 | 100 |
95 // Used to verify thread-safe usage. | 101 // Used to verify thread-safe usage. |
96 base::ThreadChecker thread_checker_; | 102 base::ThreadChecker thread_checker_; |
97 | 103 |
98 DISALLOW_COPY_AND_ASSIGN(HostSignalingManager); | 104 DISALLOW_COPY_AND_ASSIGN(HostSignalingManager); |
99 }; | 105 }; |
100 | 106 |
101 } // namespace remoting | 107 } // namespace remoting |
102 | 108 |
103 #endif // REMOTING_HOST_HOST_SIGNALING_MANAGER_H_ | 109 #endif // REMOTING_HOST_HOST_SIGNALING_MANAGER_H_ |
OLD | NEW |