Move CriticalSection into rtc_base_approved.

This class is being used from both libjingle and webrtc but we recently had a regression when we added dependency on libjingle's Thread class. This cleans that up and moves the implementation of CriticalSection and helper classes into the source file.

I'm also improving debugging facilities and constness.

BUG=
R=magjed@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/51769004

Cr-Commit-Position: refs/heads/master@{#9089}
diff --git a/webrtc/base/messagequeue.cc b/webrtc/base/messagequeue.cc
index 53e451f..5cf448e 100644
--- a/webrtc/base/messagequeue.cc
+++ b/webrtc/base/messagequeue.cc
@@ -59,7 +59,7 @@
   // MessageQueueManager methods should be non-reentrant, so we
   // ASSERT that is the case.  If any of these ASSERT, please
   // contact bpm or jbeda.
-#if CS_TRACK_OWNER  // CurrentThreadIsOwner returns true by default.
+#if CS_DEBUG_CHECKS  // CurrentThreadIsOwner returns true by default.
   ASSERT(!crit_.CurrentThreadIsOwner());
 #endif
   CritScope cs(&crit_);
@@ -73,7 +73,7 @@
   return Instance()->RemoveInternal(message_queue);
 }
 void MessageQueueManager::RemoveInternal(MessageQueue *message_queue) {
-#if CS_TRACK_OWNER  // CurrentThreadIsOwner returns true by default.
+#if CS_DEBUG_CHECKS  // CurrentThreadIsOwner returns true by default.
   ASSERT(!crit_.CurrentThreadIsOwner());  // See note above.
 #endif
   // If this is the last MessageQueue, destroy the manager as well so that
@@ -104,7 +104,7 @@
   return Instance()->ClearInternal(handler);
 }
 void MessageQueueManager::ClearInternal(MessageHandler *handler) {
-#if CS_TRACK_OWNER  // CurrentThreadIsOwner returns true by default.
+#if CS_DEBUG_CHECKS  // CurrentThreadIsOwner returns true by default.
   ASSERT(!crit_.CurrentThreadIsOwner());  // See note above.
 #endif
   CritScope cs(&crit_);