Chromium Code Reviews| Index: webrtc/api/statstypes.h |
| diff --git a/webrtc/api/statstypes.h b/webrtc/api/statstypes.h |
| index 1a55145ab4cbe1753774492b5e7895c90b395aab..8e8025f5c7adf94011b227d3ae2c1e92edc81477 100644 |
| --- a/webrtc/api/statstypes.h |
| +++ b/webrtc/api/statstypes.h |
| @@ -22,7 +22,6 @@ |
| #include "webrtc/base/basictypes.h" |
| #include "webrtc/base/common.h" |
| #include "webrtc/base/constructormagic.h" |
| -#include "webrtc/base/linked_ptr.h" |
| #include "webrtc/base/refcount.h" |
| #include "webrtc/base/scoped_ref_ptr.h" |
| #include "webrtc/base/stringencode.h" |
| @@ -264,6 +263,16 @@ class StatsReport { |
| ~Value(); |
| + // Support ref counting. Note that we don't need thread safety, so |
| + // no atomic operations. |
| + int AddRef() const { return ++ref_count_; } |
| + int Release() const { |
| + int count = --ref_count_; |
| + if (!count) |
| + delete this; |
| + return count; |
| + } |
| + |
| // TODO(tommi): This compares name as well as value... |
| // I think we should only need to compare the value part and |
| // move the name part into a hash map. |
| @@ -304,6 +313,8 @@ class StatsReport { |
| const StatsValueName name; |
| private: |
| + mutable int ref_count_; |
|
nisse-webrtc
2017/01/18 10:54:01
It seems I forgot to initialize this one... Will f
|
| + |
| const Type type_; |
| // TODO(tommi): Use C++ 11 union and make value_ const. |
| union InternalType { |
| @@ -316,13 +327,10 @@ class StatsReport { |
| Id* id_; |
| } value_; |
| - private: |
| RTC_DISALLOW_COPY_AND_ASSIGN(Value); |
| }; |
| - // TODO(tommi): Consider using a similar approach to how we store Ids using |
| - // scoped_refptr for values. |
| - typedef rtc::linked_ptr<Value> ValuePtr; |
| + typedef rtc::scoped_refptr<Value> ValuePtr; |
| typedef std::map<StatsValueName, ValuePtr> Values; |
| // Ownership of |id| is passed to |this|. |