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

Side by Side Diff: components/sync/user_events/user_event_sync_bridge.cc

Issue 2916133002: [Sync] Support commit only types. (Closed)
Patch Set: Rebase again. Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/user_events/user_event_sync_bridge.h" 5 #include "components/sync/user_events/user_event_sync_bridge.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/big_endian.h" 9 #include "base/big_endian.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 base::Optional<ModelError> UserEventSyncBridge::MergeSyncData( 77 base::Optional<ModelError> UserEventSyncBridge::MergeSyncData(
78 std::unique_ptr<MetadataChangeList> metadata_change_list, 78 std::unique_ptr<MetadataChangeList> metadata_change_list,
79 EntityDataMap entity_data_map) { 79 EntityDataMap entity_data_map) {
80 NOTREACHED(); 80 NOTREACHED();
81 return {}; 81 return {};
82 } 82 }
83 83
84 base::Optional<ModelError> UserEventSyncBridge::ApplySyncChanges( 84 base::Optional<ModelError> UserEventSyncBridge::ApplySyncChanges(
85 std::unique_ptr<MetadataChangeList> metadata_change_list, 85 std::unique_ptr<MetadataChangeList> metadata_change_list,
86 EntityChangeList entity_changes) { 86 EntityChangeList entity_changes) {
87 NOTREACHED(); 87 std::unique_ptr<WriteBatch> batch = store_->CreateWriteBatch();
88 for (EntityChange& change : entity_changes) {
89 DCHECK_EQ(EntityChange::ACTION_DELETE, change.type());
90 batch->DeleteData(change.storage_key());
91 }
92 batch->TransferMetadataChanges(std::move(metadata_change_list));
93 store_->CommitWriteBatch(
94 std::move(batch),
95 base::Bind(&UserEventSyncBridge::OnCommit, base::AsWeakPtr(this)));
88 return {}; 96 return {};
89 } 97 }
90 98
91 void UserEventSyncBridge::GetData(StorageKeyList storage_keys, 99 void UserEventSyncBridge::GetData(StorageKeyList storage_keys,
92 DataCallback callback) { 100 DataCallback callback) {
93 store_->ReadData(storage_keys, base::Bind(&UserEventSyncBridge::OnReadData, 101 store_->ReadData(storage_keys, base::Bind(&UserEventSyncBridge::OnReadData,
94 base::AsWeakPtr(this), callback)); 102 base::AsWeakPtr(this), callback));
95 } 103 }
96 104
97 void UserEventSyncBridge::GetAllData(DataCallback callback) { 105 void UserEventSyncBridge::GetAllData(DataCallback callback) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 std::unique_ptr<WriteBatch> batch = store_->CreateWriteBatch(); 213 std::unique_ptr<WriteBatch> batch = store_->CreateWriteBatch();
206 for (const Record& r : *data_records) { 214 for (const Record& r : *data_records) {
207 batch->DeleteData(r.id); 215 batch->DeleteData(r.id);
208 } 216 }
209 store_->CommitWriteBatch( 217 store_->CommitWriteBatch(
210 std::move(batch), 218 std::move(batch),
211 base::Bind(&UserEventSyncBridge::OnCommit, base::AsWeakPtr(this))); 219 base::Bind(&UserEventSyncBridge::OnCommit, base::AsWeakPtr(this)));
212 } 220 }
213 221
214 } // namespace syncer 222 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/test/engine/mock_connection_manager.cc ('k') | components/sync/user_events/user_event_sync_bridge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698