Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Side by Side Diff: remoting/signaling/jingle_info_request.cc

Issue 435823002: Revert "Update webrtc&libjingle 6774:6799." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/signaling/jingle_info_request.h ('k') | remoting/signaling/xmpp_signal_strategy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "net/base/net_util.h" 12 #include "net/base/net_util.h"
13 #include "remoting/signaling/iq_sender.h" 13 #include "remoting/signaling/iq_sender.h"
14 #include "third_party/libjingle/source/talk/base/socketaddress.h"
14 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
15 #include "third_party/libjingle/source/talk/xmpp/constants.h" 16 #include "third_party/libjingle/source/talk/xmpp/constants.h"
16 #include "third_party/webrtc/base/socketaddress.h"
17 17
18 namespace remoting { 18 namespace remoting {
19 19
20 const int kRequestTimeoutSeconds = 5; 20 const int kRequestTimeoutSeconds = 5;
21 21
22 JingleInfoRequest::JingleInfoRequest(SignalStrategy* signal_strategy) 22 JingleInfoRequest::JingleInfoRequest(SignalStrategy* signal_strategy)
23 : iq_sender_(signal_strategy) { 23 : iq_sender_(signal_strategy) {
24 } 24 }
25 25
26 JingleInfoRequest::~JingleInfoRequest() {} 26 JingleInfoRequest::~JingleInfoRequest() {}
27 27
28 void JingleInfoRequest::Send(const OnJingleInfoCallback& callback) { 28 void JingleInfoRequest::Send(const OnJingleInfoCallback& callback) {
29 on_jingle_info_cb_ = callback; 29 on_jingle_info_cb_ = callback;
30 scoped_ptr<buzz::XmlElement> iq_body( 30 scoped_ptr<buzz::XmlElement> iq_body(
31 new buzz::XmlElement(buzz::QN_JINGLE_INFO_QUERY, true)); 31 new buzz::XmlElement(buzz::QN_JINGLE_INFO_QUERY, true));
32 request_ = iq_sender_.SendIq( 32 request_ = iq_sender_.SendIq(
33 buzz::STR_GET, buzz::STR_EMPTY, iq_body.Pass(), 33 buzz::STR_GET, buzz::STR_EMPTY, iq_body.Pass(),
34 base::Bind(&JingleInfoRequest::OnResponse, base::Unretained(this))); 34 base::Bind(&JingleInfoRequest::OnResponse, base::Unretained(this)));
35 if (!request_) { 35 if (!request_) {
36 // If we failed to send IqRequest it means that SignalStrategy is 36 // If we failed to send IqRequest it means that SignalStrategy is
37 // disconnected. Notify the caller. 37 // disconnected. Notify the caller.
38 std::vector<rtc::SocketAddress> stun_hosts; 38 std::vector<talk_base::SocketAddress> stun_hosts;
39 std::vector<std::string> relay_hosts; 39 std::vector<std::string> relay_hosts;
40 std::string relay_token; 40 std::string relay_token;
41 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); 41 on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts);
42 return; 42 return;
43 } 43 }
44 request_->SetTimeout(base::TimeDelta::FromSeconds(kRequestTimeoutSeconds)); 44 request_->SetTimeout(base::TimeDelta::FromSeconds(kRequestTimeoutSeconds));
45 } 45 }
46 46
47 void JingleInfoRequest::OnResponse(IqRequest* request, 47 void JingleInfoRequest::OnResponse(IqRequest* request,
48 const buzz::XmlElement* stanza) { 48 const buzz::XmlElement* stanza) {
49 std::vector<rtc::SocketAddress> stun_hosts; 49 std::vector<talk_base::SocketAddress> stun_hosts;
50 std::vector<std::string> relay_hosts; 50 std::vector<std::string> relay_hosts;
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 =
(...skipping 13 matching lines...) Expand all
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(talk_base::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 != NULL;
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
OLDNEW
« no previous file with comments | « remoting/signaling/jingle_info_request.h ('k') | remoting/signaling/xmpp_signal_strategy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698