| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "remoting/base/constants.h" | 15 #include "remoting/base/constants.h" |
| 16 #include "remoting/host/host_config.h" | 16 #include "remoting/host/host_config.h" |
| 17 #include "remoting/signaling/iq_sender.h" | 17 #include "remoting/signaling/iq_sender.h" |
| 18 #include "remoting/signaling/jid_util.h" | 18 #include "remoting/signaling/jid_util.h" |
| 19 #include "remoting/signaling/signal_strategy.h" | 19 #include "remoting/signaling/signal_strategy.h" |
| 20 #include "remoting/signaling/signaling_address.h" |
| 20 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h" | 21 #include "third_party/libjingle_xmpp/xmllite/xmlelement.h" |
| 21 #include "third_party/libjingle_xmpp/xmpp/constants.h" | 22 #include "third_party/libjingle_xmpp/xmpp/constants.h" |
| 22 | 23 |
| 23 using buzz::QName; | 24 using buzz::QName; |
| 24 using buzz::XmlElement; | 25 using buzz::XmlElement; |
| 25 | 26 |
| 26 namespace remoting { | 27 namespace remoting { |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 // Strings used in the request message we send to the bot. | 30 // Strings used in the request message we send to the bot. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 58 signal_strategy_->RemoveListener(this); | 59 signal_strategy_->RemoveListener(this); |
| 59 } | 60 } |
| 60 | 61 |
| 61 void RegisterSupportHostRequest::OnSignalStrategyStateChange( | 62 void RegisterSupportHostRequest::OnSignalStrategyStateChange( |
| 62 SignalStrategy::State state) { | 63 SignalStrategy::State state) { |
| 63 if (state == SignalStrategy::CONNECTED) { | 64 if (state == SignalStrategy::CONNECTED) { |
| 64 DCHECK(!callback_.is_null()); | 65 DCHECK(!callback_.is_null()); |
| 65 | 66 |
| 66 request_ = iq_sender_->SendIq( | 67 request_ = iq_sender_->SendIq( |
| 67 buzz::STR_SET, directory_bot_jid_, | 68 buzz::STR_SET, directory_bot_jid_, |
| 68 CreateRegistrationRequest(signal_strategy_->GetLocalJid()), | 69 CreateRegistrationRequest(signal_strategy_->GetLocalAddress().jid()), |
| 69 base::Bind(&RegisterSupportHostRequest::ProcessResponse, | 70 base::Bind(&RegisterSupportHostRequest::ProcessResponse, |
| 70 base::Unretained(this))); | 71 base::Unretained(this))); |
| 71 } else if (state == SignalStrategy::DISCONNECTED) { | 72 } else if (state == SignalStrategy::DISCONNECTED) { |
| 72 // We will reach here if signaling fails to connect. | 73 // We will reach here if signaling fails to connect. |
| 73 std::string error_message = "Signal strategy disconnected."; | 74 std::string error_message = "Signal strategy disconnected."; |
| 74 LOG(ERROR) << error_message; | 75 LOG(ERROR) << error_message; |
| 75 CallCallback(std::string(), base::TimeDelta(), error_message); | 76 CallCallback(std::string(), base::TimeDelta(), error_message); |
| 76 } | 77 } |
| 77 } | 78 } |
| 78 | 79 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // Cleanup state before calling the callback. | 199 // Cleanup state before calling the callback. |
| 199 request_.reset(); | 200 request_.reset(); |
| 200 iq_sender_.reset(); | 201 iq_sender_.reset(); |
| 201 signal_strategy_->RemoveListener(this); | 202 signal_strategy_->RemoveListener(this); |
| 202 signal_strategy_ = nullptr; | 203 signal_strategy_ = nullptr; |
| 203 | 204 |
| 204 base::ResetAndReturn(&callback_).Run(support_id, lifetime, error_message); | 205 base::ResetAndReturn(&callback_).Run(support_id, lifetime, error_message); |
| 205 } | 206 } |
| 206 | 207 |
| 207 } // namespace remoting | 208 } // namespace remoting |
| OLD | NEW |