diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-16 18:23:01 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-16 18:23:01 +0000 |
commit | 3e0d61e2bb88eb80058b63ac6a8b9ebff64cc4eb (patch) | |
tree | c3da626825f9fe83079a9a1f248c6cf47db1ff21 /remoting/jingle_glue | |
parent | e824b9a645d86c8a75020f21cd9bb641c19d995f (diff) | |
download | chromium_src-3e0d61e2bb88eb80058b63ac6a8b9ebff64cc4eb.zip chromium_src-3e0d61e2bb88eb80058b63ac6a8b9ebff64cc4eb.tar.gz chromium_src-3e0d61e2bb88eb80058b63ac6a8b9ebff64cc4eb.tar.bz2 |
Revert 240926 "Fix LibjingleTransportFactory to refresh STUN/Relay."
> Fix LibjingleTransportFactory to refresh STUN/Relay.
>
> Previously chromoting host would get relay info only when started. Relay
> token expires within several hours, which means relay session creation would
> always fail from the host running for longer than several hours, and that
> makes connection impossible in some configurations. Moved code that
> gets Jingle info to LibjingleTransportFactory and it's responsible for
> refreshing relay token every hour.
>
> BUG=318897
> R=rmsousa@chromium.org
>
> Review URL: https://codereview.chromium.org/98173006
TBR=sergeyu@chromium.org
Review URL: https://codereview.chromium.org/116123003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/jingle_glue')
-rw-r--r-- | remoting/jingle_glue/jingle_info_request.cc | 30 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_info_request.h | 18 |
2 files changed, 16 insertions, 32 deletions
diff --git a/remoting/jingle_glue/jingle_info_request.cc b/remoting/jingle_glue/jingle_info_request.cc index d41f18a..e75b89f 100644 --- a/remoting/jingle_glue/jingle_info_request.cc +++ b/remoting/jingle_glue/jingle_info_request.cc @@ -8,7 +8,6 @@ #include "base/message_loop/message_loop.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" -#include "base/time/time.h" #include "net/base/net_util.h" #include "remoting/jingle_glue/iq_sender.h" #include "third_party/libjingle/source/talk/base/socketaddress.h" @@ -17,13 +16,12 @@ namespace remoting { -const int kRequestTimeoutSeconds = 5; - JingleInfoRequest::JingleInfoRequest(SignalStrategy* signal_strategy) : iq_sender_(signal_strategy) { } -JingleInfoRequest::~JingleInfoRequest() {} +JingleInfoRequest::~JingleInfoRequest() { +} void JingleInfoRequest::Send(const OnJingleInfoCallback& callback) { on_jingle_info_cb_ = callback; @@ -32,39 +30,19 @@ void JingleInfoRequest::Send(const OnJingleInfoCallback& callback) { request_ = iq_sender_.SendIq( buzz::STR_GET, buzz::STR_EMPTY, iq_body.Pass(), base::Bind(&JingleInfoRequest::OnResponse, base::Unretained(this))); - if (!request_) { - // If we failed to send IqRequest it means that SignalStrategy is - // disconnected. Notify the caller. - std::vector<talk_base::SocketAddress> stun_hosts; - std::vector<std::string> relay_hosts; - std::string relay_token; - on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); - return; - } - request_->SetTimeout(base::TimeDelta::FromSeconds(kRequestTimeoutSeconds)); } void JingleInfoRequest::OnResponse(IqRequest* request, const buzz::XmlElement* stanza) { - std::vector<talk_base::SocketAddress> stun_hosts; - std::vector<std::string> relay_hosts; - std::string relay_token; - - if (!stanza) { - LOG(WARNING) << "Jingle info request has timed out."; - on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); - return; - } - const buzz::XmlElement* query = stanza->FirstNamed(buzz::QN_JINGLE_INFO_QUERY); if (query == NULL) { LOG(WARNING) << "No Jingle info found in Jingle Info query response." << stanza->Str(); - on_jingle_info_cb_.Run(relay_token, relay_hosts, stun_hosts); return; } + std::vector<talk_base::SocketAddress> stun_hosts; const buzz::XmlElement* stun = query->FirstNamed(buzz::QN_JINGLE_INFO_STUN); if (stun) { for (const buzz::XmlElement* server = @@ -85,6 +63,8 @@ void JingleInfoRequest::OnResponse(IqRequest* request, } } + std::vector<std::string> relay_hosts; + std::string relay_token; const buzz::XmlElement* relay = query->FirstNamed(buzz::QN_JINGLE_INFO_RELAY); if (relay) { relay_token = relay->TextNamed(buzz::QN_JINGLE_INFO_TOKEN); diff --git a/remoting/jingle_glue/jingle_info_request.h b/remoting/jingle_glue/jingle_info_request.h index 118aa4a..a1b10de 100644 --- a/remoting/jingle_glue/jingle_info_request.h +++ b/remoting/jingle_glue/jingle_info_request.h @@ -13,6 +13,7 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "remoting/jingle_glue/iq_sender.h" +#include "third_party/libjingle/source/talk/base/sigslot.h" namespace buzz { class XmlElement; @@ -33,14 +34,17 @@ class SignalStrategy; // // This class is not threadsafe and should be used on the same thread it is // created on. -class JingleInfoRequest { +// +// TODO(ajwong): Add support for a timeout. +class JingleInfoRequest : public sigslot::has_slots<> { public: - // Callback to receive the Jingle configuration settings. All fields are empty - // if the request has timed out. - typedef base::Callback<void(const std::string& relay_token, - const std::vector<std::string>& relay_servers, - const std::vector<talk_base::SocketAddress>& - stun_servers)> OnJingleInfoCallback; + // Callback to receive the Jingle configuration settings. The arguments are + // passed by pointer so the receive may call swap on them. The receiver does + // NOT own the arguments, which are guaranteed only to be alive for the + // duration of the callback. + typedef base::Callback<void ( + const std::string&, const std::vector<std::string>&, + const std::vector<talk_base::SocketAddress>&)> OnJingleInfoCallback; explicit JingleInfoRequest(SignalStrategy* signal_strategy); virtual ~JingleInfoRequest(); |