Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: sync/internal_api/protocol_event_buffer.cc

Issue 212603007: sync: Buffer Protocol Events for about:sync page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "sync/internal_api/protocol_event_buffer.h"
6
7 #include "sync/internal_api/public/events/protocol_event.h"
8
9 namespace syncer {
10
11 const size_t ProtocolEventBuffer::kBufferSize = 6;
12
13 ProtocolEventBuffer::ProtocolEventBuffer()
14 : buffer_deleter_(&buffer_) {}
15
16 ProtocolEventBuffer::~ProtocolEventBuffer() {}
17
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;
24 }
25 }
26
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());
33 }
34 return ret.Pass();
35 }
36
37 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/protocol_event_buffer.h ('k') | sync/internal_api/protocol_event_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698