Commit cd77a9c8 authored by hta's avatar hta Committed by Commit bot

Adding counters for the types of Media Constraints.

This allows us to know who uses the old-style constraints,
who uses the new-style constraints, and who uses constraints
on APIs that should migrate away from using them.

BUG=576613

Review URL: https://codereview.chromium.org/1641653002

Cr-Commit-Position: refs/heads/master@{#372083}
parent b9487f88
......@@ -1003,6 +1003,9 @@ public:
NotificationAPIInsecureOriginIframe = 1147,
NotificationAPISecureOriginIframe = 1148,
WebSocket = 1149,
MediaStreamConstraintsNameValue = 1150,
MediaStreamConstraintsFromDictionary = 1151,
MediaStreamConstraintsConformant = 1152,
// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
......
......@@ -34,6 +34,7 @@
#include "bindings/core/v8/Dictionary.h"
#include "bindings/core/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "core/frame/UseCounter.h"
#include "modules/mediastream/MediaTrackConstraintSet.h"
#include "platform/Logging.h"
#include "platform/RuntimeEnabledFeatures.h"
......@@ -385,7 +386,7 @@ static WebMediaConstraints createFromNamedConstraints(WebVector<WebMediaConstrai
}
// Deprecated.
WebMediaConstraints create(const Dictionary& constraintsDictionary, MediaErrorState& errorState)
WebMediaConstraints create(const ExecutionContext* context, const Dictionary& constraintsDictionary, MediaErrorState& errorState)
{
WebVector<WebMediaConstraint> optional;
WebVector<WebMediaConstraint> mandatory;
......@@ -393,6 +394,7 @@ WebMediaConstraints create(const Dictionary& constraintsDictionary, MediaErrorSt
errorState.throwTypeError("Malformed constraints object.");
return WebMediaConstraints();
}
UseCounter::count(context, UseCounter::MediaStreamConstraintsFromDictionary);
return createFromNamedConstraints(mandatory, optional, errorState);
}
......@@ -491,7 +493,7 @@ void copyConstraints(const MediaTrackConstraintSet& constraintsIn, WebMediaTrack
}
}
WebMediaConstraints create(const MediaTrackConstraintSet& constraintsIn, MediaErrorState& errorState)
WebMediaConstraints create(const ExecutionContext* context, const MediaTrackConstraintSet& constraintsIn, MediaErrorState& errorState)
{
WebMediaConstraints constraints;
WebMediaTrackConstraintSet constraintBuffer;
......@@ -510,8 +512,10 @@ WebMediaConstraints create(const MediaTrackConstraintSet& constraintsIn, MediaEr
errorState.throwTypeError("Malformed constraints object.");
return WebMediaConstraints();
}
UseCounter::count(context, UseCounter::MediaStreamConstraintsNameValue);
return createFromNamedConstraints(mandatory, optional, errorState);
}
UseCounter::count(context, UseCounter::MediaStreamConstraintsConformant);
constraints.initialize(constraintBuffer, advancedBuffer);
return constraints;
}
......
......@@ -44,8 +44,8 @@ class MediaTrackConstraintSet;
namespace MediaConstraintsImpl {
WebMediaConstraints create();
WebMediaConstraints create(const Dictionary&, MediaErrorState&);
WebMediaConstraints create(const MediaTrackConstraintSet&, MediaErrorState&);
WebMediaConstraints create(const ExecutionContext*, const Dictionary&, MediaErrorState&);
WebMediaConstraints create(const ExecutionContext*, const MediaTrackConstraintSet&, MediaErrorState&);
}
......
......@@ -331,7 +331,7 @@ RTCPeerConnection* RTCPeerConnection::create(ExecutionContext* context, const Di
return 0;
MediaErrorState mediaErrorState;
WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaConstraints, mediaErrorState);
WebMediaConstraints constraints = MediaConstraintsImpl::create(context, mediaConstraints, mediaErrorState);
if (mediaErrorState.hadException()) {
mediaErrorState.raiseException(exceptionState);
return 0;
......@@ -417,7 +417,7 @@ void RTCPeerConnection::createOffer(ExecutionContext* context, RTCSessionDescrip
m_peerHandler->createOffer(request, offerOptions);
} else {
MediaErrorState mediaErrorState;
WebMediaConstraints constraints = MediaConstraintsImpl::create(rtcOfferOptions, mediaErrorState);
WebMediaConstraints constraints = MediaConstraintsImpl::create(context, rtcOfferOptions, mediaErrorState);
if (mediaErrorState.hadException()) {
mediaErrorState.raiseException(exceptionState);
return;
......@@ -450,7 +450,7 @@ void RTCPeerConnection::createAnswer(ExecutionContext* context, RTCSessionDescri
ASSERT(successCallback);
MediaErrorState mediaErrorState;
WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaConstraints, mediaErrorState);
WebMediaConstraints constraints = MediaConstraintsImpl::create(context, mediaConstraints, mediaErrorState);
if (mediaErrorState.hadException()) {
mediaErrorState.raiseException(exceptionState);
return;
......@@ -518,7 +518,7 @@ RTCSessionDescription* RTCPeerConnection::remoteDescription()
return RTCSessionDescription::create(webSessionDescription);
}
void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState& exceptionState)
void RTCPeerConnection::updateIce(ExecutionContext* context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState& exceptionState)
{
if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
return;
......@@ -528,7 +528,7 @@ void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict
return;
MediaErrorState mediaErrorState;
WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaConstraints, mediaErrorState);
WebMediaConstraints constraints = MediaConstraintsImpl::create(context, mediaConstraints, mediaErrorState);
if (mediaErrorState.hadException()) {
mediaErrorState.raiseException(exceptionState);
return;
......@@ -696,7 +696,7 @@ String RTCPeerConnection::iceConnectionState() const
return String();
}
void RTCPeerConnection::addStream(MediaStream* stream, const Dictionary& mediaConstraints, ExceptionState& exceptionState)
void RTCPeerConnection::addStream(ExecutionContext* context, MediaStream* stream, const Dictionary& mediaConstraints, ExceptionState& exceptionState)
{
if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
return;
......@@ -710,7 +710,7 @@ void RTCPeerConnection::addStream(MediaStream* stream, const Dictionary& mediaCo
return;
MediaErrorState mediaErrorState;
WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaConstraints, mediaErrorState);
WebMediaConstraints constraints = MediaConstraintsImpl::create(context, mediaConstraints, mediaErrorState);
if (mediaErrorState.hadException()) {
mediaErrorState.raiseException(exceptionState);
return;
......
......@@ -80,7 +80,7 @@ public:
String signalingState() const;
void updateIce(const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState&);
void updateIce(ExecutionContext*, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState&);
// Certificate management
// http://w3c.github.io/webrtc-pc/#sec.cert-mgmt
......@@ -101,7 +101,7 @@ public:
MediaStream* getStreamById(const String& streamId);
void addStream(MediaStream*, const Dictionary& mediaConstraints, ExceptionState&);
void addStream(ExecutionContext*, MediaStream*, const Dictionary& mediaConstraints, ExceptionState&);
void removeStream(MediaStream*, ExceptionState&);
......
......@@ -121,11 +121,11 @@ enum RTCIceConnectionState {
attribute EventHandler ondatachannel;
// Non-standard or removed from the spec:
[RaisesException] void updateIce(optional Dictionary configuration, optional Dictionary mediaConstraints);
[CallWith=ExecutionContext, RaisesException] void updateIce(optional Dictionary configuration, optional Dictionary mediaConstraints);
sequence<MediaStream> getLocalStreams();
sequence<MediaStream> getRemoteStreams();
MediaStream getStreamById(DOMString streamId);
[RaisesException] void addStream(MediaStream? stream, optional Dictionary mediaConstraints);
[CallWith=ExecutionContext, RaisesException] void addStream(MediaStream? stream, optional Dictionary mediaConstraints);
[RaisesException] void removeStream(MediaStream? stream);
[RaisesException] RTCDTMFSender createDTMFSender(MediaStreamTrack track);
attribute EventHandler onaddstream;
......
......@@ -48,7 +48,7 @@
namespace blink {
static WebMediaConstraints parseOptions(const BooleanOrMediaTrackConstraintSet& options, MediaErrorState& errorState)
static WebMediaConstraints parseOptions(ExecutionContext* context, const BooleanOrMediaTrackConstraintSet& options, MediaErrorState& errorState)
{
WebMediaConstraints constraints;
......@@ -56,7 +56,7 @@ static WebMediaConstraints parseOptions(const BooleanOrMediaTrackConstraintSet&
if (options.isNull()) {
// Do nothing.
} else if (options.isMediaTrackConstraintSet()) {
constraints = MediaConstraintsImpl::create(options.getAsMediaTrackConstraintSet(), errorState);
constraints = MediaConstraintsImpl::create(context, options.getAsMediaTrackConstraintSet(), errorState);
} else {
ASSERT(options.isBoolean());
if (options.getAsBoolean()) {
......@@ -69,11 +69,11 @@ static WebMediaConstraints parseOptions(const BooleanOrMediaTrackConstraintSet&
UserMediaRequest* UserMediaRequest::create(ExecutionContext* context, UserMediaController* controller, const MediaStreamConstraints& options, NavigatorUserMediaSuccessCallback* successCallback, NavigatorUserMediaErrorCallback* errorCallback, MediaErrorState& errorState)
{
WebMediaConstraints audio = parseOptions(options.audio(), errorState);
WebMediaConstraints audio = parseOptions(context, options.audio(), errorState);
if (errorState.hadException())
return nullptr;
WebMediaConstraints video = parseOptions(options.video(), errorState);
WebMediaConstraints video = parseOptions(context, options.video(), errorState);
if (errorState.hadException())
return nullptr;
......
......@@ -65856,6 +65856,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<int value="1147" label="NotificationAPIInsecureOriginIframe"/>
<int value="1148" label="NotificationAPISecureOriginIframe"/>
<int value="1149" label="WebSocket"/>
<int value="1150" label="MediaStreamConstraintsNameValue"/>
<int value="1151" label="MediaStreamConstraintsFromDictionary"/>
<int value="1152" label="MediaStreamConstraintsConformant"/>
</enum>
<enum name="FetchRequestMode" type="int">
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