| 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/register_support_host_request.h" | 5 #include "remoting/host/register_support_host_request.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "remoting/base/constants.h" | 13 #include "remoting/base/constants.h" |
| 14 #include "remoting/host/host_config.h" | 14 #include "remoting/host/host_config.h" |
| 15 #include "remoting/signaling/iq_sender.h" | 15 #include "remoting/signaling/iq_sender.h" |
| 16 #include "remoting/signaling/jid_util.h" |
| 16 #include "remoting/signaling/signal_strategy.h" | 17 #include "remoting/signaling/signal_strategy.h" |
| 17 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 18 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| 18 #include "third_party/webrtc/libjingle/xmpp/constants.h" | 19 #include "third_party/webrtc/libjingle/xmpp/constants.h" |
| 19 | 20 |
| 20 using buzz::QName; | 21 using buzz::QName; |
| 21 using buzz::XmlElement; | 22 using buzz::XmlElement; |
| 22 | 23 |
| 23 namespace remoting { | 24 namespace remoting { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 scoped_ptr<XmlElement> RegisterSupportHostRequest::CreateSignature( | 92 scoped_ptr<XmlElement> RegisterSupportHostRequest::CreateSignature( |
| 92 const std::string& jid) { | 93 const std::string& jid) { |
| 93 scoped_ptr<XmlElement> signature_tag(new XmlElement( | 94 scoped_ptr<XmlElement> signature_tag(new XmlElement( |
| 94 QName(kChromotingXmlNamespace, kSignatureTag))); | 95 QName(kChromotingXmlNamespace, kSignatureTag))); |
| 95 | 96 |
| 96 int64 time = static_cast<int64>(base::Time::Now().ToDoubleT()); | 97 int64 time = static_cast<int64>(base::Time::Now().ToDoubleT()); |
| 97 std::string time_str(base::Int64ToString(time)); | 98 std::string time_str(base::Int64ToString(time)); |
| 98 signature_tag->AddAttr( | 99 signature_tag->AddAttr( |
| 99 QName(kChromotingXmlNamespace, kSignatureTimeAttr), time_str); | 100 QName(kChromotingXmlNamespace, kSignatureTimeAttr), time_str); |
| 100 | 101 |
| 101 std::string message = jid + ' ' + time_str; | 102 std::string message = NormalizeJid(jid) + ' ' + time_str; |
| 102 std::string signature(key_pair_->SignMessage(message)); | 103 std::string signature(key_pair_->SignMessage(message)); |
| 103 signature_tag->AddText(signature); | 104 signature_tag->AddText(signature); |
| 104 | 105 |
| 105 return signature_tag.Pass(); | 106 return signature_tag.Pass(); |
| 106 } | 107 } |
| 107 | 108 |
| 108 bool RegisterSupportHostRequest::ParseResponse(const XmlElement* response, | 109 bool RegisterSupportHostRequest::ParseResponse(const XmlElement* response, |
| 109 std::string* support_id, | 110 std::string* support_id, |
| 110 base::TimeDelta* lifetime) { | 111 base::TimeDelta* lifetime) { |
| 111 std::string type = response->Attr(buzz::QN_TYPE); | 112 std::string type = response->Attr(buzz::QN_TYPE); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // Cleanup state before calling the callback. | 177 // Cleanup state before calling the callback. |
| 177 request_.reset(); | 178 request_.reset(); |
| 178 iq_sender_.reset(); | 179 iq_sender_.reset(); |
| 179 signal_strategy_->RemoveListener(this); | 180 signal_strategy_->RemoveListener(this); |
| 180 signal_strategy_ = nullptr; | 181 signal_strategy_ = nullptr; |
| 181 | 182 |
| 182 base::ResetAndReturn(&callback_).Run(success, support_id, lifetime); | 183 base::ResetAndReturn(&callback_).Run(success, support_id, lifetime); |
| 183 } | 184 } |
| 184 | 185 |
| 185 } // namespace remoting | 186 } // namespace remoting |
| OLD | NEW |