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

Side by Side Diff: components/sync/core/data_batch_impl.h

Issue 2416823003: [Sync] Move some things from core/ to model(_impl)/. (Closed)
Patch Set: Rebase. Created 4 years, 2 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
« no previous file with comments | « components/sync/BUILD.gn ('k') | components/sync/core/data_batch_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 #ifndef COMPONENTS_SYNC_CORE_DATA_BATCH_IMPL_H_
6 #define COMPONENTS_SYNC_CORE_DATA_BATCH_IMPL_H_
7
8 #include <stddef.h>
9
10 #include <memory>
11 #include <string>
12 #include <utility>
13 #include <vector>
14
15 #include "base/macros.h"
16 #include "components/sync/model/data_batch.h"
17 #include "components/sync/model/entity_data.h"
18
19 namespace syncer {
20
21 // An implementation of DataBatch that's purpose is to transfer ownership of
22 // EntityData objects. As soon as this batch recieves the EntityData, it owns
23 // them until Next() is invoked, when it gives up ownerhsip. Because a vector
24 // is used internally, this impl is unaware when duplcate storage_keys are used,
25 // and it is the caller's job to avoid this.
26 class DataBatchImpl : public DataBatch {
27 public:
28 DataBatchImpl();
29 ~DataBatchImpl() override;
30
31 // Takes ownership of the data tied to a given key used for storage. Put
32 // should be called at most once for any given storfage_key. Data will be
33 // readable in the same order that they are put into the batch.
34 void Put(const std::string& storage_key,
35 std::unique_ptr<EntityData> entity_data);
36
37 // DataBatch implementation.
38 bool HasNext() const override;
39 KeyAndData Next() override;
40
41 private:
42 std::vector<KeyAndData> key_data_pairs_;
43 size_t read_index_ = 0;
44
45 DISALLOW_COPY_AND_ASSIGN(DataBatchImpl);
46 };
47
48 } // namespace syncer
49
50 #endif // COMPONENTS_SYNC_CORE_DATA_BATCH_IMPL_H_
OLDNEW
« no previous file with comments | « components/sync/BUILD.gn ('k') | components/sync/core/data_batch_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698