Moved RtcEventLog files from call/ to logging/

The RtcEventLog headers need to be accessible from any place which needs
logging, and the implementation needs access to data structures that are
logged.

After a discussion in the code review, we all agreed to move the RtcEventLog implementation into its own top level directory - which I called "logging/" in expectation that other types of logging may have similar requirements. The directory contains two main build targets - "rtc_event_log_api", which is just rtc_event_log.h, that has no external dependencies and can be used from anywhere, and "rtc_event_log_impl" which contains the rest of the implementation and has many dependencies (more in the future).

The "api" target can be referenced from anywhere, while the "impl" target is only needed at the place of instantiation (currently Call, soon to be moved to PeerConnection by https://codereview.webrtc.org/2353033005/).

This change allows using RtcEventLog in the p2p/ directory, so that we
can log STUN pings and ICE state transitions.

BUG=webrtc:6393
R=kjellander@webrtc.org, kwiberg@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#14485}
diff --git a/webrtc/logging/rtc_event_log/ringbuffer.h b/webrtc/logging/rtc_event_log/ringbuffer.h
new file mode 100644
index 0000000..6c0ffda
--- /dev/null
+++ b/webrtc/logging/rtc_event_log/ringbuffer.h
@@ -0,0 +1,100 @@
+/*
+ *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ *
+ */
+
+#ifndef WEBRTC_LOGGING_RTC_EVENT_LOG_RINGBUFFER_H_
+#define WEBRTC_LOGGING_RTC_EVENT_LOG_RINGBUFFER_H_
+
+#include <memory>
+#include <utility>
+
+#include "webrtc/base/checks.h"
+#include "webrtc/base/constructormagic.h"
+
+namespace webrtc {
+
+// A RingBuffer works like a fixed size queue which starts discarding
+// the oldest elements when it becomes full.
+template <typename T>
+class RingBuffer {
+ public:
+  // Creates a RingBuffer with space for |capacity| elements.
+  explicit RingBuffer(size_t capacity)
+      :  // We allocate space for one extra sentinel element.
+        data_(new T[capacity + 1]) {
+    RTC_DCHECK(capacity > 0);
+    end_ = data_.get() + (capacity + 1);
+    front_ = data_.get();
+    back_ = data_.get();
+  }
+
+  ~RingBuffer() {
+    // The unique_ptr will free the memory.
+  }
+
+  // Removes an element from the front of the queue.
+  void pop_front() {
+    RTC_DCHECK(!empty());
+    ++front_;
+    if (front_ == end_) {
+      front_ = data_.get();
+    }
+  }
+
+  // Appends an element to the back of the queue (and removes an
+  // element from the front if there is no space at the back of the queue).
+  void push_back(const T& elem) {
+    *back_ = elem;
+    ++back_;
+    if (back_ == end_) {
+      back_ = data_.get();
+    }
+    if (back_ == front_) {
+      ++front_;
+    }
+    if (front_ == end_) {
+      front_ = data_.get();
+    }
+  }
+
+  // Appends an element to the back of the queue (and removes an
+  // element from the front if there is no space at the back of the queue).
+  void push_back(T&& elem) {
+    *back_ = std::move(elem);
+    ++back_;
+    if (back_ == end_) {
+      back_ = data_.get();
+    }
+    if (back_ == front_) {
+      ++front_;
+    }
+    if (front_ == end_) {
+      front_ = data_.get();
+    }
+  }
+
+  T& front() { return *front_; }
+
+  const T& front() const { return *front_; }
+
+  bool empty() const { return (front_ == back_); }
+
+ private:
+  std::unique_ptr<T[]> data_;
+  T* end_;
+  T* front_;
+  T* back_;
+
+  RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RingBuffer);
+};
+
+}  // namespace webrtc
+
+#endif  // WEBRTC_LOGGING_RTC_EVENT_LOG_RINGBUFFER_H_