RTCStatsMember<bool> and RTCStatsMember<std::vector<bool>> added.
RTCStatsMemberInterface::Type's kBool and kSequenceBool.

This means that RTCStats-derived classes ("RTCStats-derived
dictionaries"[1]) can contain boolean and sequence of boolean members.

[1] https://w3c.github.io/webrtc-stats/

BUG=chromium:627816
NOTRY=True

Review-Url: https://codereview.webrtc.org/2387343002
Cr-Commit-Position: refs/heads/master@{#14509}
diff --git a/webrtc/api/stats/rtcstats.h b/webrtc/api/stats/rtcstats.h
index 01dd1c3..988291b 100644
--- a/webrtc/api/stats/rtcstats.h
+++ b/webrtc/api/stats/rtcstats.h
@@ -166,6 +166,7 @@
  public:
   // Member value types.
   enum Type {
+    kBool,                  // bool
     kInt32,                 // int32_t
     kUint32,                // uint32_t
     kInt64,                 // int64_t
@@ -173,6 +174,7 @@
     kDouble,                // double
     kString,                // std::string
 
+    kSequenceBool,          // std::vector<bool>
     kSequenceInt32,         // std::vector<int32_t>
     kSequenceUint32,        // std::vector<uint32_t>
     kSequenceInt64,         // std::vector<int64_t>
diff --git a/webrtc/stats/rtcstats.cc b/webrtc/stats/rtcstats.cc
index 6b6c437..543ef42 100644
--- a/webrtc/stats/rtcstats.cc
+++ b/webrtc/stats/rtcstats.cc
@@ -93,6 +93,8 @@
     return to_str;                                                             \
   }
 
+WEBRTC_DEFINE_RTCSTATSMEMBER(bool, kBool, false, false,
+                             rtc::ToString(value_));
 WEBRTC_DEFINE_RTCSTATSMEMBER(int32_t, kInt32, false, false,
                              rtc::ToString(value_));
 WEBRTC_DEFINE_RTCSTATSMEMBER(uint32_t, kUint32, false, false,
@@ -106,6 +108,9 @@
 WEBRTC_DEFINE_RTCSTATSMEMBER(std::string, kString, false, true,
                              value_);
 WEBRTC_DEFINE_RTCSTATSMEMBER(
+    std::vector<bool>, kSequenceBool, true, false,
+    VectorToString(value_));
+WEBRTC_DEFINE_RTCSTATSMEMBER(
     std::vector<int32_t>, kSequenceInt32, true, false,
     VectorToString(value_));
 WEBRTC_DEFINE_RTCSTATSMEMBER(
diff --git a/webrtc/stats/rtcstats_unittest.cc b/webrtc/stats/rtcstats_unittest.cc
index 6cb8817..88a2e03 100644
--- a/webrtc/stats/rtcstats_unittest.cc
+++ b/webrtc/stats/rtcstats_unittest.cc
@@ -51,10 +51,11 @@
   EXPECT_EQ(stats.id(), "testId");
   EXPECT_EQ(stats.timestamp_us(), static_cast<int64_t>(42));
   std::vector<const RTCStatsMemberInterface*> members = stats.Members();
-  EXPECT_EQ(members.size(), static_cast<size_t>(12));
+  EXPECT_EQ(members.size(), static_cast<size_t>(14));
   for (const RTCStatsMemberInterface* member : members) {
     EXPECT_FALSE(member->is_defined());
   }
+  stats.m_bool = true;
   stats.m_int32 = 123;
   stats.m_uint32 = 123;
   stats.m_int64 = 123;
@@ -62,6 +63,8 @@
   stats.m_double = 123.0;
   stats.m_string = std::string("123");
 
+  std::vector<bool> sequence_bool;
+  sequence_bool.push_back(true);
   std::vector<int32_t> sequence_int32;
   sequence_int32.push_back(static_cast<int32_t>(1));
   std::vector<uint32_t> sequence_uint32;
@@ -75,6 +78,7 @@
   std::vector<std::string> sequence_string;
   sequence_string.push_back(std::string("six"));
 
+  stats.m_sequence_bool = sequence_bool;
   stats.m_sequence_int32 = sequence_int32;
   stats.m_sequence_uint32 = sequence_uint32;
   EXPECT_FALSE(stats.m_sequence_int64.is_defined());
@@ -85,12 +89,14 @@
   for (const RTCStatsMemberInterface* member : members) {
     EXPECT_TRUE(member->is_defined());
   }
+  EXPECT_EQ(*stats.m_bool, true);
   EXPECT_EQ(*stats.m_int32, static_cast<int32_t>(123));
   EXPECT_EQ(*stats.m_uint32, static_cast<uint32_t>(123));
   EXPECT_EQ(*stats.m_int64, static_cast<int64_t>(123));
   EXPECT_EQ(*stats.m_uint64, static_cast<uint64_t>(123));
   EXPECT_EQ(*stats.m_double, 123.0);
   EXPECT_EQ(*stats.m_string, std::string("123"));
+  EXPECT_EQ(*stats.m_sequence_bool, sequence_bool);
   EXPECT_EQ(*stats.m_sequence_int32, sequence_int32);
   EXPECT_EQ(*stats.m_sequence_uint32, sequence_uint32);
   EXPECT_EQ(*stats.m_sequence_int64, sequence_int64);
diff --git a/webrtc/stats/test/rtcteststats.cc b/webrtc/stats/test/rtcteststats.cc
index c317294..a4bff77 100644
--- a/webrtc/stats/test/rtcteststats.cc
+++ b/webrtc/stats/test/rtcteststats.cc
@@ -16,12 +16,14 @@
 
 RTCTestStats::RTCTestStats(const std::string& id, int64_t timestamp_us)
     : RTCStats(id, timestamp_us),
+      m_bool("mBool"),
       m_int32("mInt32"),
       m_uint32("mUint32"),
       m_int64("mInt64"),
       m_uint64("mUint64"),
       m_double("mDouble"),
       m_string("mString"),
+      m_sequence_bool("mSequenceBool"),
       m_sequence_int32("mSequenceInt32"),
       m_sequence_uint32("mSequenceUint32"),
       m_sequence_int64("mSequenceInt64"),
diff --git a/webrtc/stats/test/rtcteststats.h b/webrtc/stats/test/rtcteststats.h
index c8191eb..8571fe8 100644
--- a/webrtc/stats/test/rtcteststats.h
+++ b/webrtc/stats/test/rtcteststats.h
@@ -23,12 +23,14 @@
   RTCTestStats(const std::string& id, int64_t timestamp_us);
 
   WEBRTC_RTCSTATS_IMPL(RTCStats, RTCTestStats,
+      &m_bool,
       &m_int32,
       &m_uint32,
       &m_int64,
       &m_uint64,
       &m_double,
       &m_string,
+      &m_sequence_bool,
       &m_sequence_int32,
       &m_sequence_uint32,
       &m_sequence_int64,
@@ -36,12 +38,14 @@
       &m_sequence_double,
       &m_sequence_string);
 
+  RTCStatsMember<bool> m_bool;
   RTCStatsMember<int32_t> m_int32;
   RTCStatsMember<uint32_t> m_uint32;
   RTCStatsMember<int64_t> m_int64;
   RTCStatsMember<uint64_t> m_uint64;
   RTCStatsMember<double> m_double;
   RTCStatsMember<std::string> m_string;
+  RTCStatsMember<std::vector<bool>> m_sequence_bool;
   RTCStatsMember<std::vector<int32_t>> m_sequence_int32;
   RTCStatsMember<std::vector<uint32_t>> m_sequence_uint32;
   RTCStatsMember<std::vector<int64_t>> m_sequence_int64;