Commit 08110857 authored by deadbeef's avatar deadbeef Committed by Commit bot

Rename "updateICE" to "setConfiguration", everywhere except in Blink.

This CL prepares for later renaming updateIce to setConfiguration in
Blink, once it has an Intent to Ship.

updateIce was never functional in the first place (in the native webrtc
library), always throwing the same exception. SetConfiguration is
functional, and will allow an application to change the set of ICE
servers and ICE candidate policy. Soon, also the ICE candidate pool
size.

updateIce will no longer be tracked after this CL, which should be ok
since it has always been nonfunctional and stats show zero use.

BUG=chromium:587453

Review-Url: https://codereview.chromium.org/2511633002
Cr-Commit-Position: refs/heads/master@{#438206}
parent 876fe79c
......@@ -454,7 +454,7 @@ WebRTCSessionDescription MockWebRTCPeerConnectionHandler::remoteDescription() {
return remote_description_;
}
bool MockWebRTCPeerConnectionHandler::updateICE(
bool MockWebRTCPeerConnectionHandler::setConfiguration(
const WebRTCConfiguration& configuration) {
return true;
}
......
......@@ -50,7 +50,8 @@ class MockWebRTCPeerConnectionHandler
const blink::WebRTCSessionDescription& remote_description) override;
blink::WebRTCSessionDescription localDescription() override;
blink::WebRTCSessionDescription remoteDescription() override;
bool updateICE(const blink::WebRTCConfiguration& configuration) override;
bool setConfiguration(
const blink::WebRTCConfiguration& configuration) override;
void logSelectedRtcpMuxPolicy(blink::RtcpMuxPolicy) override;
bool addICECandidate(const blink::WebRTCICECandidate& ice_candidate) override;
bool addICECandidate(const blink::WebRTCVoidRequest& request,
......
......@@ -266,7 +266,8 @@ void MockPeerConnectionImpl::SetRemoteDescriptionWorker(
remote_desc_.reset(desc);
}
bool MockPeerConnectionImpl::UpdateIce(const IceServers& configuration) {
bool MockPeerConnectionImpl::SetConfiguration(
const RTCConfiguration& configuration) {
return true;
}
......
......@@ -92,7 +92,7 @@ class MockPeerConnectionImpl : public webrtc::PeerConnectionInterface {
void SetRemoteDescriptionWorker(
webrtc::SetSessionDescriptionObserver* observer,
webrtc::SessionDescriptionInterface* desc);
bool UpdateIce(const IceServers& configuration) override;
bool SetConfiguration(const RTCConfiguration& configuration) override;
bool AddIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
void RegisterUMAObserver(webrtc::UMAObserver* observer) override;
......
......@@ -524,7 +524,7 @@ void PeerConnectionTracker::TrackSetSessionDescription(
value);
}
void PeerConnectionTracker::TrackUpdateIce(
void PeerConnectionTracker::TrackSetConfiguration(
RTCPeerConnectionHandler* pc_handler,
const webrtc::PeerConnectionInterface::RTCConfiguration& config) {
DCHECK(main_thread_.CalledOnValidThread());
......@@ -539,10 +539,7 @@ void PeerConnectionTracker::TrackUpdateIce(
<< "rtcpMuxPolicy: " << SerializeRtcpMuxPolicy(config.rtcp_mux_policy)
<< "}";
SendPeerConnectionUpdate(
id,
"updateIce",
result.str());
SendPeerConnectionUpdate(id, "setConfiguration", result.str());
}
void PeerConnectionTracker::TrackAddIceCandidate(
......
......@@ -102,8 +102,8 @@ class CONTENT_EXPORT PeerConnectionTracker
RTCPeerConnectionHandler* pc_handler,
const std::string& sdp, const std::string& type, Source source);
// Sends an update when Ice candidates are updated.
virtual void TrackUpdateIce(
// Sends an update when setConfiguration is called.
virtual void TrackSetConfiguration(
RTCPeerConnectionHandler* pc_handler,
const webrtc::PeerConnectionInterface::RTCConfiguration& config);
......
......@@ -189,11 +189,15 @@ void GetSdpAndTypeFromSessionDescription(
// Converter functions from Blink types to WebRTC types.
// This function doesn't assume |webrtc_config| is empty. Any fields in
// |blink_config| replace the corresponding fields in |webrtc_config|, but
// fields that only exist in |webrtc_config| are left alone.
void GetNativeRtcConfiguration(
const blink::WebRTCConfiguration& blink_config,
webrtc::PeerConnectionInterface::RTCConfiguration* webrtc_config) {
DCHECK(webrtc_config);
webrtc_config->servers.clear();
for (const blink::WebRTCIceServer& blink_server : blink_config.iceServers) {
webrtc::PeerConnectionInterface::IceServer server;
server.username =
......@@ -248,6 +252,7 @@ void GetNativeRtcConfiguration(
NOTREACHED();
}
webrtc_config->certificates.clear();
for (const std::unique_ptr<blink::WebRTCCertificate>& blink_certificate :
blink_config.certificates) {
webrtc_config->certificates.push_back(
......@@ -1093,21 +1098,20 @@ bool RTCPeerConnectionHandler::initialize(
peer_connection_tracker_ =
RenderThreadImpl::current()->peer_connection_tracker()->AsWeakPtr();
webrtc::PeerConnectionInterface::RTCConfiguration config;
GetNativeRtcConfiguration(server_configuration, &config);
GetNativeRtcConfiguration(server_configuration, &configuration_);
// Choose between RTC smoothness algorithm and prerenderer smoothing.
// Prerenderer smoothing is turned on if RTC smoothness is turned off.
config.set_prerenderer_smoothing(
configuration_.set_prerenderer_smoothing(
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableRTCSmoothnessAlgorithm));
// Copy all the relevant constraints into |config|.
CopyConstraintsIntoRtcConfiguration(options, &config);
CopyConstraintsIntoRtcConfiguration(options, &configuration_);
peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr());
native_peer_connection_ = dependency_factory_->CreatePeerConnection(
config, frame_, peer_connection_observer_.get());
configuration_, frame_, peer_connection_observer_.get());
if (!native_peer_connection_.get()) {
LOG(ERROR) << "Failed to initialize native PeerConnection.";
......@@ -1115,8 +1119,8 @@ bool RTCPeerConnectionHandler::initialize(
}
if (peer_connection_tracker_) {
peer_connection_tracker_->RegisterPeerConnection(this, config, options,
frame_);
peer_connection_tracker_->RegisterPeerConnection(this, configuration_,
options, frame_);
}
uma_observer_ = new rtc::RefCountedObject<PeerConnectionUMAObserver>();
......@@ -1129,14 +1133,13 @@ bool RTCPeerConnectionHandler::InitializeForTest(
const blink::WebMediaConstraints& options,
const base::WeakPtr<PeerConnectionTracker>& peer_connection_tracker) {
DCHECK(thread_checker_.CalledOnValidThread());
webrtc::PeerConnectionInterface::RTCConfiguration config;
GetNativeRtcConfiguration(server_configuration, &config);
GetNativeRtcConfiguration(server_configuration, &configuration_);
peer_connection_observer_ = new Observer(weak_factory_.GetWeakPtr());
CopyConstraintsIntoRtcConfiguration(options, &config);
CopyConstraintsIntoRtcConfiguration(options, &configuration_);
native_peer_connection_ = dependency_factory_->CreatePeerConnection(
config, nullptr, peer_connection_observer_.get());
configuration_, nullptr, peer_connection_observer_.get());
if (!native_peer_connection_.get()) {
LOG(ERROR) << "Failed to initialize native PeerConnection.";
return false;
......@@ -1383,17 +1386,16 @@ RTCPeerConnectionHandler::remoteDescription() {
return CreateWebKitSessionDescription(sdp, type);
}
bool RTCPeerConnectionHandler::updateICE(
const blink::WebRTCConfiguration& server_configuration) {
bool RTCPeerConnectionHandler::setConfiguration(
const blink::WebRTCConfiguration& blink_config) {
DCHECK(thread_checker_.CalledOnValidThread());
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::updateICE");
webrtc::PeerConnectionInterface::RTCConfiguration config;
GetNativeRtcConfiguration(server_configuration, &config);
TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::setConfiguration");
GetNativeRtcConfiguration(blink_config, &configuration_);
if (peer_connection_tracker_)
peer_connection_tracker_->TrackUpdateIce(this, config);
peer_connection_tracker_->TrackSetConfiguration(this, configuration_);
return native_peer_connection_->UpdateIce(config.servers);
return native_peer_connection_->SetConfiguration(configuration_);
}
void RTCPeerConnectionHandler::logSelectedRtcpMuxPolicy(
......
......@@ -132,8 +132,8 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
blink::WebRTCSessionDescription localDescription() override;
blink::WebRTCSessionDescription remoteDescription() override;
bool updateICE(
const blink::WebRTCConfiguration& server_configuration) override;
bool setConfiguration(
const blink::WebRTCConfiguration& configuration) override;
void logSelectedRtcpMuxPolicy(
blink::RtcpMuxPolicy selectedRtcpMuxPolicy) override;
bool addICECandidate(const blink::WebRTCICECandidate& candidate) override;
......@@ -271,6 +271,11 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
// |native_peer_connection_| is the libjingle native PeerConnection object.
scoped_refptr<webrtc::PeerConnectionInterface> native_peer_connection_;
// The last applied configuration. Used so that the constraints
// used when constructing the PeerConnection carry over when
// SetConfiguration is called.
webrtc::PeerConnectionInterface::RTCConfiguration configuration_;
// Record info about the first SessionDescription from the local and
// remote side to record UMA stats once both are set. We only check
// for the first offer or answer. "pranswer"s and "unknown"s (from
......
......@@ -150,7 +150,7 @@ class MockPeerConnectionTracker : public PeerConnectionTracker {
const std::string& sdp, const std::string& type,
Source source));
MOCK_METHOD2(
TrackUpdateIce,
TrackSetConfiguration,
void(RTCPeerConnectionHandler* pc_handler,
const webrtc::PeerConnectionInterface::RTCConfiguration& config));
MOCK_METHOD4(TrackAddIceCandidate,
......@@ -507,14 +507,15 @@ TEST_F(RTCPeerConnectionHandlerTest, setRemoteDescription) {
EXPECT_EQ(kDummySdp, sdp_string);
}
TEST_F(RTCPeerConnectionHandlerTest, updateICE) {
TEST_F(RTCPeerConnectionHandlerTest, setConfiguration) {
blink::WebRTCConfiguration config;
EXPECT_CALL(*mock_tracker_.get(), TrackUpdateIce(pc_handler_.get(), _));
EXPECT_CALL(*mock_tracker_.get(),
TrackSetConfiguration(pc_handler_.get(), _));
// TODO(perkj): Test that the parameters in |config| can be translated when a
// WebRTCConfiguration can be constructed. It's WebKit class and can't be
// initialized from a test.
EXPECT_TRUE(pc_handler_->updateICE(config));
EXPECT_TRUE(pc_handler_->setConfiguration(config));
}
TEST_F(RTCPeerConnectionHandlerTest, addICECandidate) {
......
......@@ -807,7 +807,7 @@ RTCSessionDescription* RTCPeerConnection::remoteDescription() {
void RTCPeerConnection::updateIce(ExecutionContext* context,
const RTCConfiguration& rtcConfiguration,
const Dictionary& mediaConstraints,
const Dictionary&,
ExceptionState& exceptionState) {
if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
return;
......@@ -825,12 +825,11 @@ void RTCPeerConnection::updateIce(ExecutionContext* context,
return;
}
// Constraints are ignored.
bool valid = m_peerHandler->updateICE(configuration);
if (!valid)
exceptionState.throwDOMException(
SyntaxError,
"Could not update the ICE Agent with the given configuration.");
// TODO(deadbeef): When this changes to setConfiguration, call
// m_peerHandler->setConfiguration.
exceptionState.throwDOMException(
SyntaxError,
"Could not update the ICE Agent with the given configuration.");
}
ScriptPromise RTCPeerConnection::generateCertificate(
......
......@@ -110,7 +110,7 @@ class RTCPeerConnection final : public EventTargetWithInlineData,
void updateIce(ExecutionContext*,
const RTCConfiguration&,
const Dictionary& mediaConstraints,
const Dictionary&,
ExceptionState&);
// Certificate management
......
......@@ -81,7 +81,7 @@ class WebRTCPeerConnectionHandler {
const WebRTCSessionDescription&) = 0;
virtual WebRTCSessionDescription localDescription() = 0;
virtual WebRTCSessionDescription remoteDescription() = 0;
virtual bool updateICE(const WebRTCConfiguration&) = 0;
virtual bool setConfiguration(const WebRTCConfiguration&) = 0;
virtual void logSelectedRtcpMuxPolicy(RtcpMuxPolicy) = 0;
// DEPRECATED
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment