| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 9 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 10 #include "base/time.h" | 11 #include "base/time.h" |
| 11 #include "remoting/base/constants.h" | 12 #include "remoting/base/constants.h" |
| 12 #include "remoting/host/host_config.h" | 13 #include "remoting/host/host_config.h" |
| 13 #include "remoting/jingle_glue/iq_request.h" | 14 #include "remoting/jingle_glue/iq_request.h" |
| 14 #include "remoting/jingle_glue/jingle_thread.h" | 15 #include "remoting/jingle_glue/jingle_thread.h" |
| 15 #include "remoting/jingle_glue/signal_strategy.h" | 16 #include "remoting/jingle_glue/signal_strategy.h" |
| 16 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 17 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 66 } |
| 66 | 67 |
| 67 void HeartbeatSender::OnSignallingConnected(SignalStrategy* signal_strategy, | 68 void HeartbeatSender::OnSignallingConnected(SignalStrategy* signal_strategy, |
| 68 const std::string& full_jid) { | 69 const std::string& full_jid) { |
| 69 DCHECK(message_loop_->BelongsToCurrentThread()); | 70 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 70 DCHECK(state_ == INITIALIZED || state_ == STOPPED); | 71 DCHECK(state_ == INITIALIZED || state_ == STOPPED); |
| 71 state_ = STARTED; | 72 state_ = STARTED; |
| 72 | 73 |
| 73 full_jid_ = full_jid; | 74 full_jid_ = full_jid; |
| 74 request_.reset(signal_strategy->CreateIqRequest()); | 75 request_.reset(signal_strategy->CreateIqRequest()); |
| 75 request_->set_callback(NewCallback(this, &HeartbeatSender::ProcessResponse)); | 76 request_->set_callback(base::Bind(&HeartbeatSender::ProcessResponse, |
| 77 base::Unretained(this))); |
| 76 | 78 |
| 77 DoSendStanza(); | 79 DoSendStanza(); |
| 78 timer_.Start(base::TimeDelta::FromMilliseconds(interval_ms_), this, | 80 timer_.Start(base::TimeDelta::FromMilliseconds(interval_ms_), this, |
| 79 &HeartbeatSender::DoSendStanza); | 81 &HeartbeatSender::DoSendStanza); |
| 80 } | 82 } |
| 81 | 83 |
| 82 void HeartbeatSender::OnSignallingDisconnected() { | 84 void HeartbeatSender::OnSignallingDisconnected() { |
| 83 DCHECK(message_loop_->BelongsToCurrentThread()); | 85 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 84 state_ = STOPPED; | 86 state_ = STOPPED; |
| 85 request_.reset(NULL); | 87 request_.reset(NULL); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 QName(kChromotingXmlNamespace, kSignatureTimeAttr), time_str); | 167 QName(kChromotingXmlNamespace, kSignatureTimeAttr), time_str); |
| 166 | 168 |
| 167 std::string message = full_jid_ + ' ' + time_str; | 169 std::string message = full_jid_ + ' ' + time_str; |
| 168 std::string signature(key_pair_.GetSignature(message)); | 170 std::string signature(key_pair_.GetSignature(message)); |
| 169 signature_tag->AddText(signature); | 171 signature_tag->AddText(signature); |
| 170 | 172 |
| 171 return signature_tag; | 173 return signature_tag; |
| 172 } | 174 } |
| 173 | 175 |
| 174 } // namespace remoting | 176 } // namespace remoting |
| OLD | NEW |