OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/jingle_glue/jingle_info_request.h" | 5 #include "remoting/jingle_glue/jingle_info_request.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/task.h" | 8 #include "base/task.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
13 #include "remoting/jingle_glue/iq_request.h" | 13 #include "remoting/jingle_glue/iq_sender.h" |
14 #include "third_party/libjingle/source/talk/base/socketaddress.h" | 14 #include "third_party/libjingle/source/talk/base/socketaddress.h" |
15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
16 #include "third_party/libjingle/source/talk/xmpp/constants.h" | 16 #include "third_party/libjingle/source/talk/xmpp/constants.h" |
17 | 17 |
18 namespace remoting { | 18 namespace remoting { |
19 | 19 |
20 | 20 JingleInfoRequest::JingleInfoRequest(SignalStrategy* signal_strategy) |
21 JingleInfoRequest::JingleInfoRequest(IqRequest* request) | 21 : iq_sender_(signal_strategy) { |
22 : request_(request) { | |
23 request_->set_callback(base::Bind(&JingleInfoRequest::OnResponse, | |
24 base::Unretained(this))); | |
25 } | 22 } |
26 | 23 |
27 JingleInfoRequest::~JingleInfoRequest() { | 24 JingleInfoRequest::~JingleInfoRequest() { |
28 } | 25 } |
29 | 26 |
30 void JingleInfoRequest::Send(const OnJingleInfoCallback& callback) { | 27 void JingleInfoRequest::Send(const OnJingleInfoCallback& callback) { |
31 on_jingle_info_cb_ = callback; | 28 on_jingle_info_cb_ = callback; |
32 request_->SendIq(IqRequest::MakeIqStanza( | 29 buzz::XmlElement* iq_body = |
33 buzz::STR_GET, buzz::STR_EMPTY, | 30 new buzz::XmlElement(buzz::QN_JINGLE_INFO_QUERY, true); |
34 new buzz::XmlElement(buzz::QN_JINGLE_INFO_QUERY, true))); | 31 request_.reset(iq_sender_.SendIq( |
| 32 buzz::STR_GET, buzz::STR_EMPTY, iq_body, |
| 33 base::Bind(&JingleInfoRequest::OnResponse, base::Unretained(this)))); |
35 } | 34 } |
36 | 35 |
37 void JingleInfoRequest::OnResponse(const buzz::XmlElement* stanza) { | 36 void JingleInfoRequest::OnResponse(const buzz::XmlElement* stanza) { |
38 const buzz::XmlElement* query = | 37 const buzz::XmlElement* query = |
39 stanza->FirstNamed(buzz::QN_JINGLE_INFO_QUERY); | 38 stanza->FirstNamed(buzz::QN_JINGLE_INFO_QUERY); |
40 if (query == NULL) { | 39 if (query == NULL) { |
41 LOG(WARNING) << "No Jingle info found in Jingle Info query response." | 40 LOG(WARNING) << "No Jingle info found in Jingle Info query response." |
42 << stanza->Str(); | 41 << stanza->Str(); |
43 return; | 42 return; |
44 } | 43 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST); | 75 std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST); |
77 if (host != buzz::STR_EMPTY) | 76 if (host != buzz::STR_EMPTY) |
78 relay_hosts.push_back(host); | 77 relay_hosts.push_back(host); |
79 } | 78 } |
80 } | 79 } |
81 | 80 |
82 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); | 81 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); |
83 } | 82 } |
84 | 83 |
85 } // namespace remoting | 84 } // namespace remoting |
OLD | NEW |