Commit ed4e4092 authored by Philipp Hancke's avatar Philipp Hancke Committed by Commit Bot

webrtc: add usage counters for promise versions of SLD/SRD et al

Adds usage counters for the promise versions of
- setLocalDescription
- setRemoteDescription
- createOffer
- createAnswer
as well as now counters for the total of each.

The usage counters for these have only been applied to the non-promise versions
so far.

BUG=None

Change-Id: I50757cc66821cde7f46b3a864d33965f7543ed70
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2361686Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Reviewed-by: default avatarHarald Alvestrand <hta@chromium.org>
Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com>
Cr-Commit-Position: refs/heads/master@{#801027}
parent 51c53363
...@@ -2772,6 +2772,14 @@ enum WebFeature { ...@@ -2772,6 +2772,14 @@ enum WebFeature {
kPluginFilename = 3444, kPluginFilename = 3444,
kPluginDescription = 3445, kPluginDescription = 3445,
kSubresourceWebBundles = 3446, kSubresourceWebBundles = 3446,
kRTCPeerConnectionSetRemoteDescriptionPromise = 3447,
kRTCPeerConnectionSetLocalDescriptionPromise = 3448,
kRTCPeerConnectionCreateOfferPromise = 3449,
kRTCPeerConnectionCreateAnswerPromise = 3450,
kRTCPeerConnectionSetRemoteDescription = 3451,
kRTCPeerConnectionSetLocalDescription = 3452,
kRTCPeerConnectionCreateOffer = 3453,
kRTCPeerConnectionCreateAnswer = 3454,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
......
...@@ -861,12 +861,16 @@ ScriptPromise RTCPeerConnection::createOffer(ScriptState* script_state, ...@@ -861,12 +861,16 @@ ScriptPromise RTCPeerConnection::createOffer(ScriptState* script_state,
RTCSessionDescriptionRequestPromiseImpl::Create( RTCSessionDescriptionRequestPromiseImpl::Create(
RTCCreateSessionDescriptionOperation::kCreateOffer, this, resolver, RTCCreateSessionDescriptionOperation::kCreateOffer, this, resolver,
"RTCPeerConnection", "createOffer"); "RTCPeerConnection", "createOffer");
if (options->hasOfferToReceiveAudio() || options->hasOfferToReceiveVideo()) {
ExecutionContext* context = ExecutionContext::From(script_state); ExecutionContext* context = ExecutionContext::From(script_state);
UseCounter::Count(context, WebFeature::kRTCPeerConnectionCreateOffer);
UseCounter::Count(context, WebFeature::kRTCPeerConnectionCreateOfferPromise);
if (options->hasOfferToReceiveAudio() || options->hasOfferToReceiveVideo()) {
UseCounter::Count( UseCounter::Count(
context, context,
WebFeature::kRTCPeerConnectionCreateOfferOptionsOfferToReceive); WebFeature::kRTCPeerConnectionCreateOfferOptionsOfferToReceive);
} }
auto platform_transceivers = peer_handler_->CreateOffer( auto platform_transceivers = peer_handler_->CreateOffer(
request, ConvertToRTCOfferOptionsPlatform(options)); request, ConvertToRTCOfferOptionsPlatform(options));
for (auto& platform_transceiver : platform_transceivers) for (auto& platform_transceiver : platform_transceivers)
...@@ -910,6 +914,7 @@ ScriptPromise RTCPeerConnection::CreateOffer( ...@@ -910,6 +914,7 @@ ScriptPromise RTCPeerConnection::CreateOffer(
ExecutionContext* context = ExecutionContext::From(script_state); ExecutionContext* context = ExecutionContext::From(script_state);
UseCounter::Count( UseCounter::Count(
context, WebFeature::kRTCPeerConnectionCreateOfferLegacyFailureCallback); context, WebFeature::kRTCPeerConnectionCreateOfferLegacyFailureCallback);
UseCounter::Count(context, WebFeature::kRTCPeerConnectionCreateOffer);
if (CallErrorCallbackIfSignalingStateClosed(signaling_state_, error_callback)) if (CallErrorCallbackIfSignalingStateClosed(signaling_state_, error_callback))
return ScriptPromise::CastUndefined(script_state); return ScriptPromise::CastUndefined(script_state);
...@@ -978,6 +983,10 @@ ScriptPromise RTCPeerConnection::createAnswer(ScriptState* script_state, ...@@ -978,6 +983,10 @@ ScriptPromise RTCPeerConnection::createAnswer(ScriptState* script_state,
return ScriptPromise(); return ScriptPromise();
} }
ExecutionContext* context = ExecutionContext::From(script_state);
UseCounter::Count(context, WebFeature::kRTCPeerConnectionCreateAnswer);
UseCounter::Count(context, WebFeature::kRTCPeerConnectionCreateAnswerPromise);
call_setup_state_tracker_.NoteAnswererStateEvent( call_setup_state_tracker_.NoteAnswererStateEvent(
AnswererState::kCreateAnswerPending, HasDocumentMedia()); AnswererState::kCreateAnswerPending, HasDocumentMedia());
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state); auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
...@@ -1023,6 +1032,7 @@ ScriptPromise RTCPeerConnection::CreateAnswer( ...@@ -1023,6 +1032,7 @@ ScriptPromise RTCPeerConnection::CreateAnswer(
DCHECK(success_callback); DCHECK(success_callback);
DCHECK(error_callback); DCHECK(error_callback);
ExecutionContext* context = ExecutionContext::From(script_state); ExecutionContext* context = ExecutionContext::From(script_state);
UseCounter::Count(context, WebFeature::kRTCPeerConnectionCreateAnswer);
UseCounter::Count( UseCounter::Count(
context, WebFeature::kRTCPeerConnectionCreateAnswerLegacyFailureCallback); context, WebFeature::kRTCPeerConnectionCreateAnswerLegacyFailureCallback);
if (media_constraints.IsObject()) { if (media_constraints.IsObject()) {
...@@ -1374,6 +1384,11 @@ ScriptPromise RTCPeerConnection::setLocalDescription( ...@@ -1374,6 +1384,11 @@ ScriptPromise RTCPeerConnection::setLocalDescription(
} }
NoteCallSetupStateEventPending(SetSdpOperationType::kSetLocalDescription, NoteCallSetupStateEventPending(SetSdpOperationType::kSetLocalDescription,
*session_description_init); *session_description_init);
ExecutionContext* context = ExecutionContext::From(script_state);
UseCounter::Count(context, WebFeature::kRTCPeerConnectionSetLocalDescription);
UseCounter::Count(context,
WebFeature::kRTCPeerConnectionSetLocalDescriptionPromise);
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state); auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
ScriptPromise promise = resolver->Promise(); ScriptPromise promise = resolver->Promise();
auto* request = MakeGarbageCollected<RTCVoidRequestPromiseImpl>( auto* request = MakeGarbageCollected<RTCVoidRequestPromiseImpl>(
...@@ -1403,6 +1418,7 @@ ScriptPromise RTCPeerConnection::setLocalDescription( ...@@ -1403,6 +1418,7 @@ ScriptPromise RTCPeerConnection::setLocalDescription(
session_description_init); session_description_init);
} }
ExecutionContext* context = ExecutionContext::From(script_state); ExecutionContext* context = ExecutionContext::From(script_state);
UseCounter::Count(context, WebFeature::kRTCPeerConnectionSetLocalDescription);
if (success_callback && error_callback) { if (success_callback && error_callback) {
UseCounter::Count( UseCounter::Count(
context, context,
...@@ -1490,6 +1506,12 @@ ScriptPromise RTCPeerConnection::setRemoteDescription( ...@@ -1490,6 +1506,12 @@ ScriptPromise RTCPeerConnection::setRemoteDescription(
return ScriptPromise(); return ScriptPromise();
} }
ExecutionContext* context = ExecutionContext::From(script_state);
UseCounter::Count(context,
WebFeature::kRTCPeerConnectionSetRemoteDescription);
UseCounter::Count(context,
WebFeature::kRTCPeerConnectionSetRemoteDescriptionPromise);
NoteCallSetupStateEventPending(SetSdpOperationType::kSetRemoteDescription, NoteCallSetupStateEventPending(SetSdpOperationType::kSetRemoteDescription,
*session_description_init); *session_description_init);
if (ContainsLegacyRtpDataChannel(session_description_init->sdp())) { if (ContainsLegacyRtpDataChannel(session_description_init->sdp())) {
...@@ -1526,6 +1548,8 @@ ScriptPromise RTCPeerConnection::setRemoteDescription( ...@@ -1526,6 +1548,8 @@ ScriptPromise RTCPeerConnection::setRemoteDescription(
session_description_init); session_description_init);
} }
ExecutionContext* context = ExecutionContext::From(script_state); ExecutionContext* context = ExecutionContext::From(script_state);
UseCounter::Count(context,
WebFeature::kRTCPeerConnectionSetRemoteDescription);
if (success_callback && error_callback) { if (success_callback && error_callback) {
UseCounter::Count( UseCounter::Count(
context, context,
......
...@@ -28906,6 +28906,14 @@ Called by update_use_counter_feature_enum.py.--> ...@@ -28906,6 +28906,14 @@ Called by update_use_counter_feature_enum.py.-->
<int value="3444" label="PluginFilename"/> <int value="3444" label="PluginFilename"/>
<int value="3445" label="PluginDescription"/> <int value="3445" label="PluginDescription"/>
<int value="3446" label="SubresourceWebBundles"/> <int value="3446" label="SubresourceWebBundles"/>
<int value="3447" label="RTCPeerConnectionSetRemoteDescriptionPromise"/>
<int value="3448" label="RTCPeerConnectionSetLocalDescriptionPromise"/>
<int value="3449" label="RTCPeerConnectionCreateOfferPromise"/>
<int value="3450" label="RTCPeerConnectionCreateAnswerPromise"/>
<int value="3451" label="RTCPeerConnectionSetRemoteDescription"/>
<int value="3452" label="RTCPeerConnectionSetLocalDescription"/>
<int value="3453" label="RTCPeerConnectionCreateOffer"/>
<int value="3454" label="RTCPeerConnectionCreateAnswer"/>
</enum> </enum>
<enum name="FeaturePolicyAllowlistType"> <enum name="FeaturePolicyAllowlistType">
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