Provide GUID in ONC for all networks in ManagedNetworkConfigurationHandler
[chromium-blink-merge.git] / sync / internal_api / protocol_event_buffer.cc
blob2e9ba64407b44ea4a8b1b08b5ec485f447d0263b
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "sync/internal_api/protocol_event_buffer.h"
7 #include "sync/internal_api/public/events/protocol_event.h"
9 namespace syncer {
11 const size_t ProtocolEventBuffer::kBufferSize = 6;
13 ProtocolEventBuffer::ProtocolEventBuffer()
14 : buffer_deleter_(&buffer_) {}
16 ProtocolEventBuffer::~ProtocolEventBuffer() {}
18 void ProtocolEventBuffer::RecordProtocolEvent(const ProtocolEvent& event) {
19 buffer_.push_back(event.Clone().release());
20 if (buffer_.size() > kBufferSize) {
21 ProtocolEvent* to_delete = buffer_.front();
22 buffer_.pop_front();
23 delete to_delete;
27 ScopedVector<ProtocolEvent>
28 ProtocolEventBuffer::GetBufferedProtocolEvents() const {
29 ScopedVector<ProtocolEvent> ret;
30 for (std::deque<ProtocolEvent*>::const_iterator it = buffer_.begin();
31 it != buffer_.end(); ++it) {
32 ret.push_back((*it)->Clone().release());
34 return ret.Pass();
37 } // namespace syncer