Chromium Code Reviews| Index: webrtc/api/stats/rtcstats.h |
| diff --git a/webrtc/api/stats/rtcstats.h b/webrtc/api/stats/rtcstats.h |
| index 01dd1c3e215e4eed0d85884f653302ab1e807bc9..22c9befb5eb3cfd5a35409391c0387bdd5c34d78 100644 |
| --- a/webrtc/api/stats/rtcstats.h |
| +++ b/webrtc/api/stats/rtcstats.h |
| @@ -91,11 +91,12 @@ 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 |
| +// The macro declares and defines the static |kType| and overrides methods as |
|
hta-webrtc
2016/10/04 13:51:04
More precise:
These macros declare (in _DECL) and
hbos
2016/10/06 08:38:57
Done.
|
| +// 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). |
|
hta-webrtc
2016/10/04 13:51:04
Suggest replacing parenthesis with "The list must
hbos
2016/10/06 08:38:57
Done.
|
| @@ -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 |