| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/sync/core_impl/protocol_event_buffer.h" | 5 #include "components/sync/core_impl/protocol_event_buffer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | |
| 8 | |
| 9 #include "components/sync/engine/events/protocol_event.h" | 7 #include "components/sync/engine/events/protocol_event.h" |
| 10 | 8 |
| 11 namespace syncer { | 9 namespace syncer { |
| 12 | 10 |
| 13 const size_t ProtocolEventBuffer::kBufferSize = 6; | 11 const size_t ProtocolEventBuffer::kBufferSize = 6; |
| 14 | 12 |
| 15 ProtocolEventBuffer::ProtocolEventBuffer() {} | 13 ProtocolEventBuffer::ProtocolEventBuffer() {} |
| 16 | 14 |
| 17 ProtocolEventBuffer::~ProtocolEventBuffer() {} | 15 ProtocolEventBuffer::~ProtocolEventBuffer() {} |
| 18 | 16 |
| 19 void ProtocolEventBuffer::RecordProtocolEvent(const ProtocolEvent& event) { | 17 void ProtocolEventBuffer::RecordProtocolEvent(const ProtocolEvent& event) { |
| 20 buffer_.push_back(event.Clone()); | 18 buffer_.push_back(event.Clone()); |
| 21 if (buffer_.size() > kBufferSize) | 19 if (buffer_.size() > kBufferSize) |
| 22 buffer_.pop_front(); | 20 buffer_.pop_front(); |
| 23 } | 21 } |
| 24 | 22 |
| 25 std::vector<std::unique_ptr<ProtocolEvent>> | 23 std::vector<std::unique_ptr<ProtocolEvent>> |
| 26 ProtocolEventBuffer::GetBufferedProtocolEvents() const { | 24 ProtocolEventBuffer::GetBufferedProtocolEvents() const { |
| 27 std::vector<std::unique_ptr<ProtocolEvent>> ret; | 25 std::vector<std::unique_ptr<ProtocolEvent>> ret; |
| 28 for (auto& event : buffer_) | 26 for (auto& event : buffer_) |
| 29 ret.push_back(event->Clone()); | 27 ret.push_back(event->Clone()); |
| 30 | 28 |
| 31 return ret; | 29 return ret; |
| 32 } | 30 } |
| 33 | 31 |
| 34 } // namespace syncer | 32 } // namespace syncer |
| OLD | NEW |