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

Side by Side Diff: webrtc/api/statstypes.cc

Issue 2384693002: Test RTC_DCHECK_IS_ON instead of checking DCHECK_ALWAYS_ON everywhere (Closed)
Patch Set: !!! 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 unified diff | Download patch
« no previous file with comments | « webrtc/api/statscollector.cc ('k') | webrtc/base/buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 RTC_DCHECK_EQ(type_, other.type_); 269 RTC_DCHECK_EQ(type_, other.type_);
270 270
271 switch (type_) { 271 switch (type_) {
272 case kInt: 272 case kInt:
273 return value_.int_ == other.value_.int_; 273 return value_.int_ == other.value_.int_;
274 case kInt64: 274 case kInt64:
275 return value_.int64_ == other.value_.int64_; 275 return value_.int64_ == other.value_.int64_;
276 case kFloat: 276 case kFloat:
277 return value_.float_ == other.value_.float_; 277 return value_.float_ == other.value_.float_;
278 case kStaticString: { 278 case kStaticString: {
279 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) 279 #if RTC_DCHECK_IS_ON
280 if (value_.static_string_ != other.value_.static_string_) { 280 if (value_.static_string_ != other.value_.static_string_) {
281 RTC_DCHECK(strcmp(value_.static_string_, other.value_.static_string_) != 281 RTC_DCHECK(strcmp(value_.static_string_, other.value_.static_string_) !=
282 0) 282 0)
283 << "Duplicate global?"; 283 << "Duplicate global?";
284 } 284 }
285 #endif 285 #endif
286 return value_.static_string_ == other.value_.static_string_; 286 return value_.static_string_ == other.value_.static_string_;
287 } 287 }
288 case kString: 288 case kString:
289 return *value_.string_ == *other.value_.string_; 289 return *value_.string_ == *other.value_.string_;
290 case kBool: 290 case kBool:
291 return value_.bool_ == other.value_.bool_; 291 return value_.bool_ == other.value_.bool_;
292 case kId: 292 case kId:
293 return (*value_.id_)->Equals(*other.value_.id_); 293 return (*value_.id_)->Equals(*other.value_.id_);
294 } 294 }
295 RTC_NOTREACHED(); 295 RTC_NOTREACHED();
296 return false; 296 return false;
297 } 297 }
298 298
299 bool StatsReport::Value::operator==(const std::string& value) const { 299 bool StatsReport::Value::operator==(const std::string& value) const {
300 return (type_ == kString && value_.string_->compare(value) == 0) || 300 return (type_ == kString && value_.string_->compare(value) == 0) ||
301 (type_ == kStaticString && value.compare(value_.static_string_) == 0); 301 (type_ == kStaticString && value.compare(value_.static_string_) == 0);
302 } 302 }
303 303
304 bool StatsReport::Value::operator==(const char* value) const { 304 bool StatsReport::Value::operator==(const char* value) const {
305 if (type_ == kString) 305 if (type_ == kString)
306 return value_.string_->compare(value) == 0; 306 return value_.string_->compare(value) == 0;
307 if (type_ != kStaticString) 307 if (type_ != kStaticString)
308 return false; 308 return false;
309 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) 309 #if RTC_DCHECK_IS_ON
310 if (value_.static_string_ != value) 310 if (value_.static_string_ != value)
311 RTC_DCHECK(strcmp(value_.static_string_, value) != 0) 311 RTC_DCHECK(strcmp(value_.static_string_, value) != 0)
312 << "Duplicate global?"; 312 << "Duplicate global?";
313 #endif 313 #endif
314 return value == value_.static_string_; 314 return value == value_.static_string_;
315 } 315 }
316 316
317 bool StatsReport::Value::operator==(int64_t value) const { 317 bool StatsReport::Value::operator==(int64_t value) const {
318 return type_ == kInt ? value_.int_ == static_cast<int>(value) : 318 return type_ == kInt ? value_.int_ == static_cast<int>(value) :
319 (type_ == kInt64 ? value_.int64_ == value : false); 319 (type_ == kInt64 ? value_.int64_ == value : false);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 // Looks for a report with the given |id|. If one is not found, NULL 772 // Looks for a report with the given |id|. If one is not found, NULL
773 // will be returned. 773 // will be returned.
774 StatsReport* StatsCollection::Find(const StatsReport::Id& id) { 774 StatsReport* StatsCollection::Find(const StatsReport::Id& id) {
775 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 775 RTC_DCHECK(thread_checker_.CalledOnValidThread());
776 Container::iterator it = std::find_if(list_.begin(), list_.end(), 776 Container::iterator it = std::find_if(list_.begin(), list_.end(),
777 [&id](const StatsReport* r)->bool { return r->id()->Equals(id); }); 777 [&id](const StatsReport* r)->bool { return r->id()->Equals(id); });
778 return it == list_.end() ? nullptr : *it; 778 return it == list_.end() ? nullptr : *it;
779 } 779 }
780 780
781 } // namespace webrtc 781 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/statscollector.cc ('k') | webrtc/base/buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698