Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Unified Diff: webrtc/api/stats/rtcstats.h

Issue 2373503002: rtc_stats: Update code to remove chromium style warnings suppression. (Closed)
Patch Set: Addressed comments and rebase with master Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/rtcstatscollector_unittest.cc ('k') | webrtc/api/stats/rtcstats_objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « webrtc/api/rtcstatscollector_unittest.cc ('k') | webrtc/api/stats/rtcstats_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698