| 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_HEARTBEAT_SENDER_H_ | 5 #ifndef REMOTING_HOST_HEARTBEAT_SENDER_H_ |
| 6 #define REMOTING_HOST_HEARTBEAT_SENDER_H_ | 6 #define REMOTING_HOST_HEARTBEAT_SENDER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // </iq> | 88 // </iq> |
| 89 class HeartbeatSender : public SignalStrategy::Listener { | 89 class HeartbeatSender : public SignalStrategy::Listener { |
| 90 public: | 90 public: |
| 91 // |signal_strategy| and |delegate| must outlive this | 91 // |signal_strategy| and |delegate| must outlive this |
| 92 // object. Heartbeats will start when the supplied SignalStrategy | 92 // object. Heartbeats will start when the supplied SignalStrategy |
| 93 // enters the CONNECTED state. | 93 // enters the CONNECTED state. |
| 94 HeartbeatSender(const base::Closure& on_heartbeat_successful_callback, | 94 HeartbeatSender(const base::Closure& on_heartbeat_successful_callback, |
| 95 const base::Closure& on_unknown_host_id_error, | 95 const base::Closure& on_unknown_host_id_error, |
| 96 const std::string& host_id, | 96 const std::string& host_id, |
| 97 SignalStrategy* signal_strategy, | 97 SignalStrategy* signal_strategy, |
| 98 scoped_refptr<RsaKeyPair> key_pair, | 98 const scoped_refptr<RsaKeyPair> key_pair, |
| 99 const std::string& directory_bot_jid); | 99 const std::string& directory_bot_jid); |
| 100 virtual ~HeartbeatSender(); | 100 virtual ~HeartbeatSender(); |
| 101 | 101 |
| 102 // Sets host offline reason for future heartbeat stanzas, | 102 // Sets host offline reason for future heartbeat stanzas, |
| 103 // as well as intiates sending a stanza right away. | 103 // as well as intiates sending a stanza right away. |
| 104 // | 104 // |
| 105 // See rem:host-offline-reason class-level comments for discussion | 105 // See rem:host-offline-reason class-level comments for discussion |
| 106 // of allowed values for |host_offline_reason| string. | 106 // of allowed values for |host_offline_reason| string. |
| 107 // | 107 // |
| 108 // |ack_callback| will be called once, when the bot acks | 108 // |ack_callback| will be called once, when the bot acks |
| (...skipping 26 matching lines...) Expand all Loading... |
| 135 void SetSequenceId(int sequence_id); | 135 void SetSequenceId(int sequence_id); |
| 136 | 136 |
| 137 // Helper methods used by DoSendStanza() to generate heartbeat stanzas. | 137 // Helper methods used by DoSendStanza() to generate heartbeat stanzas. |
| 138 scoped_ptr<buzz::XmlElement> CreateHeartbeatMessage(); | 138 scoped_ptr<buzz::XmlElement> CreateHeartbeatMessage(); |
| 139 scoped_ptr<buzz::XmlElement> CreateSignature(); | 139 scoped_ptr<buzz::XmlElement> CreateSignature(); |
| 140 | 140 |
| 141 base::Closure on_heartbeat_successful_callback_; | 141 base::Closure on_heartbeat_successful_callback_; |
| 142 base::Closure on_unknown_host_id_error_; | 142 base::Closure on_unknown_host_id_error_; |
| 143 std::string host_id_; | 143 std::string host_id_; |
| 144 SignalStrategy* signal_strategy_; | 144 SignalStrategy* signal_strategy_; |
| 145 scoped_refptr<RsaKeyPair> key_pair_; | 145 const scoped_refptr<RsaKeyPair> key_pair_; |
| 146 std::string directory_bot_jid_; | 146 std::string directory_bot_jid_; |
| 147 scoped_ptr<IqSender> iq_sender_; | 147 scoped_ptr<IqSender> iq_sender_; |
| 148 scoped_ptr<IqRequest> request_; | 148 scoped_ptr<IqRequest> request_; |
| 149 int interval_ms_; | 149 int interval_ms_; |
| 150 base::RepeatingTimer<HeartbeatSender> timer_; | 150 base::RepeatingTimer<HeartbeatSender> timer_; |
| 151 base::OneShotTimer<HeartbeatSender> timer_resend_; | 151 base::OneShotTimer<HeartbeatSender> timer_resend_; |
| 152 int sequence_id_; | 152 int sequence_id_; |
| 153 bool sequence_id_was_set_; | 153 bool sequence_id_was_set_; |
| 154 int sequence_id_recent_set_num_; | 154 int sequence_id_recent_set_num_; |
| 155 bool heartbeat_succeeded_; | 155 bool heartbeat_succeeded_; |
| 156 int failed_startup_heartbeat_count_; | 156 int failed_startup_heartbeat_count_; |
| 157 std::string host_offline_reason_; | 157 std::string host_offline_reason_; |
| 158 base::Closure host_offline_reason_ack_callback_; | 158 base::Closure host_offline_reason_ack_callback_; |
| 159 | 159 |
| 160 base::ThreadChecker thread_checker_; | 160 base::ThreadChecker thread_checker_; |
| 161 | 161 |
| 162 DISALLOW_COPY_AND_ASSIGN(HeartbeatSender); | 162 DISALLOW_COPY_AND_ASSIGN(HeartbeatSender); |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 } // namespace remoting | 165 } // namespace remoting |
| 166 | 166 |
| 167 #endif // REMOTING_HOST_HEARTBEAT_SENDER_H_ | 167 #endif // REMOTING_HOST_HEARTBEAT_SENDER_H_ |
| OLD | NEW |