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/talk/app/webrtc/androidvideocapturer.cc b/talk/app/webrtc/androidvideocapturer.cc
index 747dd43..0312cd3 100644
--- a/talk/app/webrtc/androidvideocapturer.cc
+++ b/talk/app/webrtc/androidvideocapturer.cc
@@ -82,7 +82,7 @@
       int dst_width,
       int dst_height) const override {
     // Check that captured_frame is actually our frame.
-    CHECK(captured_frame == &captured_frame_);
+    RTC_CHECK(captured_frame == &captured_frame_);
     rtc::scoped_ptr<cricket::VideoFrame> frame(new cricket::WebRtcVideoFrame(
         ShallowCenterCrop(buffer_, dst_width, dst_height),
         captured_frame->elapsed_time, captured_frame->time_stamp,
@@ -119,8 +119,9 @@
   std::vector<cricket::VideoFormat> formats;
   for (Json::ArrayIndex i = 0; i < json_values.size(); ++i) {
       const Json::Value& json_value = json_values[i];
-      CHECK(!json_value["width"].isNull() && !json_value["height"].isNull() &&
-             !json_value["framerate"].isNull());
+      RTC_CHECK(!json_value["width"].isNull() &&
+                !json_value["height"].isNull() &&
+                !json_value["framerate"].isNull());
       cricket::VideoFormat format(
           json_value["width"].asInt(),
           json_value["height"].asInt(),
@@ -134,13 +135,13 @@
 }
 
 AndroidVideoCapturer::~AndroidVideoCapturer() {
-  CHECK(!running_);
+  RTC_CHECK(!running_);
 }
 
 cricket::CaptureState AndroidVideoCapturer::Start(
     const cricket::VideoFormat& capture_format) {
-  CHECK(thread_checker_.CalledOnValidThread());
-  CHECK(!running_);
+  RTC_CHECK(thread_checker_.CalledOnValidThread());
+  RTC_CHECK(!running_);
   const int fps = cricket::VideoFormat::IntervalToFps(capture_format.interval);
   LOG(LS_INFO) << " AndroidVideoCapturer::Start " << capture_format.width << "x"
                << capture_format.height << "@" << fps;
@@ -157,8 +158,8 @@
 
 void AndroidVideoCapturer::Stop() {
   LOG(LS_INFO) << " AndroidVideoCapturer::Stop ";
-  CHECK(thread_checker_.CalledOnValidThread());
-  CHECK(running_);
+  RTC_CHECK(thread_checker_.CalledOnValidThread());
+  RTC_CHECK(running_);
   running_ = false;
   SetCaptureFormat(NULL);
 
@@ -168,18 +169,18 @@
 }
 
 bool AndroidVideoCapturer::IsRunning() {
-  CHECK(thread_checker_.CalledOnValidThread());
+  RTC_CHECK(thread_checker_.CalledOnValidThread());
   return running_;
 }
 
 bool AndroidVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) {
-  CHECK(thread_checker_.CalledOnValidThread());
+  RTC_CHECK(thread_checker_.CalledOnValidThread());
   fourccs->push_back(cricket::FOURCC_YV12);
   return true;
 }
 
 void AndroidVideoCapturer::OnCapturerStarted(bool success) {
-  CHECK(thread_checker_.CalledOnValidThread());
+  RTC_CHECK(thread_checker_.CalledOnValidThread());
   cricket::CaptureState new_state =
       success ? cricket::CS_RUNNING : cricket::CS_FAILED;
   if (new_state == current_state_)
@@ -196,7 +197,7 @@
     rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer,
     int rotation,
     int64 time_stamp) {
-  CHECK(thread_checker_.CalledOnValidThread());
+  RTC_CHECK(thread_checker_.CalledOnValidThread());
   frame_factory_->UpdateCapturedFrame(buffer, rotation, time_stamp);
   SignalFrameCaptured(this, frame_factory_->GetCapturedFrame());
   frame_factory_->ClearCapturedFrame();
@@ -204,7 +205,7 @@
 
 void AndroidVideoCapturer::OnOutputFormatRequest(
     int width, int height, int fps) {
-  CHECK(thread_checker_.CalledOnValidThread());
+  RTC_CHECK(thread_checker_.CalledOnValidThread());
   const cricket::VideoFormat& current = video_adapter()->output_format();
   cricket::VideoFormat format(
       width, height, cricket::VideoFormat::FpsToInterval(fps), current.fourcc);
diff --git a/talk/app/webrtc/datachannelinterface.h b/talk/app/webrtc/datachannelinterface.h
index 90573eb..9d2cd44 100644
--- a/talk/app/webrtc/datachannelinterface.h
+++ b/talk/app/webrtc/datachannelinterface.h
@@ -120,7 +120,7 @@
       case kClosed:
         return "closed";
     }
-    CHECK(false) << "Unknown DataChannel state: " << state;
+    RTC_CHECK(false) << "Unknown DataChannel state: " << state;
     return "";
   }
 
diff --git a/talk/app/webrtc/dtlsidentitystore.cc b/talk/app/webrtc/dtlsidentitystore.cc
index fa330af..2758779 100644
--- a/talk/app/webrtc/dtlsidentitystore.cc
+++ b/talk/app/webrtc/dtlsidentitystore.cc
@@ -61,7 +61,7 @@
     store_->SignalDestroyed.connect(this, &WorkerTask::OnStoreDestroyed);
   }
 
-  virtual ~WorkerTask() { DCHECK(signaling_thread_->IsCurrent()); }
+  virtual ~WorkerTask() { RTC_DCHECK(signaling_thread_->IsCurrent()); }
 
  private:
   void GenerateIdentity_w() {
@@ -87,7 +87,7 @@
         signaling_thread_->Post(this, MSG_DESTROY, msg->pdata);
         break;
       case MSG_GENERATE_IDENTITY_RESULT:
-        DCHECK(signaling_thread_->IsCurrent());
+        RTC_DCHECK(signaling_thread_->IsCurrent());
         {
           rtc::scoped_ptr<IdentityResultMessageData> pdata(
               static_cast<IdentityResultMessageData*>(msg->pdata));
@@ -98,17 +98,17 @@
         }
         break;
       case MSG_DESTROY:
-        DCHECK(signaling_thread_->IsCurrent());
+        RTC_DCHECK(signaling_thread_->IsCurrent());
         delete msg->pdata;
         // |this| has now been deleted. Don't touch member variables.
         break;
       default:
-        CHECK(false) << "Unexpected message type";
+        RTC_CHECK(false) << "Unexpected message type";
     }
   }
 
   void OnStoreDestroyed() {
-    DCHECK(signaling_thread_->IsCurrent());
+    RTC_DCHECK(signaling_thread_->IsCurrent());
     store_ = nullptr;
   }
 
@@ -122,7 +122,7 @@
     : signaling_thread_(signaling_thread),
       worker_thread_(worker_thread),
       request_info_() {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   // Preemptively generate identities unless the worker thread and signaling
   // thread are the same (only do preemptive work in the background).
   if (worker_thread_ != signaling_thread_) {
@@ -132,21 +132,21 @@
 }
 
 DtlsIdentityStoreImpl::~DtlsIdentityStoreImpl() {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   SignalDestroyed();
 }
 
 void DtlsIdentityStoreImpl::RequestIdentity(
     rtc::KeyType key_type,
     const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& observer) {
-  DCHECK(signaling_thread_->IsCurrent());
-  DCHECK(observer);
+  RTC_DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(observer);
 
   GenerateIdentity(key_type, observer);
 }
 
 void DtlsIdentityStoreImpl::OnMessage(rtc::Message* msg) {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   switch (msg->message_id) {
     case MSG_GENERATE_IDENTITY_RESULT: {
       rtc::scoped_ptr<IdentityResultMessageData> pdata(
@@ -160,14 +160,14 @@
 
 bool DtlsIdentityStoreImpl::HasFreeIdentityForTesting(
     rtc::KeyType key_type) const {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   return request_info_[key_type].free_identity_.get() != nullptr;
 }
 
 void DtlsIdentityStoreImpl::GenerateIdentity(
     rtc::KeyType key_type,
     const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& observer) {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
 
   // Enqueue observer to be informed when generation of |key_type| is completed.
   if (observer.get()) {
@@ -205,9 +205,9 @@
 
 void DtlsIdentityStoreImpl::OnIdentityGenerated(
     rtc::KeyType key_type, rtc::scoped_ptr<rtc::SSLIdentity> identity) {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
 
-  DCHECK(request_info_[key_type].gen_in_progress_counts_);
+  RTC_DCHECK(request_info_[key_type].gen_in_progress_counts_);
   --request_info_[key_type].gen_in_progress_counts_;
 
   rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver> observer;
@@ -218,7 +218,7 @@
 
   if (observer.get() == nullptr) {
     // No observer - store result in |free_identities_|.
-    DCHECK(!request_info_[key_type].free_identity_.get());
+    RTC_DCHECK(!request_info_[key_type].free_identity_.get());
     request_info_[key_type].free_identity_.swap(identity);
     if (request_info_[key_type].free_identity_.get())
       LOG(LS_VERBOSE) << "A free DTLS identity was saved.";
diff --git a/talk/app/webrtc/dtlsidentitystore_unittest.cc b/talk/app/webrtc/dtlsidentitystore_unittest.cc
index 3e21a47..e924221 100644
--- a/talk/app/webrtc/dtlsidentitystore_unittest.cc
+++ b/talk/app/webrtc/dtlsidentitystore_unittest.cc
@@ -83,7 +83,7 @@
                                          worker_thread_.get())),
         observer_(
             new rtc::RefCountedObject<MockDtlsIdentityRequestObserver>()) {
-    CHECK(worker_thread_->Start());
+    RTC_CHECK(worker_thread_->Start());
   }
   ~DtlsIdentityStoreTest() {}
 
diff --git a/talk/app/webrtc/fakemetricsobserver.cc b/talk/app/webrtc/fakemetricsobserver.cc
index c275311..9c300cc 100644
--- a/talk/app/webrtc/fakemetricsobserver.cc
+++ b/talk/app/webrtc/fakemetricsobserver.cc
@@ -35,7 +35,7 @@
 }
 
 void FakeMetricsObserver::Reset() {
-  DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
   counters_.clear();
   memset(int_histogram_samples_, 0, sizeof(int_histogram_samples_));
   for (std::string& type : string_histogram_samples_) {
@@ -47,7 +47,7 @@
     PeerConnectionEnumCounterType type,
     int counter,
     int counter_max) {
-  DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
   if (counters_.size() <= static_cast<size_t>(type)) {
     counters_.resize(type + 1);
   }
@@ -60,34 +60,34 @@
 
 void FakeMetricsObserver::AddHistogramSample(PeerConnectionMetricsName type,
     int value) {
-  DCHECK(thread_checker_.CalledOnValidThread());
-  DCHECK_EQ(int_histogram_samples_[type], 0);
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK_EQ(int_histogram_samples_[type], 0);
   int_histogram_samples_[type] = value;
 }
 
 void FakeMetricsObserver::AddHistogramSample(PeerConnectionMetricsName type,
     const std::string& value) {
-  DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
   string_histogram_samples_[type].assign(value);
 }
 
 int FakeMetricsObserver::GetEnumCounter(PeerConnectionEnumCounterType type,
                                         int counter) const {
-  DCHECK(thread_checker_.CalledOnValidThread());
-  CHECK(counters_.size() > static_cast<size_t>(type) &&
-        counters_[type].size() > static_cast<size_t>(counter));
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_CHECK(counters_.size() > static_cast<size_t>(type) &&
+            counters_[type].size() > static_cast<size_t>(counter));
   return counters_[type][counter];
 }
 
 int FakeMetricsObserver::GetIntHistogramSample(
     PeerConnectionMetricsName type) const {
-  DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
   return int_histogram_samples_[type];
 }
 
 const std::string& FakeMetricsObserver::GetStringHistogramSample(
     PeerConnectionMetricsName type) const {
-  DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
   return string_histogram_samples_[type];
 }
 
diff --git a/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc b/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
index a6f7da3..a67dd50 100644
--- a/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
+++ b/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
@@ -183,7 +183,7 @@
                               "()V"))) {
   ScopedLocalRefFrame local_ref_frame(jni);
   codec_thread_->SetName("MediaCodecVideoDecoder", NULL);
-  CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoDecoder";
+  RTC_CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoDecoder";
 
   j_init_decode_method_ = GetMethodID(
       jni, *j_media_codec_video_decoder_class_, "initDecode",
@@ -262,8 +262,8 @@
     return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
   }
   // Factory should guard against other codecs being used with us.
-  CHECK(inst->codecType == codecType_) << "Unsupported codec " <<
-      inst->codecType << " for " << codecType_;
+  RTC_CHECK(inst->codecType == codecType_)
+      << "Unsupported codec " << inst->codecType << " for " << codecType_;
 
   if (sw_fallback_required_) {
     ALOGE("InitDecode() - fallback to SW decoder");
@@ -394,7 +394,7 @@
 }
 
 void MediaCodecVideoDecoder::CheckOnCodecThread() {
-  CHECK(codec_thread_ == ThreadManager::Instance()->CurrentThread())
+  RTC_CHECK(codec_thread_ == ThreadManager::Instance()->CurrentThread())
       << "Running on wrong thread!";
 }
 
@@ -514,7 +514,7 @@
   jobject j_input_buffer = input_buffers_[j_input_buffer_index];
   uint8* buffer =
       reinterpret_cast<uint8*>(jni->GetDirectBufferAddress(j_input_buffer));
-  CHECK(buffer) << "Indirect buffer??";
+  RTC_CHECK(buffer) << "Indirect buffer??";
   int64 buffer_capacity = jni->GetDirectBufferCapacity(j_input_buffer);
   if (CheckException(jni) || buffer_capacity < inputImage._length) {
     ALOGE("Input frame size %d is bigger than buffer size %d.",
@@ -731,8 +731,8 @@
   }
   // We only ever send one message to |this| directly (not through a Bind()'d
   // functor), so expect no ID/data.
-  CHECK(!msg->message_id) << "Unexpected message!";
-  CHECK(!msg->pdata) << "Unexpected message!";
+  RTC_CHECK(!msg->message_id) << "Unexpected message!";
+  RTC_CHECK(!msg->pdata) << "Unexpected message!";
   CheckOnCodecThread();
 
   if (!DeliverPendingOutputs(jni, 0)) {
diff --git a/talk/app/webrtc/java/jni/androidmediaencoder_jni.cc b/talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
index 8c00bc3..bd94562 100644
--- a/talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
+++ b/talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
@@ -236,7 +236,7 @@
   // in the bug, we have a problem.  For now work around that with a dedicated
   // thread.
   codec_thread_->SetName("MediaCodecVideoEncoder", NULL);
-  CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoEncoder";
+  RTC_CHECK(codec_thread_->Start()) << "Failed to start MediaCodecVideoEncoder";
 
   jclass j_output_buffer_info_class =
       FindClass(jni, "org/webrtc/MediaCodecVideoEncoder$OutputBufferInfo");
@@ -292,8 +292,9 @@
     return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
   }
   // Factory should guard against other codecs being used with us.
-  CHECK(codec_settings->codecType == codecType_) << "Unsupported codec " <<
-      codec_settings->codecType << " for " << codecType_;
+  RTC_CHECK(codec_settings->codecType == codecType_)
+      << "Unsupported codec " << codec_settings->codecType << " for "
+      << codecType_;
 
   ALOGD("InitEncode request");
   scale_ = false;
@@ -359,8 +360,8 @@
 
   // We only ever send one message to |this| directly (not through a Bind()'d
   // functor), so expect no ID/data.
-  CHECK(!msg->message_id) << "Unexpected message!";
-  CHECK(!msg->pdata) << "Unexpected message!";
+  RTC_CHECK(!msg->message_id) << "Unexpected message!";
+  RTC_CHECK(!msg->pdata) << "Unexpected message!";
   CheckOnCodecThread();
   if (!inited_) {
     return;
@@ -374,7 +375,7 @@
 }
 
 void MediaCodecVideoEncoder::CheckOnCodecThread() {
-  CHECK(codec_thread_ == ThreadManager::Instance()->CurrentThread())
+  RTC_CHECK(codec_thread_ == ThreadManager::Instance()->CurrentThread())
       << "Running on wrong thread!";
 }
 
@@ -460,7 +461,7 @@
       return WEBRTC_VIDEO_CODEC_ERROR;
   }
   size_t num_input_buffers = jni->GetArrayLength(input_buffers);
-  CHECK(input_buffers_.empty())
+  RTC_CHECK(input_buffers_.empty())
       << "Unexpected double InitEncode without Release";
   input_buffers_.resize(num_input_buffers);
   for (size_t i = 0; i < num_input_buffers; ++i) {
@@ -469,7 +470,7 @@
     int64 yuv_buffer_capacity =
         jni->GetDirectBufferCapacity(input_buffers_[i]);
     CHECK_EXCEPTION(jni);
-    CHECK(yuv_buffer_capacity >= yuv_size_) << "Insufficient capacity";
+    RTC_CHECK(yuv_buffer_capacity >= yuv_size_) << "Insufficient capacity";
   }
   CHECK_EXCEPTION(jni);
 
@@ -499,7 +500,7 @@
     return WEBRTC_VIDEO_CODEC_OK;
   }
 
-  CHECK(frame_types->size() == 1) << "Unexpected stream count";
+  RTC_CHECK(frame_types->size() == 1) << "Unexpected stream count";
   // Check framerate before spatial resolution change.
   if (scale_ && codecType_ == kVideoCodecVP8) {
     quality_scaler_->OnEncodeFrame(frame);
@@ -555,17 +556,12 @@
   uint8* yuv_buffer =
       reinterpret_cast<uint8*>(jni->GetDirectBufferAddress(j_input_buffer));
   CHECK_EXCEPTION(jni);
-  CHECK(yuv_buffer) << "Indirect buffer??";
-  CHECK(!libyuv::ConvertFromI420(
-          input_frame.buffer(webrtc::kYPlane),
-          input_frame.stride(webrtc::kYPlane),
-          input_frame.buffer(webrtc::kUPlane),
-          input_frame.stride(webrtc::kUPlane),
-          input_frame.buffer(webrtc::kVPlane),
-          input_frame.stride(webrtc::kVPlane),
-          yuv_buffer, width_,
-          width_, height_,
-          encoder_fourcc_))
+  RTC_CHECK(yuv_buffer) << "Indirect buffer??";
+  RTC_CHECK(!libyuv::ConvertFromI420(
+      input_frame.buffer(webrtc::kYPlane), input_frame.stride(webrtc::kYPlane),
+      input_frame.buffer(webrtc::kUPlane), input_frame.stride(webrtc::kUPlane),
+      input_frame.buffer(webrtc::kVPlane), input_frame.stride(webrtc::kVPlane),
+      yuv_buffer, width_, width_, height_, encoder_fourcc_))
       << "ConvertFromI420 failed";
   last_input_timestamp_ms_ = current_timestamp_us_ / 1000;
   frames_in_queue_++;
diff --git a/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc b/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc
index 43a60c3..69c350a 100644
--- a/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc
+++ b/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc
@@ -93,11 +93,11 @@
 void AndroidVideoCapturerJni::Start(int width, int height, int framerate,
                                     webrtc::AndroidVideoCapturer* capturer) {
   LOG(LS_INFO) << "AndroidVideoCapturerJni start";
-  DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
   {
     rtc::CritScope cs(&capturer_lock_);
-    CHECK(capturer_ == nullptr);
-    CHECK(invoker_.get() == nullptr);
+    RTC_CHECK(capturer_ == nullptr);
+    RTC_CHECK(invoker_.get() == nullptr);
     capturer_ = capturer;
     invoker_.reset(new rtc::GuardedAsyncInvoker());
   }
@@ -121,7 +121,7 @@
 
 void AndroidVideoCapturerJni::Stop() {
   LOG(LS_INFO) << "AndroidVideoCapturerJni stop";
-  DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
   {
     rtc::CritScope cs(&capturer_lock_);
     // Destroying |invoker_| will cancel all pending calls to |capturer_|.
@@ -220,7 +220,8 @@
   // that the memory is valid when we have released |j_frame|.
   // TODO(magjed): Move ReleaseByteArrayElements() into ReturnBuffer() and
   // remove this check.
-  CHECK(!is_copy) << "NativeObserver_nativeOnFrameCaptured: frame is a copy";
+  RTC_CHECK(!is_copy)
+      << "NativeObserver_nativeOnFrameCaptured: frame is a copy";
   reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)
       ->OnIncomingFrame(bytes, length, width, height, rotation, ts);
   jni->ReleaseByteArrayElements(j_frame, bytes, JNI_ABORT);
diff --git a/talk/app/webrtc/java/jni/classreferenceholder.cc b/talk/app/webrtc/java/jni/classreferenceholder.cc
index fd37838..0ac7e5e 100644
--- a/talk/app/webrtc/java/jni/classreferenceholder.cc
+++ b/talk/app/webrtc/java/jni/classreferenceholder.cc
@@ -51,7 +51,7 @@
 static ClassReferenceHolder* g_class_reference_holder = nullptr;
 
 void LoadGlobalClassReferenceHolder() {
-  CHECK(g_class_reference_holder == nullptr);
+  RTC_CHECK(g_class_reference_holder == nullptr);
   g_class_reference_holder = new ClassReferenceHolder(GetEnv());
 }
 
@@ -114,7 +114,7 @@
 }
 
 ClassReferenceHolder::~ClassReferenceHolder() {
-  CHECK(classes_.empty()) << "Must call FreeReferences() before dtor!";
+  RTC_CHECK(classes_.empty()) << "Must call FreeReferences() before dtor!";
 }
 
 void ClassReferenceHolder::FreeReferences(JNIEnv* jni) {
@@ -127,19 +127,19 @@
 
 jclass ClassReferenceHolder::GetClass(const std::string& name) {
   std::map<std::string, jclass>::iterator it = classes_.find(name);
-  CHECK(it != classes_.end()) << "Unexpected GetClass() call for: " << name;
+  RTC_CHECK(it != classes_.end()) << "Unexpected GetClass() call for: " << name;
   return it->second;
 }
 
 void ClassReferenceHolder::LoadClass(JNIEnv* jni, const std::string& name) {
   jclass localRef = jni->FindClass(name.c_str());
   CHECK_EXCEPTION(jni) << "error during FindClass: " << name;
-  CHECK(localRef) << name;
+  RTC_CHECK(localRef) << name;
   jclass globalRef = reinterpret_cast<jclass>(jni->NewGlobalRef(localRef));
   CHECK_EXCEPTION(jni) << "error during NewGlobalRef: " << name;
-  CHECK(globalRef) << name;
+  RTC_CHECK(globalRef) << name;
   bool inserted = classes_.insert(std::make_pair(name, globalRef)).second;
-  CHECK(inserted) << "Duplicate class name: " << name;
+  RTC_CHECK(inserted) << "Duplicate class name: " << name;
 }
 
 // Returns a global reference guaranteed to be valid for the lifetime of the
diff --git a/talk/app/webrtc/java/jni/jni_helpers.cc b/talk/app/webrtc/java/jni/jni_helpers.cc
index ecad5df..755698e 100644
--- a/talk/app/webrtc/java/jni/jni_helpers.cc
+++ b/talk/app/webrtc/java/jni/jni_helpers.cc
@@ -49,7 +49,7 @@
 using icu::UnicodeString;
 
 JavaVM *GetJVM() {
-  CHECK(g_jvm) << "JNI_OnLoad failed to run?";
+  RTC_CHECK(g_jvm) << "JNI_OnLoad failed to run?";
   return g_jvm;
 }
 
@@ -57,8 +57,8 @@
 JNIEnv* GetEnv() {
   void* env = NULL;
   jint status = g_jvm->GetEnv(&env, JNI_VERSION_1_6);
-  CHECK(((env != NULL) && (status == JNI_OK)) ||
-        ((env == NULL) && (status == JNI_EDETACHED)))
+  RTC_CHECK(((env != NULL) && (status == JNI_OK)) ||
+            ((env == NULL) && (status == JNI_EDETACHED)))
       << "Unexpected GetEnv return: " << status << ":" << env;
   return reinterpret_cast<JNIEnv*>(env);
 }
@@ -74,24 +74,24 @@
   if (!GetEnv())
     return;
 
-  CHECK(GetEnv() == prev_jni_ptr)
+  RTC_CHECK(GetEnv() == prev_jni_ptr)
       << "Detaching from another thread: " << prev_jni_ptr << ":" << GetEnv();
   jint status = g_jvm->DetachCurrentThread();
-  CHECK(status == JNI_OK) << "Failed to detach thread: " << status;
-  CHECK(!GetEnv()) << "Detaching was a successful no-op???";
+  RTC_CHECK(status == JNI_OK) << "Failed to detach thread: " << status;
+  RTC_CHECK(!GetEnv()) << "Detaching was a successful no-op???";
 }
 
 static void CreateJNIPtrKey() {
-  CHECK(!pthread_key_create(&g_jni_ptr, &ThreadDestructor))
+  RTC_CHECK(!pthread_key_create(&g_jni_ptr, &ThreadDestructor))
       << "pthread_key_create";
 }
 
 jint InitGlobalJniVariables(JavaVM *jvm) {
-  CHECK(!g_jvm) << "InitGlobalJniVariables!";
+  RTC_CHECK(!g_jvm) << "InitGlobalJniVariables!";
   g_jvm = jvm;
-  CHECK(g_jvm) << "InitGlobalJniVariables handed NULL?";
+  RTC_CHECK(g_jvm) << "InitGlobalJniVariables handed NULL?";
 
-  CHECK(!pthread_once(&g_jni_ptr_once, &CreateJNIPtrKey)) << "pthread_once";
+  RTC_CHECK(!pthread_once(&g_jni_ptr_once, &CreateJNIPtrKey)) << "pthread_once";
 
   JNIEnv* jni = nullptr;
   if (jvm->GetEnv(reinterpret_cast<void**>(&jni), JNI_VERSION_1_6) != JNI_OK)
@@ -103,9 +103,9 @@
 // Return thread ID as a string.
 static std::string GetThreadId() {
   char buf[21];  // Big enough to hold a kuint64max plus terminating NULL.
-  CHECK_LT(snprintf(buf, sizeof(buf), "%ld",
-           static_cast<long>(syscall(__NR_gettid))),
-           sizeof(buf))
+  RTC_CHECK_LT(snprintf(buf, sizeof(buf), "%ld",
+                        static_cast<long>(syscall(__NR_gettid))),
+               sizeof(buf))
       << "Thread id is bigger than uint64??";
   return std::string(buf);
 }
@@ -123,7 +123,7 @@
   JNIEnv* jni = GetEnv();
   if (jni)
     return jni;
-  CHECK(!pthread_getspecific(g_jni_ptr))
+  RTC_CHECK(!pthread_getspecific(g_jni_ptr))
       << "TLS has a JNIEnv* but not attached?";
 
   std::string name(GetThreadName() + " - " + GetThreadId());
@@ -137,10 +137,11 @@
 #else
   JNIEnv* env = NULL;
 #endif
-  CHECK(!g_jvm->AttachCurrentThread(&env, &args)) << "Failed to attach thread";
-  CHECK(env) << "AttachCurrentThread handed back NULL!";
+  RTC_CHECK(!g_jvm->AttachCurrentThread(&env, &args))
+      << "Failed to attach thread";
+  RTC_CHECK(env) << "AttachCurrentThread handed back NULL!";
   jni = reinterpret_cast<JNIEnv*>(env);
-  CHECK(!pthread_setspecific(g_jni_ptr, jni)) << "pthread_setspecific";
+  RTC_CHECK(!pthread_setspecific(g_jni_ptr, jni)) << "pthread_setspecific";
   return jni;
 }
 
@@ -154,18 +155,18 @@
   // conversion from pointer to integral type.  intptr_t to jlong is a standard
   // widening by the static_assert above.
   jlong ret = reinterpret_cast<intptr_t>(ptr);
-  DCHECK(reinterpret_cast<void*>(ret) == ptr);
+  RTC_DCHECK(reinterpret_cast<void*>(ret) == ptr);
   return ret;
 }
 
-// JNIEnv-helper methods that CHECK success: no Java exception thrown and found
-// object/class/method/field is non-null.
+// JNIEnv-helper methods that RTC_CHECK success: no Java exception thrown and
+// found object/class/method/field is non-null.
 jmethodID GetMethodID(
     JNIEnv* jni, jclass c, const std::string& name, const char* signature) {
   jmethodID m = jni->GetMethodID(c, name.c_str(), signature);
   CHECK_EXCEPTION(jni) << "error during GetMethodID: " << name << ", "
                        << signature;
-  CHECK(m) << name << ", " << signature;
+  RTC_CHECK(m) << name << ", " << signature;
   return m;
 }
 
@@ -174,7 +175,7 @@
   jmethodID m = jni->GetStaticMethodID(c, name, signature);
   CHECK_EXCEPTION(jni) << "error during GetStaticMethodID: " << name << ", "
                        << signature;
-  CHECK(m) << name << ", " << signature;
+  RTC_CHECK(m) << name << ", " << signature;
   return m;
 }
 
@@ -182,21 +183,21 @@
     JNIEnv* jni, jclass c, const char* name, const char* signature) {
   jfieldID f = jni->GetFieldID(c, name, signature);
   CHECK_EXCEPTION(jni) << "error during GetFieldID";
-  CHECK(f) << name << ", " << signature;
+  RTC_CHECK(f) << name << ", " << signature;
   return f;
 }
 
 jclass GetObjectClass(JNIEnv* jni, jobject object) {
   jclass c = jni->GetObjectClass(object);
   CHECK_EXCEPTION(jni) << "error during GetObjectClass";
-  CHECK(c) << "GetObjectClass returned NULL";
+  RTC_CHECK(c) << "GetObjectClass returned NULL";
   return c;
 }
 
 jobject GetObjectField(JNIEnv* jni, jobject object, jfieldID id) {
   jobject o = jni->GetObjectField(object, id);
   CHECK_EXCEPTION(jni) << "error during GetObjectField";
-  CHECK(o) << "GetObjectField returned NULL";
+  RTC_CHECK(o) << "GetObjectField returned NULL";
   return o;
 }
 
@@ -265,7 +266,7 @@
 jobject NewGlobalRef(JNIEnv* jni, jobject o) {
   jobject ret = jni->NewGlobalRef(o);
   CHECK_EXCEPTION(jni) << "error during NewGlobalRef";
-  CHECK(ret);
+  RTC_CHECK(ret);
   return ret;
 }
 
@@ -278,7 +279,7 @@
 // callbacks (i.e. entry points that don't originate in a Java callstack
 // through a "native" method call).
 ScopedLocalRefFrame::ScopedLocalRefFrame(JNIEnv* jni) : jni_(jni) {
-  CHECK(!jni_->PushLocalFrame(0)) << "Failed to PushLocalFrame";
+  RTC_CHECK(!jni_->PushLocalFrame(0)) << "Failed to PushLocalFrame";
 }
 ScopedLocalRefFrame::~ScopedLocalRefFrame() {
   jni_->PopLocalFrame(NULL);
diff --git a/talk/app/webrtc/java/jni/jni_helpers.h b/talk/app/webrtc/java/jni/jni_helpers.h
index dde7137..7072ee8 100644
--- a/talk/app/webrtc/java/jni/jni_helpers.h
+++ b/talk/app/webrtc/java/jni/jni_helpers.h
@@ -41,14 +41,14 @@
 // This macros uses the comma operator to execute ExceptionDescribe
 // and ExceptionClear ignoring their return values and sending ""
 // to the error stream.
-#define CHECK_EXCEPTION(jni)    \
-  CHECK(!jni->ExceptionCheck()) \
+#define CHECK_EXCEPTION(jni)        \
+  RTC_CHECK(!jni->ExceptionCheck()) \
       << (jni->ExceptionDescribe(), jni->ExceptionClear(), "")
 
 // Helper that calls ptr->Release() and aborts the process with a useful
 // message if that didn't actually delete *ptr because of extra refcounts.
 #define CHECK_RELEASE(ptr) \
-  CHECK_EQ(0, (ptr)->Release()) << "Unexpected refcount."
+  RTC_CHECK_EQ(0, (ptr)->Release()) << "Unexpected refcount."
 
 namespace webrtc_jni {
 
@@ -67,8 +67,8 @@
 // function expecting a 64-bit param) picks up garbage in the high 32 bits.
 jlong jlongFromPointer(void* ptr);
 
-// JNIEnv-helper methods that CHECK success: no Java exception thrown and found
-// object/class/method/field is non-null.
+// JNIEnv-helper methods that RTC_CHECK success: no Java exception thrown and
+// found object/class/method/field is non-null.
 jmethodID GetMethodID(
     JNIEnv* jni, jclass c, const std::string& name, const char* signature);
 
diff --git a/talk/app/webrtc/java/jni/native_handle_impl.h b/talk/app/webrtc/java/jni/native_handle_impl.h
index cdb72ff..68b213b 100644
--- a/talk/app/webrtc/java/jni/native_handle_impl.h
+++ b/talk/app/webrtc/java/jni/native_handle_impl.h
@@ -66,7 +66,7 @@
  private:
   rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override {
     // TODO(pbos): Implement before using this in the encoder pipeline (or
-    // remove the CHECK() in VideoCapture).
+    // remove the RTC_CHECK() in VideoCapture).
     RTC_NOTREACHED();
     return nullptr;
   }
diff --git a/talk/app/webrtc/java/jni/peerconnection_jni.cc b/talk/app/webrtc/java/jni/peerconnection_jni.cc
index 35406f5..5761d86 100644
--- a/talk/app/webrtc/java/jni/peerconnection_jni.cc
+++ b/talk/app/webrtc/java/jni/peerconnection_jni.cc
@@ -140,7 +140,7 @@
   if (ret < 0)
     return -1;
 
-  CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
+  RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
   LoadGlobalClassReferenceHolder();
 
   return ret;
@@ -148,7 +148,7 @@
 
 extern "C" void JNIEXPORT JNICALL JNI_OnUnLoad(JavaVM *jvm, void *reserved) {
   FreeGlobalClassReferenceHolder();
-  CHECK(rtc::CleanupSSL()) << "Failed to CleanupSSL()";
+  RTC_CHECK(rtc::CleanupSSL()) << "Failed to CleanupSSL()";
 }
 
 // Return the (singleton) Java Enum object corresponding to |index|;
@@ -219,7 +219,7 @@
   void OnIceCandidate(const IceCandidateInterface* candidate) override {
     ScopedLocalRefFrame local_ref_frame(jni());
     std::string sdp;
-    CHECK(candidate->ToString(&sdp)) << "got so far: " << sdp;
+    RTC_CHECK(candidate->ToString(&sdp)) << "got so far: " << sdp;
     jclass candidate_class = FindClass(jni(), "org/webrtc/IceCandidate");
     jmethodID ctor = GetMethodID(jni(), candidate_class,
         "<init>", "(Ljava/lang/String;ILjava/lang/String;)V");
@@ -308,7 +308,7 @@
                                   "(Ljava/lang/Object;)Z");
       jboolean added = jni()->CallBooleanMethod(audio_tracks, add, j_track);
       CHECK_EXCEPTION(jni()) << "error during CallBooleanMethod";
-      CHECK(added);
+      RTC_CHECK(added);
     }
 
     for (const auto& track : stream->GetVideoTracks()) {
@@ -331,7 +331,7 @@
                                   "(Ljava/lang/Object;)Z");
       jboolean added = jni()->CallBooleanMethod(video_tracks, add, j_track);
       CHECK_EXCEPTION(jni()) << "error during CallBooleanMethod";
-      CHECK(added);
+      RTC_CHECK(added);
     }
     remote_streams_[stream] = NewGlobalRef(jni(), j_stream);
 
@@ -344,8 +344,8 @@
   void OnRemoveStream(MediaStreamInterface* stream) override {
     ScopedLocalRefFrame local_ref_frame(jni());
     NativeToJavaStreamsMap::iterator it = remote_streams_.find(stream);
-    CHECK(it != remote_streams_.end()) << "unexpected stream: " << std::hex
-                                       << stream;
+    RTC_CHECK(it != remote_streams_.end()) << "unexpected stream: " << std::hex
+                                           << stream;
     jobject j_stream = it->second;
     jmethodID m = GetMethodID(jni(), *j_observer_class_, "onRemoveStream",
                               "(Lorg/webrtc/MediaStream;)V");
@@ -369,7 +369,7 @@
     // CallVoidMethod above as Java code might call back into native code and be
     // surprised to see a refcount of 2.
     int bumped_count = channel->AddRef();
-    CHECK(bumped_count == 2) << "Unexpected refcount OnDataChannel";
+    RTC_CHECK(bumped_count == 2) << "Unexpected refcount OnDataChannel";
 
     CHECK_EXCEPTION(jni()) << "error during CallVoidMethod";
   }
@@ -383,7 +383,7 @@
   }
 
   void SetConstraints(ConstraintsWrapper* constraints) {
-    CHECK(!constraints_.get()) << "constraints already set!";
+    RTC_CHECK(!constraints_.get()) << "constraints already set!";
     constraints_.reset(constraints);
   }
 
@@ -482,7 +482,7 @@
 static jobject JavaSdpFromNativeSdp(
     JNIEnv* jni, const SessionDescriptionInterface* desc) {
   std::string sdp;
-  CHECK(desc->ToString(&sdp)) << "got so far: " << sdp;
+  RTC_CHECK(desc->ToString(&sdp)) << "got so far: " << sdp;
   jstring j_description = JavaStringFromStdString(jni, sdp);
 
   jclass j_type_class = FindClass(
@@ -871,7 +871,7 @@
 
 JOW(jlong, DataChannel_bufferedAmount)(JNIEnv* jni, jobject j_dc) {
   uint64 buffered_amount = ExtractNativeDC(jni, j_dc)->buffered_amount();
-  CHECK_LE(buffered_amount, std::numeric_limits<int64>::max())
+  RTC_CHECK_LE(buffered_amount, std::numeric_limits<int64>::max())
       << "buffered_amount overflowed jlong!";
   return static_cast<jlong>(buffered_amount);
 }
@@ -903,7 +903,7 @@
 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
     if (path != "logcat:") {
 #endif
-      CHECK_EQ(0, webrtc::Trace::SetTraceFile(path.c_str(), false))
+      RTC_CHECK_EQ(0, webrtc::Trace::SetTraceFile(path.c_str(), false))
           << "SetTraceFile failed";
 #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD)
     } else {
@@ -1087,7 +1087,7 @@
   worker_thread->SetName("worker_thread", NULL);
   Thread* signaling_thread = new Thread();
   signaling_thread->SetName("signaling_thread", NULL);
-  CHECK(worker_thread->Start() && signaling_thread->Start())
+  RTC_CHECK(worker_thread->Start() && signaling_thread->Start())
       << "Failed to start threads";
   WebRtcVideoEncoderFactory* encoder_factory = nullptr;
   WebRtcVideoDecoderFactory* decoder_factory = nullptr;
@@ -1251,7 +1251,7 @@
   if (enum_name == "NONE")
     return PeerConnectionInterface::kNone;
 
-  CHECK(false) << "Unexpected IceTransportsType enum_name " << enum_name;
+  RTC_CHECK(false) << "Unexpected IceTransportsType enum_name " << enum_name;
   return PeerConnectionInterface::kAll;
 }
 
@@ -1270,7 +1270,7 @@
   if (enum_name == "MAXCOMPAT")
     return PeerConnectionInterface::kBundlePolicyMaxCompat;
 
-  CHECK(false) << "Unexpected BundlePolicy enum_name " << enum_name;
+  RTC_CHECK(false) << "Unexpected BundlePolicy enum_name " << enum_name;
   return PeerConnectionInterface::kBundlePolicyBalanced;
 }
 
@@ -1286,7 +1286,7 @@
   if (enum_name == "REQUIRE")
     return PeerConnectionInterface::kRtcpMuxPolicyRequire;
 
-  CHECK(false) << "Unexpected RtcpMuxPolicy enum_name " << enum_name;
+  RTC_CHECK(false) << "Unexpected RtcpMuxPolicy enum_name " << enum_name;
   return PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
 }
 
@@ -1303,7 +1303,7 @@
   if (enum_name == "DISABLED")
     return PeerConnectionInterface::kTcpCandidatePolicyDisabled;
 
-  CHECK(false) << "Unexpected TcpCandidatePolicy enum_name " << enum_name;
+  RTC_CHECK(false) << "Unexpected TcpCandidatePolicy enum_name " << enum_name;
   return PeerConnectionInterface::kTcpCandidatePolicyEnabled;
 }
 
@@ -1316,7 +1316,7 @@
   if (enum_name == "ECDSA")
     return rtc::KT_ECDSA;
 
-  CHECK(false) << "Unexpected KeyType enum_name " << enum_name;
+  RTC_CHECK(false) << "Unexpected KeyType enum_name " << enum_name;
   return rtc::KT_ECDSA;
 }
 
@@ -1477,7 +1477,7 @@
   // vararg parameter as 64-bit and reading memory that doesn't belong to the
   // 32-bit parameter.
   jlong nativeChannelPtr = jlongFromPointer(channel.get());
-  CHECK(nativeChannelPtr) << "Failed to create DataChannel";
+  RTC_CHECK(nativeChannelPtr) << "Failed to create DataChannel";
   jclass j_data_channel_class = FindClass(jni, "org/webrtc/DataChannel");
   jmethodID j_data_channel_ctor = GetMethodID(
       jni, j_data_channel_class, "<init>", "(J)V");
@@ -1486,7 +1486,7 @@
   CHECK_EXCEPTION(jni) << "error during NewObject";
   // Channel is now owned by Java object, and will be freed from there.
   int bumped_count = channel->AddRef();
-  CHECK(bumped_count == 2) << "Unexpected refcount";
+  RTC_CHECK(bumped_count == 2) << "Unexpected refcount";
   return j_channel;
 }
 
@@ -1648,7 +1648,7 @@
   std::string device_name = JavaToStdString(jni, j_device_name);
   scoped_ptr<cricket::DeviceManagerInterface> device_manager(
       cricket::DeviceManagerFactory::Create());
-  CHECK(device_manager->Init()) << "DeviceManager::Init() failed";
+  RTC_CHECK(device_manager->Init()) << "DeviceManager::Init() failed";
   cricket::Device device;
   if (!device_manager->GetVideoCaptureDevice(device_name, &device)) {
     LOG(LS_ERROR) << "GetVideoCaptureDevice failed for " << device_name;
@@ -1695,11 +1695,11 @@
     jint src_stride, jobject j_dst_buffer, jint dst_stride) {
   size_t src_size = jni->GetDirectBufferCapacity(j_src_buffer);
   size_t dst_size = jni->GetDirectBufferCapacity(j_dst_buffer);
-  CHECK(src_stride >= width) << "Wrong source stride " << src_stride;
-  CHECK(dst_stride >= width) << "Wrong destination stride " << dst_stride;
-  CHECK(src_size >= src_stride * height)
+  RTC_CHECK(src_stride >= width) << "Wrong source stride " << src_stride;
+  RTC_CHECK(dst_stride >= width) << "Wrong destination stride " << dst_stride;
+  RTC_CHECK(src_size >= src_stride * height)
       << "Insufficient source buffer capacity " << src_size;
-  CHECK(dst_size >= dst_stride * height)
+  RTC_CHECK(dst_size >= dst_stride * height)
       << "Isufficient destination buffer capacity " << dst_size;
   uint8_t *src =
       reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_buffer));
diff --git a/talk/app/webrtc/mediacontroller.cc b/talk/app/webrtc/mediacontroller.cc
index ff21314..28b007e 100644
--- a/talk/app/webrtc/mediacontroller.cc
+++ b/talk/app/webrtc/mediacontroller.cc
@@ -42,7 +42,7 @@
   MediaController(rtc::Thread* worker_thread,
                   webrtc::VoiceEngine* voice_engine)
       : worker_thread_(worker_thread) {
-    DCHECK(nullptr != worker_thread);
+    RTC_DCHECK(nullptr != worker_thread);
     worker_thread_->Invoke<void>(
         rtc::Bind(&MediaController::Construct_w, this, voice_engine));
   }
@@ -52,13 +52,13 @@
   }
 
   webrtc::Call* call_w() override {
-    DCHECK(worker_thread_->IsCurrent());
+    RTC_DCHECK(worker_thread_->IsCurrent());
     return call_.get();
   }
 
  private:
   void Construct_w(webrtc::VoiceEngine* voice_engine)  {
-    DCHECK(worker_thread_->IsCurrent());
+    RTC_DCHECK(worker_thread_->IsCurrent());
     webrtc::Call::Config config;
     config.voice_engine = voice_engine;
     config.bitrate_config.min_bitrate_bps = kMinBandwidthBps;
@@ -67,7 +67,7 @@
     call_.reset(webrtc::Call::Create(config));
   }
   void Destruct_w() {
-    DCHECK(worker_thread_->IsCurrent());
+    RTC_DCHECK(worker_thread_->IsCurrent());
     call_.reset(nullptr);
   }
 
diff --git a/talk/app/webrtc/objc/RTCFileLogger.mm b/talk/app/webrtc/objc/RTCFileLogger.mm
index 3080ebc..c4e4696 100644
--- a/talk/app/webrtc/objc/RTCFileLogger.mm
+++ b/talk/app/webrtc/objc/RTCFileLogger.mm
@@ -109,7 +109,7 @@
   if (!_hasStarted) {
     return;
   }
-  DCHECK(_logSink);
+  RTC_DCHECK(_logSink);
   rtc::LogMessage::RemoveLogToStream(_logSink.get());
   _hasStarted = NO;
   _logSink.reset();
diff --git a/talk/app/webrtc/objc/avfoundationvideocapturer.mm b/talk/app/webrtc/objc/avfoundationvideocapturer.mm
index d68fdff..c47e36d 100644
--- a/talk/app/webrtc/objc/avfoundationvideocapturer.mm
+++ b/talk/app/webrtc/objc/avfoundationvideocapturer.mm
@@ -336,7 +336,7 @@
 
   // Keep track of which thread capture started on. This is the thread that
   // frames need to be sent to.
-  DCHECK(!_startThread);
+  RTC_DCHECK(!_startThread);
   _startThread = rtc::Thread::Current();
 
   SetCaptureFormat(&format);
@@ -412,7 +412,8 @@
   // Sanity check assumption that planar bytes are contiguous.
   uint8_t* uvPlaneAddress =
       (uint8_t*)CVPixelBufferGetBaseAddressOfPlane(imageBuffer, kUVPlaneIndex);
-  DCHECK(uvPlaneAddress == yPlaneAddress + yPlaneHeight * yPlaneBytesPerRow);
+  RTC_DCHECK(
+      uvPlaneAddress == yPlaneAddress + yPlaneHeight * yPlaneBytesPerRow);
 
   // Stuff data into a cricket::CapturedFrame.
   int64 currentTime = rtc::TimeNanos();
@@ -439,7 +440,7 @@
 
 void AVFoundationVideoCapturer::SignalFrameCapturedOnStartThread(
     const cricket::CapturedFrame* frame) {
-  DCHECK(_startThread->IsCurrent());
+  RTC_DCHECK(_startThread->IsCurrent());
   // This will call a superclass method that will perform the frame conversion
   // to I420.
   SignalFrameCaptured(this, frame);
diff --git a/talk/app/webrtc/peerconnectionfactory.cc b/talk/app/webrtc/peerconnectionfactory.cc
index 26765d2..98c5c85 100644
--- a/talk/app/webrtc/peerconnectionfactory.cc
+++ b/talk/app/webrtc/peerconnectionfactory.cc
@@ -55,7 +55,7 @@
   DtlsIdentityStoreWrapper(
       const rtc::scoped_refptr<RefCountedDtlsIdentityStore>& store)
       : store_(store) {
-    DCHECK(store_);
+    RTC_DCHECK(store_);
   }
 
   void RequestIdentity(
@@ -151,7 +151,7 @@
 }
 
 PeerConnectionFactory::~PeerConnectionFactory() {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   channel_manager_.reset(nullptr);
   default_allocator_factory_ = nullptr;
 
@@ -167,7 +167,7 @@
 }
 
 bool PeerConnectionFactory::Initialize() {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   rtc::InitRandom(rtc::Time());
 
   default_allocator_factory_ = PortAllocatorFactory::Create(worker_thread_);
@@ -200,7 +200,7 @@
 rtc::scoped_refptr<AudioSourceInterface>
 PeerConnectionFactory::CreateAudioSource(
     const MediaConstraintsInterface* constraints) {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   rtc::scoped_refptr<LocalAudioSource> source(
       LocalAudioSource::Create(options_, constraints));
   return source;
@@ -210,14 +210,14 @@
 PeerConnectionFactory::CreateVideoSource(
     cricket::VideoCapturer* capturer,
     const MediaConstraintsInterface* constraints) {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   rtc::scoped_refptr<VideoSource> source(
       VideoSource::Create(channel_manager_.get(), capturer, constraints));
   return VideoSourceProxy::Create(signaling_thread_, source);
 }
 
 bool PeerConnectionFactory::StartAecDump(rtc::PlatformFile file) {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   return channel_manager_->StartAecDump(file);
 }
 
@@ -228,8 +228,8 @@
     PortAllocatorFactoryInterface* allocator_factory,
     rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
     PeerConnectionObserver* observer) {
-  DCHECK(signaling_thread_->IsCurrent());
-  DCHECK(allocator_factory || default_allocator_factory_);
+  RTC_DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(allocator_factory || default_allocator_factory_);
 
   if (!dtls_identity_store.get()) {
     // Because |pc|->Initialize takes ownership of the store we need a new
@@ -258,7 +258,7 @@
 
 rtc::scoped_refptr<MediaStreamInterface>
 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   return MediaStreamProxy::Create(signaling_thread_,
                                   MediaStream::Create(label));
 }
@@ -267,7 +267,7 @@
 PeerConnectionFactory::CreateVideoTrack(
     const std::string& id,
     VideoSourceInterface* source) {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   rtc::scoped_refptr<VideoTrackInterface> track(
       VideoTrack::Create(id, source));
   return VideoTrackProxy::Create(signaling_thread_, track);
@@ -276,14 +276,14 @@
 rtc::scoped_refptr<AudioTrackInterface>
 PeerConnectionFactory::CreateAudioTrack(const std::string& id,
                                         AudioSourceInterface* source) {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   rtc::scoped_refptr<AudioTrackInterface> track(
       AudioTrack::Create(id, source));
   return AudioTrackProxy::Create(signaling_thread_, track);
 }
 
 cricket::ChannelManager* PeerConnectionFactory::channel_manager() {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   return channel_manager_.get();
 }
 
@@ -294,7 +294,7 @@
 }
 
 rtc::Thread* PeerConnectionFactory::worker_thread() {
-  DCHECK(signaling_thread_->IsCurrent());
+  RTC_DCHECK(signaling_thread_->IsCurrent());
   return worker_thread_;
 }
 
diff --git a/talk/app/webrtc/statscollector.cc b/talk/app/webrtc/statscollector.cc
index a634521..6327445 100644
--- a/talk/app/webrtc/statscollector.cc
+++ b/talk/app/webrtc/statscollector.cc
@@ -71,7 +71,7 @@
 
 StatsReport::Id GetTransportIdFromProxy(const cricket::ProxyTransportMap& map,
                                         const std::string& proxy) {
-  DCHECK(!proxy.empty());
+  RTC_DCHECK(!proxy.empty());
   cricket::ProxyTransportMap::const_iterator found = map.find(proxy);
   if (found == map.end())
     return StatsReport::Id();
@@ -96,7 +96,7 @@
   for (const auto& track : tracks) {
     const std::string& track_id = track->id();
     StatsReport* report = AddTrackReport(reports, track_id);
-    DCHECK(report != nullptr);
+    RTC_DCHECK(report != nullptr);
     track_ids[track_id] = report;
   }
 }
@@ -261,7 +261,7 @@
                   double stats_gathering_started,
                   PeerConnectionInterface::StatsOutputLevel level,
                   StatsReport* report) {
-  DCHECK(report->type() == StatsReport::kStatsReportTypeBwe);
+  RTC_DCHECK(report->type() == StatsReport::kStatsReportTypeBwe);
 
   report->set_timestamp(stats_gathering_started);
   const IntForAdd ints[] = {
@@ -332,7 +332,7 @@
   if (candidate_type == cricket::RELAY_PORT_TYPE) {
     return STATSREPORT_RELAY_PORT_TYPE;
   }
-  DCHECK(false);
+  RTC_DCHECK(false);
   return "unknown";
 }
 
@@ -351,7 +351,7 @@
     case rtc::ADAPTER_TYPE_LOOPBACK:
       return STATSREPORT_ADAPTER_TYPE_LOOPBACK;
     default:
-      DCHECK(false);
+      RTC_DCHECK(false);
       return "";
   }
 }
@@ -359,11 +359,11 @@
 StatsCollector::StatsCollector(WebRtcSession* session)
     : session_(session),
       stats_gathering_started_(0) {
-  DCHECK(session_);
+  RTC_DCHECK(session_);
 }
 
 StatsCollector::~StatsCollector() {
-  DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
 }
 
 double StatsCollector::GetTimeNow() {
@@ -373,8 +373,8 @@
 // Adds a MediaStream with tracks that can be used as a |selector| in a call
 // to GetStats.
 void StatsCollector::AddStream(MediaStreamInterface* stream) {
-  DCHECK(session_->signaling_thread()->IsCurrent());
-  DCHECK(stream != NULL);
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(stream != NULL);
 
   CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(),
                                        &reports_, track_ids_);
@@ -384,11 +384,11 @@
 
 void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
                                         uint32 ssrc) {
-  DCHECK(session_->signaling_thread()->IsCurrent());
-  DCHECK(audio_track != NULL);
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(audio_track != NULL);
 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
   for (const auto& track : local_audio_tracks_)
-    DCHECK(track.first != audio_track || track.second != ssrc);
+    RTC_DCHECK(track.first != audio_track || track.second != ssrc);
 #endif
 
   local_audio_tracks_.push_back(std::make_pair(audio_track, ssrc));
@@ -406,7 +406,7 @@
 
 void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
                                            uint32 ssrc) {
-  DCHECK(audio_track != NULL);
+  RTC_DCHECK(audio_track != NULL);
   local_audio_tracks_.erase(std::remove_if(local_audio_tracks_.begin(),
       local_audio_tracks_.end(),
       [audio_track, ssrc](const LocalAudioTrackVector::value_type& track) {
@@ -416,9 +416,9 @@
 
 void StatsCollector::GetStats(MediaStreamTrackInterface* track,
                               StatsReports* reports) {
-  DCHECK(session_->signaling_thread()->IsCurrent());
-  DCHECK(reports != NULL);
-  DCHECK(reports->empty());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(reports != NULL);
+  RTC_DCHECK(reports->empty());
 
   rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
 
@@ -456,7 +456,7 @@
 
 void
 StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
-  DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
   double time_now = GetTimeNow();
   // Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of
   // ms apart will be ignored.
@@ -487,7 +487,7 @@
     uint32 ssrc,
     const StatsReport::Id& transport_id,
     StatsReport::Direction direction) {
-  DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
   StatsReport::Id id(StatsReport::NewIdWithDirection(
       local ? StatsReport::kStatsReportTypeSsrc :
               StatsReport::kStatsReportTypeRemoteSsrc,
@@ -526,7 +526,7 @@
 
 StatsReport* StatsCollector::AddOneCertificateReport(
     const rtc::SSLCertificate* cert, const StatsReport* issuer) {
-  DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
 
   // TODO(bemasc): Move this computation to a helper class that caches these
   // values to reduce CPU use in GetStats.  This will require adding a fast
@@ -569,13 +569,13 @@
 
 StatsReport* StatsCollector::AddCertificateReports(
     const rtc::SSLCertificate* cert) {
-  DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
   // Produces a chain of StatsReports representing this certificate and the rest
   // of its chain, and adds those reports to |reports_|.  The return value is
   // the id of the leaf report.  The provided cert must be non-null, so at least
   // one report will always be provided and the returned string will never be
   // empty.
-  DCHECK(cert != NULL);
+  RTC_DCHECK(cert != NULL);
 
   StatsReport* issuer = nullptr;
   rtc::scoped_ptr<rtc::SSLCertChain> chain;
@@ -669,7 +669,7 @@
 }
 
 void StatsCollector::ExtractSessionInfo() {
-  DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
 
   // Extract information from the base session.
   StatsReport::Id id(StatsReport::NewTypedId(
@@ -763,7 +763,7 @@
 }
 
 void StatsCollector::ExtractVoiceInfo() {
-  DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
 
   if (!session_->voice_channel()) {
     return;
@@ -796,7 +796,7 @@
 
 void StatsCollector::ExtractVideoInfo(
     PeerConnectionInterface::StatsOutputLevel level) {
-  DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
 
   if (!session_->video_channel())
     return;
@@ -833,7 +833,7 @@
 }
 
 void StatsCollector::ExtractDataInfo() {
-  DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
 
   rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
 
@@ -854,14 +854,14 @@
 StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type,
                                        const std::string& id,
                                        StatsReport::Direction direction) {
-  DCHECK(session_->signaling_thread()->IsCurrent());
-  DCHECK(type == StatsReport::kStatsReportTypeSsrc ||
-         type == StatsReport::kStatsReportTypeRemoteSsrc);
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(type == StatsReport::kStatsReportTypeSsrc ||
+             type == StatsReport::kStatsReportTypeRemoteSsrc);
   return reports_.Find(StatsReport::NewIdWithDirection(type, id, direction));
 }
 
 void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
-  DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
   // Loop through the existing local audio tracks.
   for (const auto& it : local_audio_tracks_) {
     AudioTrackInterface* track = it.first;
@@ -889,8 +889,8 @@
 
 void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
                                                 StatsReport* report) {
-  DCHECK(session_->signaling_thread()->IsCurrent());
-  DCHECK(track != NULL);
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(track != NULL);
 
   int signal_level = 0;
   if (!track->GetSignalLevel(&signal_level))
@@ -911,7 +911,7 @@
 
 bool StatsCollector::GetTrackIdBySsrc(uint32 ssrc, std::string* track_id,
                                       StatsReport::Direction direction) {
-  DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
   if (direction == StatsReport::kSend) {
     if (!session_->GetLocalTrackIdBySsrc(ssrc, track_id)) {
       LOG(LS_WARNING) << "The SSRC " << ssrc
@@ -919,7 +919,7 @@
       return false;
     }
   } else {
-    DCHECK(direction == StatsReport::kReceive);
+    RTC_DCHECK(direction == StatsReport::kReceive);
     if (!session_->GetRemoteTrackIdBySsrc(ssrc, track_id)) {
       LOG(LS_WARNING) << "The SSRC " << ssrc
                       << " is not associated with a receiving track";
@@ -931,7 +931,7 @@
 }
 
 void StatsCollector::UpdateTrackReports() {
-  DCHECK(session_->signaling_thread()->IsCurrent());
+  RTC_DCHECK(session_->signaling_thread()->IsCurrent());
 
   rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
 
diff --git a/talk/app/webrtc/statstypes.cc b/talk/app/webrtc/statstypes.cc
index a23b959..56d705e 100644
--- a/talk/app/webrtc/statstypes.cc
+++ b/talk/app/webrtc/statstypes.cc
@@ -32,7 +32,7 @@
 #include "webrtc/base/checks.h"
 
 // TODO(tommi): Could we have a static map of value name -> expected type
-// and use this to DCHECK on correct usage (somewhat strongly typed values)?
+// and use this to RTC_DCHECK on correct usage (somewhat strongly typed values)?
 // Alternatively, we could define the names+type in a separate document and
 // generate strongly typed inline C++ code that forces the correct type to be
 // used for a given name at compile time.
@@ -74,7 +74,7 @@
     case StatsReport::kStatsReportTypeDataChannel:
       return "datachannel";
   }
-  DCHECK(false);
+  RTC_DCHECK(false);
   return nullptr;
 }
 
@@ -231,7 +231,7 @@
 
 StatsReport::Value::Value(StatsValueName name, int64 value, Type int_type)
     : name(name), type_(int_type) {
-  DCHECK(type_ == kInt || type_ == kInt64);
+  RTC_DCHECK(type_ == kInt || type_ == kInt64);
   type_ == kInt ? value_.int_ = static_cast<int>(value) : value_.int64_ = value;
 }
 
@@ -283,7 +283,7 @@
 
   // There's a 1:1 relation between a name and a type, so we don't have to
   // check that.
-  DCHECK_EQ(type_, other.type_);
+  RTC_DCHECK_EQ(type_, other.type_);
 
   switch (type_) {
     case kInt:
@@ -295,7 +295,8 @@
     case kStaticString: {
 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
       if (value_.static_string_ != other.value_.static_string_) {
-        DCHECK(strcmp(value_.static_string_, other.value_.static_string_) != 0)
+        RTC_DCHECK(strcmp(value_.static_string_, other.value_.static_string_) !=
+                   0)
             << "Duplicate global?";
       }
 #endif
@@ -324,7 +325,8 @@
     return false;
 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
   if (value_.static_string_ != value)
-    DCHECK(strcmp(value_.static_string_, value) != 0) << "Duplicate global?";
+    RTC_DCHECK(strcmp(value_.static_string_, value) != 0)
+        << "Duplicate global?";
 #endif
   return value == value_.static_string_;
 }
@@ -347,32 +349,32 @@
 }
 
 int StatsReport::Value::int_val() const {
-  DCHECK(type_ == kInt);
+  RTC_DCHECK(type_ == kInt);
   return value_.int_;
 }
 
 int64 StatsReport::Value::int64_val() const {
-  DCHECK(type_ == kInt64);
+  RTC_DCHECK(type_ == kInt64);
   return value_.int64_;
 }
 
 float StatsReport::Value::float_val() const {
-  DCHECK(type_ == kFloat);
+  RTC_DCHECK(type_ == kFloat);
   return value_.float_;
 }
 
 const char* StatsReport::Value::static_string_val() const {
-  DCHECK(type_ == kStaticString);
+  RTC_DCHECK(type_ == kStaticString);
   return value_.static_string_;
 }
 
 const std::string& StatsReport::Value::string_val() const {
-  DCHECK(type_ == kString);
+  RTC_DCHECK(type_ == kString);
   return *value_.string_;
 }
 
 bool StatsReport::Value::bool_val() const {
-  DCHECK(type_ == kBool);
+  RTC_DCHECK(type_ == kBool);
   return value_.bool_;
 }
 
@@ -591,7 +593,7 @@
     case kStatsValueNameWritable:
       return "googWritable";
     default:
-      DCHECK(false);
+      RTC_DCHECK(false);
       break;
   }
 
@@ -620,7 +622,7 @@
 }
 
 StatsReport::StatsReport(const Id& id) : id_(id), timestamp_(0.0) {
-  DCHECK(id_.get());
+  RTC_DCHECK(id_.get());
 }
 
 // static
@@ -720,43 +722,43 @@
 }
 
 StatsCollection::~StatsCollection() {
-  DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
   for (auto* r : list_)
     delete r;
 }
 
 StatsCollection::const_iterator StatsCollection::begin() const {
-  DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
   return list_.begin();
 }
 
 StatsCollection::const_iterator StatsCollection::end() const {
-  DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
   return list_.end();
 }
 
 size_t StatsCollection::size() const {
-  DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
   return list_.size();
 }
 
 StatsReport* StatsCollection::InsertNew(const StatsReport::Id& id) {
-  DCHECK(thread_checker_.CalledOnValidThread());
-  DCHECK(Find(id) == nullptr);
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(Find(id) == nullptr);
   StatsReport* report = new StatsReport(id);
   list_.push_back(report);
   return report;
 }
 
 StatsReport* StatsCollection::FindOrAddNew(const StatsReport::Id& id) {
-  DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_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());
+  RTC_DCHECK(thread_checker_.CalledOnValidThread());
+  RTC_DCHECK(id.get());
   Container::iterator it = std::find_if(list_.begin(), list_.end(),
       [&id](const StatsReport* r)->bool { return r->id()->Equals(id); });
   if (it != end()) {
@@ -771,7 +773,7 @@
 // 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());
+  RTC_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;
diff --git a/talk/app/webrtc/test/fakedtlsidentitystore.h b/talk/app/webrtc/test/fakedtlsidentitystore.h
index 5d7743d..0f9bdb9 100644
--- a/talk/app/webrtc/test/fakedtlsidentitystore.h
+++ b/talk/app/webrtc/test/fakedtlsidentitystore.h
@@ -82,7 +82,7 @@
       const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>&
           observer) override {
     // TODO(hbos): Should be able to generate KT_ECDSA too.
-    DCHECK(key_type == rtc::KT_RSA || should_fail_);
+    RTC_DCHECK(key_type == rtc::KT_RSA || should_fail_);
     MessageData* msg = new MessageData(
         rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>(observer));
     rtc::Thread::Current()->Post(
diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc
index 26a9505..0c0e44d 100644
--- a/talk/app/webrtc/webrtcsession.cc
+++ b/talk/app/webrtc/webrtcsession.cc
@@ -746,7 +746,7 @@
     // Construct with DTLS enabled.
     if (!certificate) {
       // Use the |dtls_identity_store| to generate a certificate.
-      DCHECK(dtls_identity_store);
+      RTC_DCHECK(dtls_identity_store);
       webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
           signaling_thread(),
           channel_manager_,
@@ -2006,7 +2006,7 @@
 // for IPv4 and IPv6.
 void WebRtcSession::ReportBestConnectionState(
     const cricket::TransportStats& stats) {
-  DCHECK(metrics_observer_ != NULL);
+  RTC_DCHECK(metrics_observer_ != NULL);
   for (cricket::TransportChannelStatsList::const_iterator it =
          stats.channel_stats.begin();
        it != stats.channel_stats.end(); ++it) {
@@ -2029,7 +2029,7 @@
       } else if (local.protocol() == cricket::UDP_PROTOCOL_NAME) {
         type = kEnumCounterIceCandidatePairTypeUdp;
       } else {
-        CHECK(0);
+        RTC_CHECK(0);
       }
       metrics_observer_->IncrementEnumCounter(
           type, GetIceCandidatePairCounter(local, remote),
@@ -2046,7 +2046,7 @@
             kEnumCounterAddressFamily, kBestConnections_IPv6,
             kPeerConnectionAddressFamilyCounter_Max);
       } else {
-        CHECK(0);
+        RTC_CHECK(0);
       }
 
       return;
@@ -2056,7 +2056,7 @@
 
 void WebRtcSession::ReportNegotiatedCiphers(
     const cricket::TransportStats& stats) {
-  DCHECK(metrics_observer_ != NULL);
+  RTC_DCHECK(metrics_observer_ != NULL);
   if (!dtls_enabled_ || stats.channel_stats.empty()) {
     return;
   }
diff --git a/talk/app/webrtc/webrtcsession_unittest.cc b/talk/app/webrtc/webrtcsession_unittest.cc
index ef4d33f..b84e6fb 100644
--- a/talk/app/webrtc/webrtcsession_unittest.cc
+++ b/talk/app/webrtc/webrtcsession_unittest.cc
@@ -424,7 +424,7 @@
       dtls_identity_store.reset(new FakeDtlsIdentityStore());
       dtls_identity_store->set_should_fail(false);
     } else {
-      CHECK(false);
+      RTC_CHECK(false);
     }
     Init(dtls_identity_store.Pass(), configuration);
   }
@@ -1237,7 +1237,7 @@
 
   void VerifyMultipleAsyncCreateDescriptionAfterInit(
       bool success, CreateSessionDescriptionRequest::Type type) {
-    CHECK(session_);
+    RTC_CHECK(session_);
     SetFactoryDtlsSrtp();
     if (type == CreateSessionDescriptionRequest::kAnswer) {
       cricket::MediaSessionOptions options;
diff --git a/talk/app/webrtc/webrtcsessiondescriptionfactory.cc b/talk/app/webrtc/webrtcsessiondescriptionfactory.cc
index aad5185..a0ec679 100644
--- a/talk/app/webrtc/webrtcsessiondescriptionfactory.cc
+++ b/talk/app/webrtc/webrtcsessiondescriptionfactory.cc
@@ -190,7 +190,7 @@
         session_id,
         dct,
         true) {
-  DCHECK(dtls_identity_store_);
+  RTC_DCHECK(dtls_identity_store_);
 
   certificate_request_state_ = CERTIFICATE_WAITING;
 
@@ -219,7 +219,7 @@
     : WebRtcSessionDescriptionFactory(
         signaling_thread, channel_manager, mediastream_signaling, nullptr,
         nullptr, session, session_id, dct, true) {
-  DCHECK(certificate);
+  RTC_DCHECK(certificate);
 
   certificate_request_state_ = CERTIFICATE_WAITING;
 
@@ -517,7 +517,7 @@
 
 void WebRtcSessionDescriptionFactory::SetCertificate(
     const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
-  DCHECK(certificate);
+  RTC_DCHECK(certificate);
   LOG(LS_VERBOSE) << "Setting new certificate";
 
   certificate_request_state_ = CERTIFICATE_SUCCEEDED;