Chromium Code Reviews| Index: webrtc/api/statstypes.h |
| diff --git a/webrtc/api/statstypes.h b/webrtc/api/statstypes.h |
| index 1a55145ab4cbe1753774492b5e7895c90b395aab..3d1f7b82dd47a13a3735876914b98fa3787084a1 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,18 @@ class StatsReport { |
| ~Value(); |
| + // Support ref counting. Note that for performance reasons, we |
| + // don't use thread safe operations. Therefore, all operations |
| + // affecting the ref count (in practice, creation and copying of |
| + // the Values mapping) must occur on webrtc's signalling thread. |
|
tommi
2017/01/18 11:59:22
can we use a thread or sequence checker in DCHECK
nisse-webrtc
2017/01/18 12:16:32
Sure, adding a ThreadChecker should be possible. A
|
| + 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 +315,8 @@ class StatsReport { |
| const StatsValueName name; |
| private: |
| + mutable int ref_count_ = 0; |
| + |
| const Type type_; |
| // TODO(tommi): Use C++ 11 union and make value_ const. |
| union InternalType { |
| @@ -316,13 +329,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|. |