Reviewers: Mike West, hta - Chromium, tommi-chrömium
CL:
https://codereview.chromium.org/2156063002/Message:
Please take a look, mkwst and hta. (And tommi when back from vacation.)
Description:
Preparation CL for new Promise-based RTCPeerConnection.getStats.
The WebRTC spec defines the following getStats[1]:
partial interface RTCPeerConnection {
Promise<RTCStatsReport> getStats(optional MediaStreamTrack? selector =
null);
};
interface RTCStatsReport {
readonly maplike<DOMString, object>; // object: RTCStats-derived
dictionaries
};
dictionary RTCStats {
DOMHighResTimeStamp timestamp;
RTCStatsType type;
DOMString id;
};
There currently exists a callback-based getStats method and related interfaces
that are different from the spec. To not break existing usages, these will be
kept for a transition period.
Before this CL, what we call "RTCStatsReport" is something other than what the
spec refers to (and is more similar to the spec's RTCStats but different).
A big difference between old and new stats API is that the old stats are
presented as string-string maps and the new API as well defined and typed
dictionary members (each deriviation should have its own .idl file). This makes
the two APIs incompatible.
Changes:
- The old RTCStatsReport is renamed to RTCLegacyStatsReport to avoid a name
conflict. This should be low-risk since its a NoInterfaceObject.
- The callback-based getStats is changed in ways necessary to support two
getStats functions. E.g. it now returns Promise<void> because the return
values both have to be Promise<Foo>.
- The promise-based getStats is added behind runtime enabled test feature
"RTCPeerConnectionNewGetStats". It is not implemented yet and always rejects
its promise for now.
- The new signature is tested in RTCPeerConnection-statsPromise.html.
Due to WebIDL limitations, callback interfaces and interfaces are
indistinguishable[2] when deciding which getStats function to call. This CL gets
around this by defining getStats(optional any value) in WebIDL and examining the
value's type information in C++. See
crbug.com/629068.
[1]
https://www.w3.org/TR/2016/WD-webrtc-20160531/#sec.stats-model[2]
https://heycam.github.io/webidl/#idl-overloadingBUG=627816, 629068
Base URL:
https://chromium.googlesource.com/chromium/src.git@masterAffected files (+201, -179 lines):
A third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-statsPromise.html
A third_party/WebKit/LayoutTests/fast/peerconnection/RTCPeerConnection-statsPromise-expected.txt
M third_party/WebKit/Source/modules/modules.gypi
A + third_party/WebKit/Source/modules/peerconnection/RTCLegacyStatsReport.h
A + third_party/WebKit/Source/modules/peerconnection/RTCLegacyStatsReport.cpp
A + third_party/WebKit/Source/modules/peerconnection/RTCLegacyStatsReport.idl
M third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.h
M third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp
M third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.idl
D third_party/WebKit/Source/modules/peerconnection/RTCStatsReport.h
D third_party/WebKit/Source/modules/peerconnection/RTCStatsReport.cpp
D third_party/WebKit/Source/modules/peerconnection/RTCStatsReport.idl
M third_party/WebKit/Source/modules/peerconnection/RTCStatsResponse.h
M third_party/WebKit/Source/modules/peerconnection/RTCStatsResponse.cpp
M third_party/WebKit/Source/modules/peerconnection/RTCStatsResponse.idl
M third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in