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

Unified Diff: remoting/protocol/transport_context.cc

Issue 1694613002: Add IceConfig and IceConfigRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@url_request
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/transport_context.h ('k') | remoting/remoting_srcs.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/transport_context.cc
diff --git a/remoting/protocol/transport_context.cc b/remoting/protocol/transport_context.cc
index b8ed300a111673cfe91b4d0c455b9ea7743e0404..d75e403e26134b4c7f0c05d19d8d21d42a14231c 100644
--- a/remoting/protocol/transport_context.cc
+++ b/remoting/protocol/transport_context.cc
@@ -11,6 +11,7 @@
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "remoting/base/url_request.h"
+#include "remoting/protocol/jingle_info_request.h"
#include "remoting/protocol/port_allocator_factory.h"
#include "third_party/webrtc/base/socketaddress.h"
@@ -23,9 +24,6 @@
namespace remoting {
namespace protocol {
-// Get fresh STUN/Relay configuration every hour.
-static const int kJingleInfoUpdatePeriodSeconds = 3600;
-
#if !defined(OS_NACL)
// static
scoped_refptr<TransportContext> TransportContext::ForTests(TransportRole role) {
@@ -56,21 +54,21 @@ void TransportContext::Prepare() {
EnsureFreshJingleInfo();
}
-void TransportContext::GetJingleInfo(const GetJingleInfoCallback& callback) {
+void TransportContext::GetIceConfig(const GetIceConfigCallback& callback) {
EnsureFreshJingleInfo();
- // If there is a pending |jingle_info_request_| delay the callback until the
+ // If there is a pending |ice_config_request_| delay the callback until the
// request is finished.
- if (jingle_info_request_) {
- pending_jingle_info_callbacks_.push_back(callback);
+ if (ice_config_request_) {
+ pending_ice_config_callbacks_.push_back(callback);
} else {
- callback.Run(stun_hosts_, relay_hosts_, relay_token_);
+ callback.Run(ice_config_);
}
}
void TransportContext::EnsureFreshJingleInfo() {
// Check if request is already pending.
- if (jingle_info_request_)
+ if (ice_config_request_)
return;
// Don't need to make jingleinfo request if both STUN and Relay are disabled.
@@ -79,31 +77,21 @@ void TransportContext::EnsureFreshJingleInfo() {
return;
}
- if (last_jingle_info_update_time_.is_null() ||
- base::TimeTicks::Now() - last_jingle_info_update_time_ >
- base::TimeDelta::FromSeconds(kJingleInfoUpdatePeriodSeconds)) {
- jingle_info_request_.reset(new JingleInfoRequest(signal_strategy_));
- jingle_info_request_->Send(base::Bind(
- &TransportContext::OnJingleInfo, base::Unretained(this)));
+ if (ice_config_.is_null() ||
+ base::Time::Now() > ice_config_.expiration_time) {
+ ice_config_request_.reset(new JingleInfoRequest(signal_strategy_));
+ ice_config_request_->Send(base::Bind(
+ &TransportContext::OnIceConfig, base::Unretained(this)));
}
}
-void TransportContext::OnJingleInfo(
- const std::string& relay_token,
- const std::vector<std::string>& relay_hosts,
- const std::vector<rtc::SocketAddress>& stun_hosts) {
- relay_token_ = relay_token;
- relay_hosts_ = relay_hosts;
- stun_hosts_ = stun_hosts;
-
- jingle_info_request_.reset();
- if ((!relay_token.empty() && !relay_hosts.empty()) || !stun_hosts.empty())
- last_jingle_info_update_time_ = base::TimeTicks::Now();
-
- while (!pending_jingle_info_callbacks_.empty()) {
- pending_jingle_info_callbacks_.begin()->Run(stun_hosts_, relay_hosts_,
- relay_token_);
- pending_jingle_info_callbacks_.pop_front();
+void TransportContext::OnIceConfig(const IceConfig& ice_config) {
+ ice_config_ = ice_config;
+ ice_config_request_.reset();
+
+ while (!pending_ice_config_callbacks_.empty()) {
+ pending_ice_config_callbacks_.begin()->Run(ice_config_);
+ pending_ice_config_callbacks_.pop_front();
}
}
« no previous file with comments | « remoting/protocol/transport_context.h ('k') | remoting/remoting_srcs.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698