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/task.h" | 7 #include "base/task.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 for (const buzz::XmlElement* server = | 50 for (const buzz::XmlElement* server = |
51 stun->FirstNamed(buzz::QN_JINGLE_INFO_SERVER); | 51 stun->FirstNamed(buzz::QN_JINGLE_INFO_SERVER); |
52 server != NULL; | 52 server != NULL; |
53 server = server->NextNamed(buzz::QN_JINGLE_INFO_SERVER)) { | 53 server = server->NextNamed(buzz::QN_JINGLE_INFO_SERVER)) { |
54 std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST); | 54 std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST); |
55 std::string port_str = server->Attr(buzz::QN_JINGLE_INFO_UDP); | 55 std::string port_str = server->Attr(buzz::QN_JINGLE_INFO_UDP); |
56 if (host != buzz::STR_EMPTY && port_str != buzz::STR_EMPTY) { | 56 if (host != buzz::STR_EMPTY && port_str != buzz::STR_EMPTY) { |
57 int port; | 57 int port; |
58 if (!base::StringToInt(port_str, &port)) { | 58 if (!base::StringToInt(port_str, &port)) { |
59 LOG(WARNING) << "Unable to parse port in stanza" << stanza->Str(); | 59 LOG(WARNING) << "Unable to parse port in stanza" << stanza->Str(); |
60 } else { | 60 continue; |
61 } | |
62 | |
63 if (host_resolver_factory_) { | |
61 net::IPAddressNumber ip_number; | 64 net::IPAddressNumber ip_number; |
62 HostResolver* resolver = host_resolver_factory_->CreateHostResolver(); | 65 HostResolver* resolver = host_resolver_factory_->CreateHostResolver(); |
63 stun_dns_requests_.insert(resolver); | 66 stun_dns_requests_.insert(resolver); |
64 resolver->SignalDone.connect( | 67 resolver->SignalDone.connect( |
65 this, &JingleInfoRequest::OnStunAddressResponse); | 68 this, &JingleInfoRequest::OnStunAddressResponse); |
66 resolver->Resolve(talk_base::SocketAddress(host, port)); | 69 resolver->Resolve(talk_base::SocketAddress(host, port)); |
70 } else { | |
71 // If there is no host_resolver_factory_, we're not sandboxes, do we | |
Sergey Ulanov
2011/08/11 01:32:49
s/do/so/
awong
2011/08/11 01:36:45
Done.
| |
72 // can let jingle itself do the DNS resolution. | |
Sergey Ulanov
2011/08/11 01:32:49
s/jingle/libjingle/
awong
2011/08/11 01:36:45
Done.
| |
73 stun_hosts_.push_back(talk_base::SocketAddress(host, port)); | |
67 } | 74 } |
68 } | 75 } |
69 } | 76 } |
70 } | 77 } |
71 | 78 |
72 const buzz::XmlElement* relay = query->FirstNamed(buzz::QN_JINGLE_INFO_RELAY); | 79 const buzz::XmlElement* relay = query->FirstNamed(buzz::QN_JINGLE_INFO_RELAY); |
73 if (relay) { | 80 if (relay) { |
74 relay_token_ = relay->TextNamed(buzz::QN_JINGLE_INFO_TOKEN); | 81 relay_token_ = relay->TextNamed(buzz::QN_JINGLE_INFO_TOKEN); |
75 for (const buzz::XmlElement* server = | 82 for (const buzz::XmlElement* server = |
76 relay->FirstNamed(buzz::QN_JINGLE_INFO_SERVER); | 83 relay->FirstNamed(buzz::QN_JINGLE_INFO_SERVER); |
(...skipping 15 matching lines...) Expand all Loading... | |
92 stun_hosts_.push_back(address); | 99 stun_hosts_.push_back(address); |
93 | 100 |
94 MessageLoop::current()->DeleteSoon(FROM_HERE, resolver); | 101 MessageLoop::current()->DeleteSoon(FROM_HERE, resolver); |
95 stun_dns_requests_.erase(resolver); | 102 stun_dns_requests_.erase(resolver); |
96 | 103 |
97 if (stun_dns_requests_.empty()) | 104 if (stun_dns_requests_.empty()) |
98 on_jingle_info_cb_.Run(relay_token_, relay_hosts_, stun_hosts_); | 105 on_jingle_info_cb_.Run(relay_token_, relay_hosts_, stun_hosts_); |
99 } | 106 } |
100 | 107 |
101 } // namespace remoting | 108 } // namespace remoting |
OLD | NEW |