| Index: webrtc/api/stats/rtcstats.h
|
| diff --git a/webrtc/api/stats/rtcstats.h b/webrtc/api/stats/rtcstats.h
|
| index 988291bd110a96c0bb0a324fb8b408e1c9843b7d..69175483021a748d8e4accd3239c4aa5ff256d79 100644
|
| --- a/webrtc/api/stats/rtcstats.h
|
| +++ b/webrtc/api/stats/rtcstats.h
|
| @@ -91,14 +91,15 @@ class RTCStats {
|
| int64_t timestamp_us_;
|
| };
|
|
|
| -// All |RTCStats| classes should use this macro in a public section of the class
|
| -// definition.
|
| +// All |RTCStats| classes should use these macros.
|
| +// |WEBRTC_RTCSTATS_DECL| is placed in a public section of the class definition.
|
| +// |WEBRTC_RTCSTATS_IMPL| is placed outside the class definition (in a .cc).
|
| //
|
| -// This macro declares the static |kType| and overrides methods as required by
|
| -// subclasses of |RTCStats|: |copy|, |type|, and
|
| +// These macros declare (in _DECL) and define (in _IMPL) the static |kType| and
|
| +// overrides methods as required by subclasses of |RTCStats|: |copy|, |type| and
|
| // |MembersOfThisObjectAndAncestors|. The |...| argument is a list of addresses
|
| -// to each member defined in the implementing class (list cannot be empty, must
|
| -// have at least one new member).
|
| +// to each member defined in the implementing class. The list must have at least
|
| +// one member.
|
| //
|
| // (Since class names need to be known to implement these methods this cannot be
|
| // part of the base |RTCStats|. While these methods could be implemented using
|
| @@ -112,34 +113,53 @@ class RTCStats {
|
| // rtcfoostats.h:
|
| // class RTCFooStats : public RTCStats {
|
| // public:
|
| -// RTCFooStats(const std::string& id, int64_t timestamp_us)
|
| -// : RTCStats(id, timestamp_us),
|
| -// foo("foo"),
|
| -// bar("bar") {
|
| -// }
|
| +// WEBRTC_RTCSTATS_DECL();
|
| //
|
| -// WEBRTC_RTCSTATS_IMPL(RTCStats, RTCFooStats,
|
| -// &foo,
|
| -// &bar);
|
| +// RTCFooStats(const std::string& id, int64_t timestamp_us);
|
| //
|
| // RTCStatsMember<int32_t> foo;
|
| // RTCStatsMember<int32_t> bar;
|
| // };
|
| //
|
| // rtcfoostats.cc:
|
| -// const char RTCFooStats::kType[] = "foo-stats";
|
| +// WEBRTC_RTCSTATS_IMPL(RTCFooStats, RTCStats, "foo-stats"
|
| +// &foo,
|
| +// &bar);
|
| //
|
| -#define WEBRTC_RTCSTATS_IMPL(parent_class, this_class, ...) \
|
| +// RTCFooStats::RTCFooStats(const std::string& id, int64_t timestamp_us)
|
| +// : RTCStats(id, timestamp_us),
|
| +// foo("foo"),
|
| +// bar("bar") {
|
| +// }
|
| +//
|
| +#define WEBRTC_RTCSTATS_DECL() \
|
| public: \
|
| static const char kType[]; \
|
| - std::unique_ptr<webrtc::RTCStats> copy() const override { \
|
| - return std::unique_ptr<webrtc::RTCStats>(new this_class(*this)); \
|
| - } \
|
| - const char* type() const override { return this_class::kType; } \
|
| + \
|
| + std::unique_ptr<webrtc::RTCStats> copy() const override; \
|
| + const char* type() const override; \
|
| + \
|
| protected: \
|
| std::vector<const webrtc::RTCStatsMemberInterface*> \
|
| MembersOfThisObjectAndAncestors( \
|
| - size_t local_var_additional_capacity) const override { \
|
| + size_t local_var_additional_capacity) const override; \
|
| + \
|
| + public:
|
| +
|
| +#define WEBRTC_RTCSTATS_IMPL(this_class, parent_class, type_str, ...) \
|
| + const char this_class::kType[] = type_str; \
|
| + \
|
| + std::unique_ptr<webrtc::RTCStats> this_class::copy() const { \
|
| + return std::unique_ptr<webrtc::RTCStats>(new this_class(*this)); \
|
| + } \
|
| + \
|
| + const char* this_class::type() const { \
|
| + return this_class::kType; \
|
| + } \
|
| + \
|
| + std::vector<const webrtc::RTCStatsMemberInterface*> \
|
| + this_class::MembersOfThisObjectAndAncestors( \
|
| + size_t local_var_additional_capacity) const { \
|
| const webrtc::RTCStatsMemberInterface* local_var_members[] = { \
|
| __VA_ARGS__ \
|
| }; \
|
| @@ -155,8 +175,7 @@ class RTCStats {
|
| &local_var_members[0], \
|
| &local_var_members[local_var_members_count]); \
|
| return local_var_members_vec; \
|
| - } \
|
| - public:
|
| + }
|
|
|
| // Interface for |RTCStats| members, which have a name and a value of a type
|
| // defined in a subclass. Only the types listed in |Type| are supported, these
|
|
|