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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 std::string relay_token; | 51 std::string relay_token; |
52 | 52 |
53 if (!stanza) { | 53 if (!stanza) { |
54 LOG(WARNING) << "Jingle info request has timed out."; | 54 LOG(WARNING) << "Jingle info request has timed out."; |
55 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); | 55 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); |
56 return; | 56 return; |
57 } | 57 } |
58 | 58 |
59 const buzz::XmlElement* query = | 59 const buzz::XmlElement* query = |
60 stanza->FirstNamed(buzz::QN_JINGLE_INFO_QUERY); | 60 stanza->FirstNamed(buzz::QN_JINGLE_INFO_QUERY); |
61 if (query == NULL) { | 61 if (query == nullptr) { |
62 LOG(WARNING) << "No Jingle info found in Jingle Info query response." | 62 LOG(WARNING) << "No Jingle info found in Jingle Info query response." |
63 << stanza->Str(); | 63 << stanza->Str(); |
64 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); | 64 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); |
65 return; | 65 return; |
66 } | 66 } |
67 | 67 |
68 const buzz::XmlElement* stun = query->FirstNamed(buzz::QN_JINGLE_INFO_STUN); | 68 const buzz::XmlElement* stun = query->FirstNamed(buzz::QN_JINGLE_INFO_STUN); |
69 if (stun) { | 69 if (stun) { |
70 for (const buzz::XmlElement* server = | 70 for (const buzz::XmlElement* server = |
71 stun->FirstNamed(buzz::QN_JINGLE_INFO_SERVER); | 71 stun->FirstNamed(buzz::QN_JINGLE_INFO_SERVER); |
72 server != NULL; | 72 server != nullptr; |
73 server = server->NextNamed(buzz::QN_JINGLE_INFO_SERVER)) { | 73 server = server->NextNamed(buzz::QN_JINGLE_INFO_SERVER)) { |
74 std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST); | 74 std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST); |
75 std::string port_str = server->Attr(buzz::QN_JINGLE_INFO_UDP); | 75 std::string port_str = server->Attr(buzz::QN_JINGLE_INFO_UDP); |
76 if (host != buzz::STR_EMPTY && port_str != buzz::STR_EMPTY) { | 76 if (host != buzz::STR_EMPTY && port_str != buzz::STR_EMPTY) { |
77 int port; | 77 int port; |
78 if (!base::StringToInt(port_str, &port)) { | 78 if (!base::StringToInt(port_str, &port)) { |
79 LOG(WARNING) << "Unable to parse port in stanza" << stanza->Str(); | 79 LOG(WARNING) << "Unable to parse port in stanza" << stanza->Str(); |
80 continue; | 80 continue; |
81 } | 81 } |
82 | 82 |
83 stun_hosts.push_back(rtc::SocketAddress(host, port)); | 83 stun_hosts.push_back(rtc::SocketAddress(host, port)); |
84 } | 84 } |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 const buzz::XmlElement* relay = query->FirstNamed(buzz::QN_JINGLE_INFO_RELAY); | 88 const buzz::XmlElement* relay = query->FirstNamed(buzz::QN_JINGLE_INFO_RELAY); |
89 if (relay) { | 89 if (relay) { |
90 relay_token = relay->TextNamed(buzz::QN_JINGLE_INFO_TOKEN); | 90 relay_token = relay->TextNamed(buzz::QN_JINGLE_INFO_TOKEN); |
91 for (const buzz::XmlElement* server = | 91 for (const buzz::XmlElement* server = |
92 relay->FirstNamed(buzz::QN_JINGLE_INFO_SERVER); | 92 relay->FirstNamed(buzz::QN_JINGLE_INFO_SERVER); |
93 server != NULL; | 93 server != nullptr; |
94 server = server->NextNamed(buzz::QN_JINGLE_INFO_SERVER)) { | 94 server = server->NextNamed(buzz::QN_JINGLE_INFO_SERVER)) { |
95 std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST); | 95 std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST); |
96 if (host != buzz::STR_EMPTY) | 96 if (host != buzz::STR_EMPTY) |
97 relay_hosts.push_back(host); | 97 relay_hosts.push_back(host); |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); | 101 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); |
102 } | 102 } |
103 | 103 |
104 } // namespace remoting | 104 } // namespace remoting |
OLD | NEW |