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

Side by Side Diff: sync/internal_api/public/simple_metadata_change_list.h

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
(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 SYNC_INTERNAL_API_PUBLIC_SIMPLE_METADATA_CHANGE_LIST_H_
6 #define SYNC_INTERNAL_API_PUBLIC_SIMPLE_METADATA_CHANGE_LIST_H_
7
8 #include <map>
9 #include <string>
10
11 #include "sync/api/metadata_change_list.h"
12 #include "sync/api/model_type_store.h"
13 #include "sync/base/sync_export.h"
14 #include "sync/internal_api/public/non_blocking_sync_common.h"
15 #include "sync/protocol/data_type_state.pb.h"
16 #include "sync/protocol/entity_metadata.pb.h"
17
18 namespace syncer_v2 {
19
20 // A MetadataChangeList implementation that is meant to be used in combination
21 // with a ModelTypeStore. It accumulates changes in member fields, and then when
22 // requested transfers them to the store/write batch.
23 class SYNC_EXPORT SimpleMetadataChangeList : public MetadataChangeList {
24 public:
25 enum ChangeType { UPDATE, CLEAR };
26
27 struct MetadataChange {
28 ChangeType type;
29 sync_pb::EntityMetadata metadata;
30 };
31
32 struct DataTypeStateChange {
33 ChangeType type;
34 sync_pb::DataTypeState state;
35 };
36
37 typedef std::map<std::string, MetadataChange> MetadataChanges;
38
39 SimpleMetadataChangeList();
40 ~SimpleMetadataChangeList() override;
41
42 void UpdateDataTypeState(
43 const sync_pb::DataTypeState& data_type_state) override;
44 void ClearDataTypeState() override;
45 void UpdateMetadata(const std::string& client_tag,
46 const sync_pb::EntityMetadata& metadata) override;
47 void ClearMetadata(const std::string& client_tag) override;
48
49 const MetadataChanges& GetMetadataChanges() const;
50 bool HasDataTypeStateChange() const;
51 const DataTypeStateChange& GetDataTypeStateChange() const;
52
53 // Moves all currently accumulated changes into the write batch, clear out
54 // local copies. Calling this multiple times will work, but should not be
55 // necessary.
56 void TransferChanges(ModelTypeStore* store,
57 ModelTypeStore::WriteBatch* write_batch);
58
59 private:
60 MetadataChanges metadata_changes_;
61 std::unique_ptr<DataTypeStateChange> state_change_;
62 };
63
64 } // namespace syncer_v2
65
66 #endif // SYNC_INTERNAL_API_PUBLIC_SIMPLE_METADATA_CHANGE_LIST_H_
OLDNEW
« no previous file with comments | « sync/internal_api/public/shutdown_reason.h ('k') | sync/internal_api/public/simple_metadata_change_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698