Chromium Code Reviews| Index: sync/internal_api/protocol_event_buffer.h |
| diff --git a/sync/internal_api/protocol_event_buffer.h b/sync/internal_api/protocol_event_buffer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8d82210f08eb12213c87b7e7103a1c8059908712 |
| --- /dev/null |
| +++ b/sync/internal_api/protocol_event_buffer.h |
| @@ -0,0 +1,42 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef SYNC_INTERNAL_API_PROTOCOL_EVENT_BUFFER_H_ |
| +#define SYNC_INTERNAL_API_PROTOCOL_EVENT_BUFFER_H_ |
| + |
| +#include <deque> |
| + |
| +#include "base/memory/scoped_vector.h" |
| +#include "sync/base/sync_export.h" |
| + |
| +namespace syncer { |
| + |
| +class ProtocolEvent; |
| + |
| +// A container for ProtocolEvents. |
| +// |
| +// Stores at most kBufferSize events, then starts dropping the oldest events. |
| +class SYNC_EXPORT_PRIVATE ProtocolEventBuffer { |
| + public: |
| + static const size_t kBufferSize; |
|
tim (not reviewing)
2014/03/28 20:45:42
do you actually use this anywhere besides this cla
rlarocque
2014/03/28 21:00:49
I exposed it for tests. It's a const, so I figure
|
| + |
| + ProtocolEventBuffer(); |
| + ~ProtocolEventBuffer(); |
| + |
| + // Records an event. May cause the oldest event to be dropped. |
| + void RecordProtocolEvent(const ProtocolEvent& event); |
| + |
| + // Returns the buffered contents. Will not clear the buffer. |
| + ScopedVector<ProtocolEvent> GetBufferedProtocolEvents() const; |
| + |
| + private: |
| + std::deque<ProtocolEvent*> buffer_; |
| + STLElementDeleter<std::deque<ProtocolEvent*> > buffer_deleter_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ProtocolEventBuffer); |
| +}; |
| + |
| +} // namespace syncer |
| + |
| +#endif // SYNC_INTERNAL_API_PROTOCOL_EVENT_BUFFER_H_ |