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

Side by Side Diff: remoting/host/heartbeat_sender.h

Issue 2915193003: Add heartbeat timeout. (Closed)
Patch Set: 30 seconds Created 3 years, 6 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 | « no previous file | remoting/host/heartbeat_sender.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 (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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // SignalStrategy::Listener interface. 124 // SignalStrategy::Listener interface.
125 void OnSignalStrategyStateChange(SignalStrategy::State state) override; 125 void OnSignalStrategyStateChange(SignalStrategy::State state) override;
126 bool OnSignalStrategyIncomingStanza(const buzz::XmlElement* stanza) override; 126 bool OnSignalStrategyIncomingStanza(const buzz::XmlElement* stanza) override;
127 127
128 private: 128 private:
129 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, 129 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest,
130 DoSendStanzaWithExpectedSequenceId); 130 DoSendStanzaWithExpectedSequenceId);
131 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, ProcessResponseSetInterval); 131 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, ProcessResponseSetInterval);
132 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, 132 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest,
133 ProcessResponseExpectedSequenceId); 133 ProcessResponseExpectedSequenceId);
134 FRIEND_TEST_ALL_PREFIXES(HeartbeatSenderTest, ResponseTimeout);
134 friend class HeartbeatSenderTest; 135 friend class HeartbeatSenderTest;
135 136
136 void SendStanza(); 137 void SendStanza();
137 void ResendStanza(); 138 void ResendStanza();
138 void DoSendStanza(); 139 void DoSendStanza();
139 void ProcessResponse(bool is_offline_heartbeat_response, 140 void ProcessResponse(bool is_offline_heartbeat_response,
140 IqRequest* request, 141 IqRequest* request,
141 const buzz::XmlElement* response); 142 const buzz::XmlElement* response);
142 void SetInterval(int interval); 143 void SetInterval(base::TimeDelta interval);
143 void SetSequenceId(int sequence_id); 144 void SetSequenceId(int sequence_id);
144 145
145 // Handlers for host-offline-reason completion and timeout. 146 // Handlers for host-offline-reason completion and timeout.
146 void OnHostOfflineReasonTimeout(); 147 void OnHostOfflineReasonTimeout();
147 void OnHostOfflineReasonAck(); 148 void OnHostOfflineReasonAck();
148 149
149 // Helper methods used by DoSendStanza() to generate heartbeat stanzas. 150 // Helper methods used by DoSendStanza() to generate heartbeat stanzas.
150 std::unique_ptr<buzz::XmlElement> CreateHeartbeatMessage(); 151 std::unique_ptr<buzz::XmlElement> CreateHeartbeatMessage();
151 std::unique_ptr<buzz::XmlElement> CreateSignature(); 152 std::unique_ptr<buzz::XmlElement> CreateSignature();
152 153
153 base::Closure on_heartbeat_successful_callback_; 154 base::Closure on_heartbeat_successful_callback_;
154 base::Closure on_unknown_host_id_error_; 155 base::Closure on_unknown_host_id_error_;
155 std::string host_id_; 156 std::string host_id_;
156 SignalStrategy* signal_strategy_; 157 SignalStrategy* signal_strategy_;
157 scoped_refptr<const RsaKeyPair> host_key_pair_; 158 scoped_refptr<const RsaKeyPair> host_key_pair_;
158 std::string directory_bot_jid_; 159 std::string directory_bot_jid_;
159 std::unique_ptr<IqSender> iq_sender_; 160 std::unique_ptr<IqSender> iq_sender_;
160 std::unique_ptr<IqRequest> request_; 161 std::unique_ptr<IqRequest> request_;
161 int interval_ms_; 162 base::TimeDelta interval_;
162 base::RepeatingTimer timer_; 163 base::RepeatingTimer timer_;
163 base::OneShotTimer timer_resend_; 164 base::OneShotTimer timer_resend_;
164 int sequence_id_; 165 int sequence_id_ = 0;
165 bool sequence_id_was_set_; 166 bool sequence_id_was_set_ = false;
166 int sequence_id_recent_set_num_; 167 int sequence_id_recent_set_num_ = 0;
167 bool heartbeat_succeeded_; 168 bool heartbeat_succeeded_ = false;
168 int failed_startup_heartbeat_count_; 169 int failed_startup_heartbeat_count_ = 0;
170 int timed_out_heartbeats_count_ = 0;
169 171
170 // Fields to send and indicate completion of sending host-offline-reason. 172 // Fields to send and indicate completion of sending host-offline-reason.
171 std::string host_offline_reason_; 173 std::string host_offline_reason_;
172 base::Callback<void(bool success)> host_offline_reason_ack_callback_; 174 base::Callback<void(bool success)> host_offline_reason_ack_callback_;
173 base::OneShotTimer host_offline_reason_timeout_timer_; 175 base::OneShotTimer host_offline_reason_timeout_timer_;
174 176
175 base::ThreadChecker thread_checker_; 177 base::ThreadChecker thread_checker_;
176 178
177 DISALLOW_COPY_AND_ASSIGN(HeartbeatSender); 179 DISALLOW_COPY_AND_ASSIGN(HeartbeatSender);
178 }; 180 };
179 181
180 } // namespace remoting 182 } // namespace remoting
181 183
182 #endif // REMOTING_HOST_HEARTBEAT_SENDER_H_ 184 #endif // REMOTING_HOST_HEARTBEAT_SENDER_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/host/heartbeat_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698