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

Side by Side Diff: webrtc/base/checks.h

Issue 1338763002: Remove dependency on Chromium in diagnostic_logging.h. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc/trunk/webrtc.git@rename_checks
Patch Set: Added bug in comment. Created 5 years, 3 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 | « no previous file | webrtc/overrides/webrtc/base/diagnostic_logging.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 2006 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2006 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
11 #ifndef WEBRTC_BASE_CHECKS_H_ 11 #ifndef WEBRTC_BASE_CHECKS_H_
12 #define WEBRTC_BASE_CHECKS_H_ 12 #define WEBRTC_BASE_CHECKS_H_
13 13
14 #include <sstream> 14 #include <sstream>
15 #include <string> 15 #include <string>
16 16
17 #ifdef WEBRTC_CHROMIUM_BUILD
18 // Include logging.h in a Chromium build to enable the overrides mechanism for
19 // using Chromium's macros. Otherwise, don't depend on logging.h.
20 // TODO(ajm): Ideally, checks.h would be combined with logging.h, but
21 // consolidation with system_wrappers/logging.h should happen first.
22 #include "webrtc/base/logging.h"
23 #endif
24 #include "webrtc/typedefs.h" 17 #include "webrtc/typedefs.h"
25 18
26 // The macros here print a message to stderr and abort under various 19 // The macros here print a message to stderr and abort under various
27 // conditions. All will accept additional stream messages. For example: 20 // conditions. All will accept additional stream messages. For example:
28 // RTC_DCHECK_EQ(foo, bar) << "I'm printed when foo != bar."; 21 // RTC_DCHECK_EQ(foo, bar) << "I'm printed when foo != bar.";
29 // 22 //
30 // - RTC_CHECK(x) is an assertion that x is always true, and that if it isn't, 23 // - RTC_CHECK(x) is an assertion that x is always true, and that if it isn't,
31 // it's better to terminate the process than to continue. During development, 24 // it's better to terminate the process than to continue. During development,
32 // the reason that it's better to terminate might simply be that the error 25 // the reason that it's better to terminate might simply be that the error
33 // handling code isn't in place yet; in production, the reason might be that 26 // handling code isn't in place yet; in production, the reason might be that
(...skipping 18 matching lines...) Expand all
52 // RTC_DCHECK only evaluates its argument in debug builds, so if x has visible 45 // RTC_DCHECK only evaluates its argument in debug builds, so if x has visible
53 // side effects, you need to write e.g. 46 // side effects, you need to write e.g.
54 // bool w = x; RTC_DCHECK(w); 47 // bool w = x; RTC_DCHECK(w);
55 // 48 //
56 // - RTC_CHECK_EQ, _NE, _GT, ..., and RTC_DCHECK_EQ, _NE, _GT, ... are 49 // - RTC_CHECK_EQ, _NE, _GT, ..., and RTC_DCHECK_EQ, _NE, _GT, ... are
57 // specialized variants of RTC_CHECK and RTC_DCHECK that print prettier 50 // specialized variants of RTC_CHECK and RTC_DCHECK that print prettier
58 // messages if the condition doesn't hold. Prefer them to raw RTC_CHECK and 51 // messages if the condition doesn't hold. Prefer them to raw RTC_CHECK and
59 // RTC_DCHECK. 52 // RTC_DCHECK.
60 // 53 //
61 // - FATAL() aborts unconditionally. 54 // - FATAL() aborts unconditionally.
55 //
56 // TODO(ajm): Ideally, checks.h would be combined with logging.h, but
57 // consolidation with system_wrappers/logging.h should happen first.
62 58
63 namespace rtc { 59 namespace rtc {
64 60
65 // Helper macro which avoids evaluating the arguments to a stream if 61 // Helper macro which avoids evaluating the arguments to a stream if
66 // the condition doesn't hold. 62 // the condition doesn't hold.
67 #define RTC_LAZY_STREAM(stream, condition) \ 63 #define RTC_LAZY_STREAM(stream, condition) \
68 !(condition) ? static_cast<void>(0) : rtc::FatalMessageVoidify() & (stream) 64 !(condition) ? static_cast<void>(0) : rtc::FatalMessageVoidify() & (stream)
69 65
70 // The actual stream used isn't important. We reference condition in the code 66 // The actual stream used isn't important. We reference condition in the code
71 // but don't evaluate it; this is to avoid "unused variable" warnings (we do so 67 // but don't evaluate it; this is to avoid "unused variable" warnings (we do so
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // remainder is zero. 218 // remainder is zero.
223 template <typename T> 219 template <typename T>
224 inline T CheckedDivExact(T a, T b) { 220 inline T CheckedDivExact(T a, T b) {
225 RTC_CHECK_EQ(a % b, static_cast<T>(0)); 221 RTC_CHECK_EQ(a % b, static_cast<T>(0));
226 return a / b; 222 return a / b;
227 } 223 }
228 224
229 } // namespace rtc 225 } // namespace rtc
230 226
231 #endif // WEBRTC_BASE_CHECKS_H_ 227 #endif // WEBRTC_BASE_CHECKS_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/overrides/webrtc/base/diagnostic_logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698