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

Side by Side Diff: components/sync/core_impl/protocol_event_buffer.cc

Issue 2284283002: Remove stl_util's STLElementDeleter from sync. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
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> 7 #include <stddef.h>
8 8
9 #include "components/sync/engine/events/protocol_event.h" 9 #include "components/sync/engine/events/protocol_event.h"
10 10
11 namespace syncer { 11 namespace syncer {
12 12
13 const size_t ProtocolEventBuffer::kBufferSize = 6; 13 const size_t ProtocolEventBuffer::kBufferSize = 6;
14 14
15 ProtocolEventBuffer::ProtocolEventBuffer() : buffer_deleter_(&buffer_) {} 15 ProtocolEventBuffer::ProtocolEventBuffer() {}
16 16
17 ProtocolEventBuffer::~ProtocolEventBuffer() {} 17 ProtocolEventBuffer::~ProtocolEventBuffer() {}
18 18
19 void ProtocolEventBuffer::RecordProtocolEvent(const ProtocolEvent& event) { 19 void ProtocolEventBuffer::RecordProtocolEvent(const ProtocolEvent& event) {
20 buffer_.push_back(event.Clone().release()); 20 buffer_.push_back(event.Clone());
21 if (buffer_.size() > kBufferSize) { 21 if (buffer_.size() > kBufferSize)
22 ProtocolEvent* to_delete = buffer_.front();
23 buffer_.pop_front(); 22 buffer_.pop_front();
24 delete to_delete;
25 }
26 } 23 }
27 24
28 ScopedVector<ProtocolEvent> ProtocolEventBuffer::GetBufferedProtocolEvents() 25 std::vector<std::unique_ptr<ProtocolEvent>>
29 const { 26 ProtocolEventBuffer::GetBufferedProtocolEvents() const {
30 ScopedVector<ProtocolEvent> ret; 27 std::vector<std::unique_ptr<ProtocolEvent>> ret;
31 for (std::deque<ProtocolEvent*>::const_iterator it = buffer_.begin(); 28 for (auto& event : buffer_)
32 it != buffer_.end(); ++it) { 29 ret.push_back(event->Clone());
33 ret.push_back((*it)->Clone()); 30
34 }
35 return ret; 31 return ret;
36 } 32 }
37 33
38 } // namespace syncer 34 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/core_impl/protocol_event_buffer.h ('k') | components/sync/core_impl/protocol_event_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698