Commit 65c25b89 authored by Ehsan Chiniforooshan's avatar Ehsan Chiniforooshan Committed by Commit Bot

Move cc::RingBuffer to //base

It is used by content/browser/tracing/arc_tracing_agent_impl.{cc,h}, which,
logically, should not depend on chrome compositor.

Also, we want to move arc_tracing_agent_impl to //chrome/browser
(crrev/c/868575) but we do not want to add a dependency from //chrome/browser to
//cc/base ( https://cs.chromium.org/chromium/src/chrome/browser/DEPS?l=89).

TBR=oysteine@chromium.org

Bug: 808839
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: I30adee8ee4f3c7e8c4f478f15e6841937b4be96c
Reviewed-on: https://chromium-review.googlesource.com/899858Reviewed-by: default avatardanakj <danakj@chromium.org>
Reviewed-by: default avatarEhsan Chiniforooshan <chiniforooshan@chromium.org>
Commit-Queue: Ehsan Chiniforooshan <chiniforooshan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534796}
parent 73fedd04
......@@ -2,16 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_BASE_RING_BUFFER_H_
#define CC_BASE_RING_BUFFER_H_
#ifndef BASE_CONTAINERS_RING_BUFFER_H_
#define BASE_CONTAINERS_RING_BUFFER_H_
#include <stddef.h>
#include "base/logging.h"
#include "base/macros.h"
namespace cc {
namespace base {
// base::RingBuffer uses a fixed-size array, unlike base::circular_deque and
// std::deque, and so, one can access only the last |kSize| elements. Also, you
// can add elements to the front and read/modify random elements, but cannot
// remove elements from the back. Therefore, it does not have a |Size| method,
// only |BufferSize|, which is a constant, and |CurrentIndex|, which is the
// number of elements added so far.
//
// If the above is sufficient for your use case, base::RingBuffer should be more
// efficient than base::circular_deque.
template <typename T, size_t kSize>
class RingBuffer {
public:
......@@ -105,6 +114,6 @@ class RingBuffer {
DISALLOW_COPY_AND_ASSIGN(RingBuffer);
};
} // namespace cc
} // namespace base
#endif // CC_BASE_RING_BUFFER_H_
#endif // BASE_CONTAINERS_RING_BUFFER_H_
......@@ -10,9 +10,9 @@
#include <memory>
#include "base/containers/ring_buffer.h"
#include "base/macros.h"
#include "base/time/time.h"
#include "cc/base/ring_buffer.h"
namespace cc {
......@@ -36,7 +36,7 @@ class MemoryHistory {
void SaveEntry(const Entry& entry);
typedef RingBuffer<Entry, 80> RingBufferType;
typedef base::RingBuffer<Entry, 80> RingBufferType;
RingBufferType::Iterator Begin() const { return ring_buffer_.Begin(); }
RingBufferType::Iterator End() const { return ring_buffer_.End(); }
......
......@@ -9,9 +9,9 @@
#include <memory>
#include "base/containers/ring_buffer.h"
#include "base/macros.h"
#include "base/time/time.h"
#include "cc/base/ring_buffer.h"
namespace cc {
......@@ -40,7 +40,7 @@ class FrameRateCounter {
void GetMinAndMaxFPS(double* min_fps, double* max_fps) const;
double GetAverageFPS() const;
typedef RingBuffer<base::TimeTicks, 136> RingBufferType;
typedef base::RingBuffer<base::TimeTicks, 136> RingBufferType;
RingBufferType::Iterator begin() const { return ring_buffer_.Begin(); }
RingBufferType::Iterator end() const { return ring_buffer_.End(); }
......
......@@ -9,12 +9,12 @@
#include <string>
#include "base/callback_forward.h"
#include "base/containers/ring_buffer.h"
#include "base/files/file_descriptor_watcher_posix.h"
#include "base/files/scoped_file.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "cc/base/ring_buffer.h"
#include "content/public/browser/arc_tracing_agent.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/resource_coordinator/public/interfaces/tracing/tracing.mojom.h"
......@@ -58,7 +58,7 @@ class ArcTracingAgentImpl : public ArcTracingAgent {
private:
base::ScopedFD read_fd_;
std::unique_ptr<base::FileDescriptorWatcher::Controller> fd_watcher_;
cc::RingBuffer<std::string, kTraceEventBufferSize> ring_buffer_;
base::RingBuffer<std::string, kTraceEventBufferSize> ring_buffer_;
// NOTE: Weak pointers must be invalidated before all other member variables
// so it must be the last member.
base::WeakPtrFactory<ArcTracingReader> weak_ptr_factory_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment