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/engine_impl/events/protocol_event_buffer.h" |
6 | 6 |
7 #include "components/sync/engine/events/protocol_event.h" | 7 #include "components/sync/engine/events/protocol_event.h" |
8 | 8 |
9 namespace syncer { | 9 namespace syncer { |
10 | 10 |
11 const size_t ProtocolEventBuffer::kBufferSize = 6; | 11 const size_t ProtocolEventBuffer::kBufferSize = 6; |
12 | 12 |
13 ProtocolEventBuffer::ProtocolEventBuffer() {} | 13 ProtocolEventBuffer::ProtocolEventBuffer() {} |
14 | 14 |
15 ProtocolEventBuffer::~ProtocolEventBuffer() {} | 15 ProtocolEventBuffer::~ProtocolEventBuffer() {} |
16 | 16 |
17 void ProtocolEventBuffer::RecordProtocolEvent(const ProtocolEvent& event) { | 17 void ProtocolEventBuffer::RecordProtocolEvent(const ProtocolEvent& event) { |
18 buffer_.push_back(event.Clone()); | 18 buffer_.push_back(event.Clone()); |
19 if (buffer_.size() > kBufferSize) | 19 if (buffer_.size() > kBufferSize) |
20 buffer_.pop_front(); | 20 buffer_.pop_front(); |
21 } | 21 } |
22 | 22 |
23 std::vector<std::unique_ptr<ProtocolEvent>> | 23 std::vector<std::unique_ptr<ProtocolEvent>> |
24 ProtocolEventBuffer::GetBufferedProtocolEvents() const { | 24 ProtocolEventBuffer::GetBufferedProtocolEvents() const { |
25 std::vector<std::unique_ptr<ProtocolEvent>> ret; | 25 std::vector<std::unique_ptr<ProtocolEvent>> ret; |
26 for (auto& event : buffer_) | 26 for (auto& event : buffer_) |
27 ret.push_back(event->Clone()); | 27 ret.push_back(event->Clone()); |
28 | 28 |
29 return ret; | 29 return ret; |
30 } | 30 } |
31 | 31 |
32 } // namespace syncer | 32 } // namespace syncer |
OLD | NEW |