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

Side by Side Diff: components/sync/model_impl/accumulating_metadata_change_list.cc

Issue 2473553003: [Sync] Improve MetadataChangeList usage for types using ModelTypeStore. (Closed)
Patch Set: Fix comments + protected constructor. Created 4 years, 1 month 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 2016 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 "components/sync/model_impl/accumulating_metadata_change_list.h"
6
7 namespace syncer {
8
9 AccumulatingMetadataChangeList::AccumulatingMetadataChangeList() {}
10 AccumulatingMetadataChangeList::~AccumulatingMetadataChangeList() {}
11
12 void AccumulatingMetadataChangeList::TransferChanges(
13 ModelTypeStore* store,
14 ModelTypeStore::WriteBatch* write_batch) {
15 DCHECK(write_batch);
16 DCHECK(store);
17 for (const auto& pair : metadata_changes_) {
18 const std::string& storage_key = pair.first;
19 const MetadataChange& change = pair.second;
20 switch (change.type) {
21 case UPDATE:
22 store->WriteMetadata(write_batch, storage_key,
23 change.metadata.SerializeAsString());
24 break;
25 case CLEAR:
26 store->DeleteMetadata(write_batch, storage_key);
27 break;
28 }
29 }
30 metadata_changes_.clear();
31 if (state_change_) {
32 switch (state_change_->type) {
33 case UPDATE:
34 store->WriteGlobalMetadata(write_batch,
35 state_change_->state.SerializeAsString());
36 break;
37 case CLEAR:
38 store->DeleteGlobalMetadata(write_batch);
39 break;
40 }
41 state_change_.reset();
42 }
43 }
44
45 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698