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