OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signaling/jingle_info_request.h" | 5 #include "remoting/signaling/jingle_info_request.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
9 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
10 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
11 #include "base/time/time.h" | 13 #include "base/time/time.h" |
12 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
13 #include "remoting/signaling/iq_sender.h" | 15 #include "remoting/signaling/iq_sender.h" |
14 #include "third_party/webrtc/base/socketaddress.h" | 16 #include "third_party/webrtc/base/socketaddress.h" |
15 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 17 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
16 #include "third_party/webrtc/libjingle/xmpp/constants.h" | 18 #include "third_party/webrtc/libjingle/xmpp/constants.h" |
17 | 19 |
18 namespace remoting { | 20 namespace remoting { |
19 | 21 |
20 const int kRequestTimeoutSeconds = 5; | 22 const int kRequestTimeoutSeconds = 5; |
21 | 23 |
22 JingleInfoRequest::JingleInfoRequest(SignalStrategy* signal_strategy) | 24 JingleInfoRequest::JingleInfoRequest(SignalStrategy* signal_strategy) |
23 : iq_sender_(signal_strategy) { | 25 : iq_sender_(signal_strategy) {} |
24 } | |
25 | 26 |
26 JingleInfoRequest::~JingleInfoRequest() {} | 27 JingleInfoRequest::~JingleInfoRequest() {} |
27 | 28 |
28 void JingleInfoRequest::Send(const OnJingleInfoCallback& callback) { | 29 void JingleInfoRequest::Send(const OnJingleInfoCallback& callback) { |
29 on_jingle_info_cb_ = callback; | 30 on_jingle_info_cb_ = callback; |
30 scoped_ptr<buzz::XmlElement> iq_body( | 31 scoped_ptr<buzz::XmlElement> iq_body( |
31 new buzz::XmlElement(buzz::QN_JINGLE_INFO_QUERY, true)); | 32 new buzz::XmlElement(buzz::QN_JINGLE_INFO_QUERY, true)); |
32 request_ = iq_sender_.SendIq( | 33 request_ = iq_sender_.SendIq( |
33 buzz::STR_GET, buzz::STR_EMPTY, iq_body.Pass(), | 34 buzz::STR_GET, buzz::STR_EMPTY, std::move(iq_body), |
34 base::Bind(&JingleInfoRequest::OnResponse, base::Unretained(this))); | 35 base::Bind(&JingleInfoRequest::OnResponse, base::Unretained(this))); |
35 if (!request_) { | 36 if (!request_) { |
36 // If we failed to send IqRequest it means that SignalStrategy is | 37 // If we failed to send IqRequest it means that SignalStrategy is |
37 // disconnected. Notify the caller. | 38 // disconnected. Notify the caller. |
38 std::vector<rtc::SocketAddress> stun_hosts; | 39 std::vector<rtc::SocketAddress> stun_hosts; |
39 std::vector<std::string> relay_hosts; | 40 std::vector<std::string> relay_hosts; |
40 std::string relay_token; | 41 std::string relay_token; |
41 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); | 42 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); |
42 return; | 43 return; |
43 } | 44 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST); | 96 std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST); |
96 if (host != buzz::STR_EMPTY) | 97 if (host != buzz::STR_EMPTY) |
97 relay_hosts.push_back(host); | 98 relay_hosts.push_back(host); |
98 } | 99 } |
99 } | 100 } |
100 | 101 |
101 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); | 102 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); |
102 } | 103 } |
103 | 104 |
104 } // namespace remoting | 105 } // namespace remoting |
OLD | NEW |