| 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 #include "remoting/host/heartbeat_sender.h" | 5 #include "remoting/host/heartbeat_sender.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | |
| 11 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 13 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringize_macros.h" | 13 #include "base/strings/stringize_macros.h" |
| 15 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 16 #include "remoting/base/constants.h" | 15 #include "remoting/base/constants.h" |
| 16 #include "remoting/base/logging.h" |
| 17 #include "remoting/host/server_log_entry.h" | 17 #include "remoting/host/server_log_entry.h" |
| 18 #include "remoting/jingle_glue/iq_sender.h" | 18 #include "remoting/jingle_glue/iq_sender.h" |
| 19 #include "remoting/jingle_glue/signal_strategy.h" | 19 #include "remoting/jingle_glue/signal_strategy.h" |
| 20 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 20 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
| 21 #include "third_party/libjingle/source/talk/xmpp/constants.h" | 21 #include "third_party/libjingle/source/talk/xmpp/constants.h" |
| 22 | 22 |
| 23 using buzz::QName; | 23 using buzz::QName; |
| 24 using buzz::XmlElement; | 24 using buzz::XmlElement; |
| 25 | 25 |
| 26 namespace remoting { | 26 namespace remoting { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 sequence_id_ = sequence_id; | 221 sequence_id_ = sequence_id; |
| 222 // Setting the sequence ID may be a symptom of a temporary server-side | 222 // Setting the sequence ID may be a symptom of a temporary server-side |
| 223 // problem, which would affect many hosts, so don't send a new heartbeat | 223 // problem, which would affect many hosts, so don't send a new heartbeat |
| 224 // immediately, as many hosts doing so may overload the server. | 224 // immediately, as many hosts doing so may overload the server. |
| 225 // But the server will usually set the sequence ID when it receives the first | 225 // But the server will usually set the sequence ID when it receives the first |
| 226 // heartbeat from a host. In that case, we can send a new heartbeat | 226 // heartbeat from a host. In that case, we can send a new heartbeat |
| 227 // immediately, as that only happens once per host instance. | 227 // immediately, as that only happens once per host instance. |
| 228 if (!sequence_id_was_set_) { | 228 if (!sequence_id_was_set_) { |
| 229 ResendStanza(); | 229 ResendStanza(); |
| 230 } else { | 230 } else { |
| 231 LOG(INFO) << "The heartbeat sequence ID has been set more than once: " | 231 HOST_LOG << "The heartbeat sequence ID has been set more than once: " |
| 232 << "the new value is " << sequence_id; | 232 << "the new value is " << sequence_id; |
| 233 double delay = pow(2.0, sequence_id_recent_set_num_) * | 233 double delay = pow(2.0, sequence_id_recent_set_num_) * |
| 234 (1 + base::RandDouble()) * kResendDelayMs; | 234 (1 + base::RandDouble()) * kResendDelayMs; |
| 235 if (delay <= interval_ms_) { | 235 if (delay <= interval_ms_) { |
| 236 timer_resend_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(delay), | 236 timer_resend_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(delay), |
| 237 this, &HeartbeatSender::ResendStanza); | 237 this, &HeartbeatSender::ResendStanza); |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 sequence_id_was_set_ = true; | 240 sequence_id_was_set_ = true; |
| 241 } | 241 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 268 | 268 |
| 269 std::string message = signal_strategy_->GetLocalJid() + ' ' + | 269 std::string message = signal_strategy_->GetLocalJid() + ' ' + |
| 270 base::IntToString(sequence_id_); | 270 base::IntToString(sequence_id_); |
| 271 std::string signature(key_pair_->SignMessage(message)); | 271 std::string signature(key_pair_->SignMessage(message)); |
| 272 signature_tag->AddText(signature); | 272 signature_tag->AddText(signature); |
| 273 | 273 |
| 274 return signature_tag.Pass(); | 274 return signature_tag.Pass(); |
| 275 } | 275 } |
| 276 | 276 |
| 277 } // namespace remoting | 277 } // namespace remoting |
| OLD | NEW |