RTCDataChannelStats[1] added, supporting all stats members.

Also updates MockDataChannel to also mock id, messages_sent, bytes_sent,
messages_received and bytes_received.

[1] https://w3c.github.io/webrtc-stats/#dcstats-dict*

BUG=chromium:654927, chromium:627816

Review-Url: https://codereview.webrtc.org/2420473002
Cr-Commit-Position: refs/heads/master@{#14670}
diff --git a/webrtc/api/stats/rtcstats_objects.h b/webrtc/api/stats/rtcstats_objects.h
index 4738fe8..ad6a39c 100644
--- a/webrtc/api/stats/rtcstats_objects.h
+++ b/webrtc/api/stats/rtcstats_objects.h
@@ -17,6 +17,14 @@
 
 namespace webrtc {
 
+// https://w3c.github.io/webrtc-pc/#idl-def-rtcdatachannelstate
+struct RTCDataChannelState {
+  static const char* kConnecting;
+  static const char* kOpen;
+  static const char* kClosing;
+  static const char* kClosed;
+};
+
 // https://w3c.github.io/webrtc-stats/#dom-rtcstatsicecandidatepairstate
 struct RTCStatsIceCandidatePairState {
   static const char* kFrozen;
@@ -27,7 +35,7 @@
   static const char* kCancelled;
 };
 
-// https://www.w3.org/TR/webrtc/#rtcicecandidatetype-enum
+// https://w3c.github.io/webrtc-pc/#rtcicecandidatetype-enum
 struct RTCIceCandidateType {
   static const char* kHost;
   static const char* kSrflx;
@@ -129,6 +137,27 @@
   RTCStatsMember<std::string> issuer_certificate_id;
 };
 
+// https://w3c.github.io/webrtc-stats/#dcstats-dict*
+class RTCDataChannelStats final : public RTCStats {
+ public:
+  WEBRTC_RTCSTATS_DECL();
+
+  RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
+  RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
+  RTCDataChannelStats(const RTCDataChannelStats& other);
+  ~RTCDataChannelStats() override;
+
+  RTCStatsMember<std::string> label;
+  RTCStatsMember<std::string> protocol;
+  RTCStatsMember<int32_t> datachannelid;
+  // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
+  RTCStatsMember<std::string> state;
+  RTCStatsMember<uint32_t> messages_sent;
+  RTCStatsMember<uint64_t> bytes_sent;
+  RTCStatsMember<uint32_t> messages_received;
+  RTCStatsMember<uint64_t> bytes_received;
+};
+
 // https://w3c.github.io/webrtc-stats/#pcstats-dict*
 // TODO(hbos): Tracking bug crbug.com/636818
 class RTCPeerConnectionStats final : public RTCStats {