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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 LOG(ERROR) << error_message; | 74 LOG(ERROR) << error_message; |
75 CallCallback(std::string(), base::TimeDelta(), error_message); | 75 CallCallback(std::string(), base::TimeDelta(), error_message); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 bool RegisterSupportHostRequest::OnSignalStrategyIncomingStanza( | 79 bool RegisterSupportHostRequest::OnSignalStrategyIncomingStanza( |
80 const buzz::XmlElement* stanza) { | 80 const buzz::XmlElement* stanza) { |
81 return false; | 81 return false; |
82 } | 82 } |
83 | 83 |
84 scoped_ptr<XmlElement> RegisterSupportHostRequest::CreateRegistrationRequest( | 84 std::unique_ptr<XmlElement> |
85 const std::string& jid) { | 85 RegisterSupportHostRequest::CreateRegistrationRequest(const std::string& jid) { |
86 scoped_ptr<XmlElement> query(new XmlElement( | 86 std::unique_ptr<XmlElement> query( |
87 QName(kChromotingXmlNamespace, kRegisterQueryTag))); | 87 new XmlElement(QName(kChromotingXmlNamespace, kRegisterQueryTag))); |
88 XmlElement* public_key = new XmlElement( | 88 XmlElement* public_key = new XmlElement( |
89 QName(kChromotingXmlNamespace, kPublicKeyTag)); | 89 QName(kChromotingXmlNamespace, kPublicKeyTag)); |
90 public_key->AddText(key_pair_->GetPublicKey()); | 90 public_key->AddText(key_pair_->GetPublicKey()); |
91 query->AddElement(public_key); | 91 query->AddElement(public_key); |
92 query->AddElement(CreateSignature(jid).release()); | 92 query->AddElement(CreateSignature(jid).release()); |
93 return query; | 93 return query; |
94 } | 94 } |
95 | 95 |
96 scoped_ptr<XmlElement> RegisterSupportHostRequest::CreateSignature( | 96 std::unique_ptr<XmlElement> RegisterSupportHostRequest::CreateSignature( |
97 const std::string& jid) { | 97 const std::string& jid) { |
98 scoped_ptr<XmlElement> signature_tag(new XmlElement( | 98 std::unique_ptr<XmlElement> signature_tag( |
99 QName(kChromotingXmlNamespace, kSignatureTag))); | 99 new XmlElement(QName(kChromotingXmlNamespace, kSignatureTag))); |
100 | 100 |
101 int64_t time = static_cast<int64_t>(base::Time::Now().ToDoubleT()); | 101 int64_t time = static_cast<int64_t>(base::Time::Now().ToDoubleT()); |
102 std::string time_str(base::Int64ToString(time)); | 102 std::string time_str(base::Int64ToString(time)); |
103 signature_tag->AddAttr( | 103 signature_tag->AddAttr( |
104 QName(kChromotingXmlNamespace, kSignatureTimeAttr), time_str); | 104 QName(kChromotingXmlNamespace, kSignatureTimeAttr), time_str); |
105 | 105 |
106 std::string message = NormalizeJid(jid) + ' ' + time_str; | 106 std::string message = NormalizeJid(jid) + ' ' + time_str; |
107 std::string signature(key_pair_->SignMessage(message)); | 107 std::string signature(key_pair_->SignMessage(message)); |
108 signature_tag->AddText(signature); | 108 signature_tag->AddText(signature); |
109 | 109 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // Cleanup state before calling the callback. | 198 // Cleanup state before calling the callback. |
199 request_.reset(); | 199 request_.reset(); |
200 iq_sender_.reset(); | 200 iq_sender_.reset(); |
201 signal_strategy_->RemoveListener(this); | 201 signal_strategy_->RemoveListener(this); |
202 signal_strategy_ = nullptr; | 202 signal_strategy_ = nullptr; |
203 | 203 |
204 base::ResetAndReturn(&callback_).Run(support_id, lifetime, error_message); | 204 base::ResetAndReturn(&callback_).Run(support_id, lifetime, error_message); |
205 } | 205 } |
206 | 206 |
207 } // namespace remoting | 207 } // namespace remoting |
OLD | NEW |