diff options
author | jbauch <jbauch@webrtc.org> | 2015-08-07 09:48:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-07 16:48:22 +0000 |
commit | 25c96d02cdd2460b378ab89e4b90b17a81bf0d4a (patch) | |
tree | a106fc299def5b3053c844b850423ca0a5d3e0c7 /talk/app/webrtc/statstypes.cc | |
parent | 2328a94ec7ee545a26e8220c5ae157e1b3b5144f (diff) | |
download | webrtc-25c96d02cdd2460b378ab89e4b90b17a81bf0d4a.tar.gz |
Add thread checker to StatsCollection.
This CL makes sure the methods are always called on the correct thread.
Review URL: https://codereview.webrtc.org/1235263003
Cr-Commit-Position: refs/heads/master@{#9688}
Diffstat (limited to 'talk/app/webrtc/statstypes.cc')
-rw-r--r-- | talk/app/webrtc/statstypes.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/talk/app/webrtc/statstypes.cc b/talk/app/webrtc/statstypes.cc index a902210478..a23b959033 100644 --- a/talk/app/webrtc/statstypes.cc +++ b/talk/app/webrtc/statstypes.cc @@ -720,23 +720,28 @@ StatsCollection::StatsCollection() { } StatsCollection::~StatsCollection() { + DCHECK(thread_checker_.CalledOnValidThread()); for (auto* r : list_) delete r; } StatsCollection::const_iterator StatsCollection::begin() const { + DCHECK(thread_checker_.CalledOnValidThread()); return list_.begin(); } StatsCollection::const_iterator StatsCollection::end() const { + DCHECK(thread_checker_.CalledOnValidThread()); return list_.end(); } size_t StatsCollection::size() const { + DCHECK(thread_checker_.CalledOnValidThread()); return list_.size(); } StatsReport* StatsCollection::InsertNew(const StatsReport::Id& id) { + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(Find(id) == nullptr); StatsReport* report = new StatsReport(id); list_.push_back(report); @@ -744,11 +749,13 @@ StatsReport* StatsCollection::InsertNew(const StatsReport::Id& id) { } StatsReport* StatsCollection::FindOrAddNew(const StatsReport::Id& id) { + DCHECK(thread_checker_.CalledOnValidThread()); StatsReport* ret = Find(id); return ret ? ret : InsertNew(id); } StatsReport* StatsCollection::ReplaceOrAddNew(const StatsReport::Id& id) { + DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(id.get()); Container::iterator it = std::find_if(list_.begin(), list_.end(), [&id](const StatsReport* r)->bool { return r->id()->Equals(id); }); @@ -764,6 +771,7 @@ StatsReport* StatsCollection::ReplaceOrAddNew(const StatsReport::Id& id) { // Looks for a report with the given |id|. If one is not found, NULL // will be returned. StatsReport* StatsCollection::Find(const StatsReport::Id& id) { + DCHECK(thread_checker_.CalledOnValidThread()); Container::iterator it = std::find_if(list_.begin(), list_.end(), [&id](const StatsReport* r)->bool { return r->id()->Equals(id); }); return it == list_.end() ? nullptr : *it; |