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 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 DCHECK(host_key_pair_.get()); | 78 DCHECK(host_key_pair_.get()); |
79 DCHECK(thread_checker_.CalledOnValidThread()); | 79 DCHECK(thread_checker_.CalledOnValidThread()); |
80 | 80 |
81 signal_strategy_->AddListener(this); | 81 signal_strategy_->AddListener(this); |
82 | 82 |
83 // Start heartbeats if the |signal_strategy_| is already connected. | 83 // Start heartbeats if the |signal_strategy_| is already connected. |
84 OnSignalStrategyStateChange(signal_strategy_->GetState()); | 84 OnSignalStrategyStateChange(signal_strategy_->GetState()); |
85 } | 85 } |
86 | 86 |
87 HeartbeatSender::~HeartbeatSender() { | 87 HeartbeatSender::~HeartbeatSender() { |
| 88 DCHECK(thread_checker_.CalledOnValidThread()); |
88 signal_strategy_->RemoveListener(this); | 89 signal_strategy_->RemoveListener(this); |
89 } | 90 } |
90 | 91 |
91 void HeartbeatSender::OnSignalStrategyStateChange(SignalStrategy::State state) { | 92 void HeartbeatSender::OnSignalStrategyStateChange(SignalStrategy::State state) { |
92 DCHECK(thread_checker_.CalledOnValidThread()); | 93 DCHECK(thread_checker_.CalledOnValidThread()); |
93 if (state == SignalStrategy::CONNECTED) { | 94 if (state == SignalStrategy::CONNECTED) { |
94 iq_sender_.reset(new IqSender(signal_strategy_)); | 95 iq_sender_.reset(new IqSender(signal_strategy_)); |
95 SendStanza(); | 96 SendStanza(); |
96 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(interval_ms_), | 97 timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(interval_ms_), |
97 this, &HeartbeatSender::SendStanza); | 98 this, &HeartbeatSender::SendStanza); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 352 |
352 std::string message = signal_strategy_->GetLocalAddress().jid() + ' ' + | 353 std::string message = signal_strategy_->GetLocalAddress().jid() + ' ' + |
353 base::IntToString(sequence_id_); | 354 base::IntToString(sequence_id_); |
354 std::string signature(host_key_pair_->SignMessage(message)); | 355 std::string signature(host_key_pair_->SignMessage(message)); |
355 signature_tag->AddText(signature); | 356 signature_tag->AddText(signature); |
356 | 357 |
357 return signature_tag; | 358 return signature_tag; |
358 } | 359 } |
359 | 360 |
360 } // namespace remoting | 361 } // namespace remoting |
OLD | NEW |