Add RTC_ prefix to (D)CHECKs and related macros.

We must remove dependency on Chromium, i.e. we can't use Chromium's base/logging.h. That means we need to define these macros in WebRTC also when doing Chromium builds. And this causes redefinition.

Alternative solutions:
* Check if we already have defined e.g. CHECK, and don't define them in that case. This makes us depend on include order in Chromium, which is not acceptable.
* Don't allow using the macros in WebRTC headers. Error prone since if someone adds it there by mistake it may compile fine, but later break if a header in added or order is changed in Chromium. That will be confusing and hard to enforce.
* Ensure that headers that are included by an embedder don't include our macros. This would require some heavy refactoring to be maintainable and enforcable.
* Changes in Chromium for this is obviously not an option.

BUG=chromium:468375
NOTRY=true

Review URL: https://codereview.webrtc.org/1335923002

Cr-Commit-Position: refs/heads/master@{#9964}
diff --git a/webrtc/common_audio/audio_converter.cc b/webrtc/common_audio/audio_converter.cc
index 624c38d..07e5c6b 100644
--- a/webrtc/common_audio/audio_converter.cc
+++ b/webrtc/common_audio/audio_converter.cc
@@ -106,7 +106,7 @@
  public:
   CompositionConverter(ScopedVector<AudioConverter> converters)
       : converters_(converters.Pass()) {
-    CHECK_GE(converters_.size(), 2u);
+    RTC_CHECK_GE(converters_.size(), 2u);
     // We need an intermediate buffer after every converter.
     for (auto it = converters_.begin(); it != converters_.end() - 1; ++it)
       buffers_.push_back(new ChannelBuffer<float>((*it)->dst_frames(),
@@ -188,12 +188,13 @@
       src_frames_(src_frames),
       dst_channels_(dst_channels),
       dst_frames_(dst_frames) {
-  CHECK(dst_channels == src_channels || dst_channels == 1 || src_channels == 1);
+  RTC_CHECK(dst_channels == src_channels || dst_channels == 1 ||
+            src_channels == 1);
 }
 
 void AudioConverter::CheckSizes(size_t src_size, size_t dst_capacity) const {
-  CHECK_EQ(src_size, src_channels() * src_frames());
-  CHECK_GE(dst_capacity, dst_channels() * dst_frames());
+  RTC_CHECK_EQ(src_size, src_channels() * src_frames());
+  RTC_CHECK_GE(dst_capacity, dst_channels() * dst_frames());
 }
 
 }  // namespace webrtc
diff --git a/webrtc/common_audio/audio_converter.h b/webrtc/common_audio/audio_converter.h
index c6fe08e..7d1513b 100644
--- a/webrtc/common_audio/audio_converter.h
+++ b/webrtc/common_audio/audio_converter.h
@@ -49,7 +49,7 @@
   AudioConverter(int src_channels, size_t src_frames, int dst_channels,
                  size_t dst_frames);
 
-  // Helper to CHECK that inputs are correctly sized.
+  // Helper to RTC_CHECK that inputs are correctly sized.
   void CheckSizes(size_t src_size, size_t dst_capacity) const;
 
  private:
diff --git a/webrtc/common_audio/audio_ring_buffer.cc b/webrtc/common_audio/audio_ring_buffer.cc
index 13cf36b..a29e53a 100644
--- a/webrtc/common_audio/audio_ring_buffer.cc
+++ b/webrtc/common_audio/audio_ring_buffer.cc
@@ -30,19 +30,19 @@
 
 void AudioRingBuffer::Write(const float* const* data, size_t channels,
                             size_t frames) {
-  DCHECK_EQ(buffers_.size(), channels);
+  RTC_DCHECK_EQ(buffers_.size(), channels);
   for (size_t i = 0; i < channels; ++i) {
     const size_t written = WebRtc_WriteBuffer(buffers_[i], data[i], frames);
-    CHECK_EQ(written, frames);
+    RTC_CHECK_EQ(written, frames);
   }
 }
 
 void AudioRingBuffer::Read(float* const* data, size_t channels, size_t frames) {
-  DCHECK_EQ(buffers_.size(), channels);
+  RTC_DCHECK_EQ(buffers_.size(), channels);
   for (size_t i = 0; i < channels; ++i) {
     const size_t read =
         WebRtc_ReadBuffer(buffers_[i], nullptr, data[i], frames);
-    CHECK_EQ(read, frames);
+    RTC_CHECK_EQ(read, frames);
   }
 }
 
@@ -60,7 +60,7 @@
   for (auto buf : buffers_) {
     const size_t moved =
         static_cast<size_t>(WebRtc_MoveReadPtr(buf, static_cast<int>(frames)));
-    CHECK_EQ(moved, frames);
+    RTC_CHECK_EQ(moved, frames);
   }
 }
 
@@ -68,7 +68,7 @@
   for (auto buf : buffers_) {
     const size_t moved = static_cast<size_t>(
         -WebRtc_MoveReadPtr(buf, -static_cast<int>(frames)));
-    CHECK_EQ(moved, frames);
+    RTC_CHECK_EQ(moved, frames);
   }
 }
 
diff --git a/webrtc/common_audio/blocker.cc b/webrtc/common_audio/blocker.cc
index 359e881..0133550 100644
--- a/webrtc/common_audio/blocker.cc
+++ b/webrtc/common_audio/blocker.cc
@@ -118,8 +118,8 @@
       window_(new float[block_size_]),
       shift_amount_(shift_amount),
       callback_(callback) {
-  CHECK_LE(num_output_channels_, num_input_channels_);
-  CHECK_LE(shift_amount_, block_size_);
+  RTC_CHECK_LE(num_output_channels_, num_input_channels_);
+  RTC_CHECK_LE(shift_amount_, block_size_);
 
   memcpy(window_.get(), window, block_size_ * sizeof(*window_.get()));
   input_buffer_.MoveReadPositionBackward(initial_delay_);
@@ -169,9 +169,9 @@
                            int num_input_channels,
                            int num_output_channels,
                            float* const* output) {
-  CHECK_EQ(chunk_size, chunk_size_);
-  CHECK_EQ(num_input_channels, num_input_channels_);
-  CHECK_EQ(num_output_channels, num_output_channels_);
+  RTC_CHECK_EQ(chunk_size, chunk_size_);
+  RTC_CHECK_EQ(num_input_channels, num_input_channels_);
+  RTC_CHECK_EQ(num_output_channels, num_output_channels_);
 
   input_buffer_.Write(input, num_input_channels, chunk_size_);
   size_t first_frame_in_block = frame_offset_;
diff --git a/webrtc/common_audio/channel_buffer.h b/webrtc/common_audio/channel_buffer.h
index 00ea733..6050090 100644
--- a/webrtc/common_audio/channel_buffer.h
+++ b/webrtc/common_audio/channel_buffer.h
@@ -75,7 +75,7 @@
   // 0 <= channel < |num_channels_|
   // 0 <= sample < |num_frames_per_band_|
   const T* const* channels(size_t band) const {
-    DCHECK_LT(band, num_bands_);
+    RTC_DCHECK_LT(band, num_bands_);
     return &channels_[band * num_channels_];
   }
   T* const* channels(size_t band) {
@@ -91,8 +91,8 @@
   // 0 <= band < |num_bands_|
   // 0 <= sample < |num_frames_per_band_|
   const T* const* bands(int channel) const {
-    DCHECK_LT(channel, num_channels_);
-    DCHECK_GE(channel, 0);
+    RTC_DCHECK_LT(channel, num_channels_);
+    RTC_DCHECK_GE(channel, 0);
     return &bands_[channel * num_bands_];
   }
   T* const* bands(int channel) {
@@ -103,7 +103,7 @@
   // Sets the |slice| pointers to the |start_frame| position for each channel.
   // Returns |slice| for convenience.
   const T* const* Slice(T** slice, size_t start_frame) const {
-    DCHECK_LT(start_frame, num_frames_);
+    RTC_DCHECK_LT(start_frame, num_frames_);
     for (int i = 0; i < num_channels_; ++i)
       slice[i] = &channels_[i][start_frame];
     return slice;
@@ -120,7 +120,7 @@
   size_t size() const {return num_frames_ * num_channels_; }
 
   void SetDataForTesting(const T* data, size_t size) {
-    CHECK_EQ(size, this->size());
+    RTC_CHECK_EQ(size, this->size());
     memcpy(data_.get(), data, size * sizeof(*data));
   }
 
diff --git a/webrtc/common_audio/include/audio_util.h b/webrtc/common_audio/include/audio_util.h
index d8e1ce3..2c0028c 100644
--- a/webrtc/common_audio/include/audio_util.h
+++ b/webrtc/common_audio/include/audio_util.h
@@ -154,8 +154,8 @@
                                   size_t num_frames,
                                   int num_channels,
                                   T* deinterleaved) {
-  DCHECK_GT(num_channels, 0);
-  DCHECK_GT(num_frames, 0u);
+  RTC_DCHECK_GT(num_channels, 0);
+  RTC_DCHECK_GT(num_frames, 0u);
 
   const T* const end = interleaved + num_frames * num_channels;
 
diff --git a/webrtc/common_audio/lapped_transform.cc b/webrtc/common_audio/lapped_transform.cc
index 525450d..c01f1d9 100644
--- a/webrtc/common_audio/lapped_transform.cc
+++ b/webrtc/common_audio/lapped_transform.cc
@@ -24,9 +24,9 @@
                                                int num_input_channels,
                                                int num_output_channels,
                                                float* const* output) {
-  CHECK_EQ(num_input_channels, parent_->num_in_channels_);
-  CHECK_EQ(num_output_channels, parent_->num_out_channels_);
-  CHECK_EQ(parent_->block_length_, num_frames);
+  RTC_CHECK_EQ(num_input_channels, parent_->num_in_channels_);
+  RTC_CHECK_EQ(num_output_channels, parent_->num_out_channels_);
+  RTC_CHECK_EQ(parent_->block_length_, num_frames);
 
   for (int i = 0; i < num_input_channels; ++i) {
     memcpy(parent_->real_buf_.Row(i), input[i],
@@ -37,7 +37,7 @@
 
   size_t block_length = RealFourier::ComplexLength(
       RealFourier::FftOrder(num_frames));
-  CHECK_EQ(parent_->cplx_length_, block_length);
+  RTC_CHECK_EQ(parent_->cplx_length_, block_length);
   parent_->block_processor_->ProcessAudioBlock(parent_->cplx_pre_.Array(),
                                                num_input_channels,
                                                parent_->cplx_length_,
@@ -83,13 +83,13 @@
       cplx_post_(num_out_channels,
                  cplx_length_,
                  RealFourier::kFftBufferAlignment) {
-  CHECK(num_in_channels_ > 0 && num_out_channels_ > 0);
-  CHECK_GT(block_length_, 0u);
-  CHECK_GT(chunk_length_, 0u);
-  CHECK(block_processor_);
+  RTC_CHECK(num_in_channels_ > 0 && num_out_channels_ > 0);
+  RTC_CHECK_GT(block_length_, 0u);
+  RTC_CHECK_GT(chunk_length_, 0u);
+  RTC_CHECK(block_processor_);
 
   // block_length_ power of 2?
-  CHECK_EQ(0u, block_length_ & (block_length_ - 1));
+  RTC_CHECK_EQ(0u, block_length_ & (block_length_ - 1));
 }
 
 void LappedTransform::ProcessChunk(const float* const* in_chunk,
diff --git a/webrtc/common_audio/lapped_transform_unittest.cc b/webrtc/common_audio/lapped_transform_unittest.cc
index 49751c0..f688cc2 100644
--- a/webrtc/common_audio/lapped_transform_unittest.cc
+++ b/webrtc/common_audio/lapped_transform_unittest.cc
@@ -29,7 +29,7 @@
                                  size_t frames,
                                  int out_channels,
                                  complex<float>* const* out_block) {
-    CHECK_EQ(in_channels, out_channels);
+    RTC_CHECK_EQ(in_channels, out_channels);
     for (int i = 0; i < out_channels; ++i) {
       memcpy(out_block[i], in_block[i], sizeof(**in_block) * frames);
     }
@@ -53,7 +53,7 @@
                                  size_t frames,
                                  int out_channels,
                                  complex<float>* const* out_block) {
-    CHECK_EQ(in_channels, out_channels);
+    RTC_CHECK_EQ(in_channels, out_channels);
 
     size_t full_length = (frames - 1) * 2;
     ++block_num_;
diff --git a/webrtc/common_audio/real_fourier.cc b/webrtc/common_audio/real_fourier.cc
index 29b704b..fef3c60 100644
--- a/webrtc/common_audio/real_fourier.cc
+++ b/webrtc/common_audio/real_fourier.cc
@@ -30,12 +30,12 @@
 }
 
 int RealFourier::FftOrder(size_t length) {
-  CHECK_GT(length, 0U);
+  RTC_CHECK_GT(length, 0U);
   return WebRtcSpl_GetSizeInBits(static_cast<uint32_t>(length - 1));
 }
 
 size_t RealFourier::FftLength(int order) {
-  CHECK_GE(order, 0);
+  RTC_CHECK_GE(order, 0);
   return static_cast<size_t>(1 << order);
 }
 
diff --git a/webrtc/common_audio/real_fourier_ooura.cc b/webrtc/common_audio/real_fourier_ooura.cc
index 1c4004d..8cd4c86 100644
--- a/webrtc/common_audio/real_fourier_ooura.cc
+++ b/webrtc/common_audio/real_fourier_ooura.cc
@@ -42,7 +42,7 @@
       // arrays on the first call.
       work_ip_(new size_t[ComputeWorkIpSize(length_)]()),
       work_w_(new float[complex_length_]()) {
-  CHECK_GE(fft_order, 1);
+  RTC_CHECK_GE(fft_order, 1);
 }
 
 void RealFourierOoura::Forward(const float* src, complex<float>* dest) const {
diff --git a/webrtc/common_audio/real_fourier_openmax.cc b/webrtc/common_audio/real_fourier_openmax.cc
index f7a0f64..bc3e734 100644
--- a/webrtc/common_audio/real_fourier_openmax.cc
+++ b/webrtc/common_audio/real_fourier_openmax.cc
@@ -23,19 +23,19 @@
 
 // Creates and initializes the Openmax state. Transfers ownership to caller.
 OMXFFTSpec_R_F32* CreateOpenmaxState(int order) {
-  CHECK_GE(order, 1);
+  RTC_CHECK_GE(order, 1);
   // The omx implementation uses this macro to check order validity.
-  CHECK_LE(order, TWIDDLE_TABLE_ORDER);
+  RTC_CHECK_LE(order, TWIDDLE_TABLE_ORDER);
 
   OMX_INT buffer_size;
   OMXResult r = omxSP_FFTGetBufSize_R_F32(order, &buffer_size);
-  CHECK_EQ(r, OMX_Sts_NoErr);
+  RTC_CHECK_EQ(r, OMX_Sts_NoErr);
 
   OMXFFTSpec_R_F32* omx_spec = malloc(buffer_size);
-  DCHECK(omx_spec);
+  RTC_DCHECK(omx_spec);
 
   r = omxSP_FFTInit_R_F32(omx_spec, order);
-  CHECK_EQ(r, OMX_Sts_NoErr);
+  RTC_CHECK_EQ(r, OMX_Sts_NoErr);
   return omx_spec;
 }
 
@@ -55,14 +55,14 @@
   // http://en.cppreference.com/w/cpp/numeric/complex
   OMXResult r =
       omxSP_FFTFwd_RToCCS_F32(src, reinterpret_cast<OMX_F32*>(dest), omx_spec_);
-  CHECK_EQ(r, OMX_Sts_NoErr);
+  RTC_CHECK_EQ(r, OMX_Sts_NoErr);
 }
 
 void RealFourierOpenmax::Inverse(const complex<float>* src, float* dest) const {
   OMXResult r =
       omxSP_FFTInv_CCSToR_F32(reinterpret_cast<const OMX_F32*>(src), dest,
                               omx_spec_);
-  CHECK_EQ(r, OMX_Sts_NoErr);
+  RTC_CHECK_EQ(r, OMX_Sts_NoErr);
 }
 
 }  // namespace webrtc
diff --git a/webrtc/common_audio/resampler/push_sinc_resampler.cc b/webrtc/common_audio/resampler/push_sinc_resampler.cc
index 72ed56b..a740423 100644
--- a/webrtc/common_audio/resampler/push_sinc_resampler.cc
+++ b/webrtc/common_audio/resampler/push_sinc_resampler.cc
@@ -50,8 +50,8 @@
                                    size_t source_length,
                                    float* destination,
                                    size_t destination_capacity) {
-  CHECK_EQ(source_length, resampler_->request_frames());
-  CHECK_GE(destination_capacity, destination_frames_);
+  RTC_CHECK_EQ(source_length, resampler_->request_frames());
+  RTC_CHECK_GE(destination_capacity, destination_frames_);
   // Cache the source pointer. Calling Resample() will immediately trigger
   // the Run() callback whereupon we provide the cached value.
   source_ptr_ = source;
@@ -81,7 +81,7 @@
 void PushSincResampler::Run(size_t frames, float* destination) {
   // Ensure we are only asked for the available samples. This would fail if
   // Run() was triggered more than once per Resample() call.
-  CHECK_EQ(source_available_, frames);
+  RTC_CHECK_EQ(source_available_, frames);
 
   if (first_pass_) {
     // Provide dummy input on the first pass, the output of which will be
diff --git a/webrtc/common_audio/resampler/sinc_resampler_unittest.cc b/webrtc/common_audio/resampler/sinc_resampler_unittest.cc
index 8bdcb25..206a174 100644
--- a/webrtc/common_audio/resampler/sinc_resampler_unittest.cc
+++ b/webrtc/common_audio/resampler/sinc_resampler_unittest.cc
@@ -163,8 +163,8 @@
 #endif
 
 // Benchmark for the various Convolve() methods.  Make sure to build with
-// branding=Chrome so that DCHECKs are compiled out when benchmarking.  Original
-// benchmarks were run with --convolve-iterations=50000000.
+// branding=Chrome so that RTC_DCHECKs are compiled out when benchmarking.
+// Original benchmarks were run with --convolve-iterations=50000000.
 TEST(SincResamplerTest, ConvolveBenchmark) {
   // Initialize a dummy resampler.
   MockSource mock_source;
diff --git a/webrtc/common_audio/sparse_fir_filter.cc b/webrtc/common_audio/sparse_fir_filter.cc
index 28bc013..5862b7c 100644
--- a/webrtc/common_audio/sparse_fir_filter.cc
+++ b/webrtc/common_audio/sparse_fir_filter.cc
@@ -22,8 +22,8 @@
       offset_(offset),
       nonzero_coeffs_(nonzero_coeffs, nonzero_coeffs + num_nonzero_coeffs),
       state_(sparsity_ * (num_nonzero_coeffs - 1) + offset_, 0.f) {
-  CHECK_GE(num_nonzero_coeffs, 1u);
-  CHECK_GE(sparsity, 1u);
+  RTC_CHECK_GE(num_nonzero_coeffs, 1u);
+  RTC_CHECK_GE(sparsity, 1u);
 }
 
 void SparseFIRFilter::Filter(const float* in, size_t length, float* out) {
diff --git a/webrtc/common_audio/vad/vad.cc b/webrtc/common_audio/vad/vad.cc
index 8973a68..95a162f 100644
--- a/webrtc/common_audio/vad/vad.cc
+++ b/webrtc/common_audio/vad/vad.cc
@@ -35,7 +35,7 @@
       case 1:
         return kActive;
       default:
-        DCHECK(false) << "WebRtcVad_Process returned an error.";
+        RTC_DCHECK(false) << "WebRtcVad_Process returned an error.";
         return kError;
     }
   }
@@ -44,9 +44,9 @@
     if (handle_)
       WebRtcVad_Free(handle_);
     handle_ = WebRtcVad_Create();
-    CHECK(handle_);
-    CHECK_EQ(WebRtcVad_Init(handle_), 0);
-    CHECK_EQ(WebRtcVad_set_mode(handle_, aggressiveness_), 0);
+    RTC_CHECK(handle_);
+    RTC_CHECK_EQ(WebRtcVad_Init(handle_), 0);
+    RTC_CHECK_EQ(WebRtcVad_set_mode(handle_, aggressiveness_), 0);
   }
 
  private:
diff --git a/webrtc/common_audio/vad/vad_unittest.cc b/webrtc/common_audio/vad/vad_unittest.cc
index ecc4734..a0e16b1 100644
--- a/webrtc/common_audio/vad/vad_unittest.cc
+++ b/webrtc/common_audio/vad/vad_unittest.cc
@@ -76,7 +76,7 @@
             WebRtcVad_Process(nullptr, kRates[0], speech, kFrameLengths[0]));
 
   // WebRtcVad_Create()
-  CHECK(handle);
+  RTC_CHECK(handle);
 
   // Not initialized tests
   EXPECT_EQ(-1, WebRtcVad_Process(handle, kRates[0], speech, kFrameLengths[0]));
diff --git a/webrtc/common_audio/wav_file.cc b/webrtc/common_audio/wav_file.cc
index a0c792c..8dae7d6 100644
--- a/webrtc/common_audio/wav_file.cc
+++ b/webrtc/common_audio/wav_file.cc
@@ -39,16 +39,16 @@
 
 WavReader::WavReader(const std::string& filename)
     : file_handle_(fopen(filename.c_str(), "rb")) {
-  CHECK(file_handle_ && "Could not open wav file for reading.");
+  RTC_CHECK(file_handle_ && "Could not open wav file for reading.");
 
   ReadableWavFile readable(file_handle_);
   WavFormat format;
   int bytes_per_sample;
-  CHECK(ReadWavHeader(&readable, &num_channels_, &sample_rate_, &format,
-                      &bytes_per_sample, &num_samples_));
+  RTC_CHECK(ReadWavHeader(&readable, &num_channels_, &sample_rate_, &format,
+                          &bytes_per_sample, &num_samples_));
   num_samples_remaining_ = num_samples_;
-  CHECK_EQ(kWavFormat, format);
-  CHECK_EQ(kBytesPerSample, bytes_per_sample);
+  RTC_CHECK_EQ(kWavFormat, format);
+  RTC_CHECK_EQ(kBytesPerSample, bytes_per_sample);
 }
 
 WavReader::~WavReader() {
@@ -65,8 +65,8 @@
   const size_t read =
       fread(samples, sizeof(*samples), num_samples, file_handle_);
   // If we didn't read what was requested, ensure we've reached the EOF.
-  CHECK(read == num_samples || feof(file_handle_));
-  CHECK_LE(read, num_samples_remaining_);
+  RTC_CHECK(read == num_samples || feof(file_handle_));
+  RTC_CHECK_LE(read, num_samples_remaining_);
   num_samples_remaining_ -= rtc::checked_cast<uint32_t>(read);
   return read;
 }
@@ -86,7 +86,7 @@
 }
 
 void WavReader::Close() {
-  CHECK_EQ(0, fclose(file_handle_));
+  RTC_CHECK_EQ(0, fclose(file_handle_));
   file_handle_ = NULL;
 }
 
@@ -96,17 +96,14 @@
       num_channels_(num_channels),
       num_samples_(0),
       file_handle_(fopen(filename.c_str(), "wb")) {
-  CHECK(file_handle_ && "Could not open wav file for writing.");
-  CHECK(CheckWavParameters(num_channels_,
-                           sample_rate_,
-                           kWavFormat,
-                           kBytesPerSample,
-                           num_samples_));
+  RTC_CHECK(file_handle_ && "Could not open wav file for writing.");
+  RTC_CHECK(CheckWavParameters(num_channels_, sample_rate_, kWavFormat,
+                               kBytesPerSample, num_samples_));
 
   // Write a blank placeholder header, since we need to know the total number
   // of samples before we can fill in the real data.
   static const uint8_t blank_header[kWavHeaderSize] = {0};
-  CHECK_EQ(1u, fwrite(blank_header, kWavHeaderSize, 1, file_handle_));
+  RTC_CHECK_EQ(1u, fwrite(blank_header, kWavHeaderSize, 1, file_handle_));
 }
 
 WavWriter::~WavWriter() {
@@ -119,10 +116,10 @@
 #endif
   const size_t written =
       fwrite(samples, sizeof(*samples), num_samples, file_handle_);
-  CHECK_EQ(num_samples, written);
+  RTC_CHECK_EQ(num_samples, written);
   num_samples_ += static_cast<uint32_t>(written);
-  CHECK(written <= std::numeric_limits<uint32_t>::max() ||
-        num_samples_ >= written);  // detect uint32_t overflow
+  RTC_CHECK(written <= std::numeric_limits<uint32_t>::max() ||
+            num_samples_ >= written);  // detect uint32_t overflow
 }
 
 void WavWriter::WriteSamples(const float* samples, size_t num_samples) {
@@ -136,12 +133,12 @@
 }
 
 void WavWriter::Close() {
-  CHECK_EQ(0, fseek(file_handle_, 0, SEEK_SET));
+  RTC_CHECK_EQ(0, fseek(file_handle_, 0, SEEK_SET));
   uint8_t header[kWavHeaderSize];
   WriteWavHeader(header, num_channels_, sample_rate_, kWavFormat,
                  kBytesPerSample, num_samples_);
-  CHECK_EQ(1u, fwrite(header, kWavHeaderSize, 1, file_handle_));
-  CHECK_EQ(0, fclose(file_handle_));
+  RTC_CHECK_EQ(1u, fwrite(header, kWavHeaderSize, 1, file_handle_));
+  RTC_CHECK_EQ(0, fclose(file_handle_));
   file_handle_ = NULL;
 }
 
diff --git a/webrtc/common_audio/wav_file.h b/webrtc/common_audio/wav_file.h
index 14a8a0e..2eadd3f 100644
--- a/webrtc/common_audio/wav_file.h
+++ b/webrtc/common_audio/wav_file.h
@@ -32,7 +32,7 @@
 };
 
 // Simple C++ class for writing 16-bit PCM WAV files. All error handling is
-// by calls to CHECK(), making it unsuitable for anything but debug code.
+// by calls to RTC_CHECK(), making it unsuitable for anything but debug code.
 class WavWriter final : public WavFile {
  public:
   // Open a new WAV file for writing.
diff --git a/webrtc/common_audio/wav_header.cc b/webrtc/common_audio/wav_header.cc
index fefbee0..61cfffe 100644
--- a/webrtc/common_audio/wav_header.cc
+++ b/webrtc/common_audio/wav_header.cc
@@ -151,8 +151,8 @@
                     WavFormat format,
                     int bytes_per_sample,
                     uint32_t num_samples) {
-  CHECK(CheckWavParameters(num_channels, sample_rate, format,
-                           bytes_per_sample, num_samples));
+  RTC_CHECK(CheckWavParameters(num_channels, sample_rate, format,
+                               bytes_per_sample, num_samples));
 
   WavHeader header;
   const uint32_t bytes_in_payload = bytes_per_sample * num_samples;
diff --git a/webrtc/common_audio/window_generator.cc b/webrtc/common_audio/window_generator.cc
index ae6cbc9..ab983b7 100644
--- a/webrtc/common_audio/window_generator.cc
+++ b/webrtc/common_audio/window_generator.cc
@@ -38,8 +38,8 @@
 namespace webrtc {
 
 void WindowGenerator::Hanning(int length, float* window) {
-  CHECK_GT(length, 1);
-  CHECK(window != nullptr);
+  RTC_CHECK_GT(length, 1);
+  RTC_CHECK(window != nullptr);
   for (int i = 0; i < length; ++i) {
     window[i] = 0.5f * (1 - cosf(2 * static_cast<float>(M_PI) * i /
                                  (length - 1)));
@@ -48,8 +48,8 @@
 
 void WindowGenerator::KaiserBesselDerived(float alpha, size_t length,
                                           float* window) {
-  CHECK_GT(length, 1U);
-  CHECK(window != nullptr);
+  RTC_CHECK_GT(length, 1U);
+  RTC_CHECK(window != nullptr);
 
   const size_t half = (length + 1) / 2;
   float sum = 0.0f;