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

Side by Side Diff: components/sync/model/recording_model_type_change_processor.cc

Issue 2961723003: [USS] Implement ApplySyncChanges and OnURLVisited/Modified/Deleted. (Closed)
Patch Set: update pavel's review Created 3 years, 5 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/model/recording_model_type_change_processor.h" 5 #include "components/sync/model/recording_model_type_change_processor.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "components/sync/model/fake_model_type_sync_bridge.h"
11 #include "components/sync/model/metadata_batch.h" 12 #include "components/sync/model/metadata_batch.h"
12 13
13 namespace syncer { 14 namespace syncer {
14 15
15 namespace { 16 namespace {
16 17
17 std::unique_ptr<ModelTypeChangeProcessor> CreateAndAssignProcessor( 18 std::unique_ptr<ModelTypeChangeProcessor> CreateAndAssignProcessor(
18 RecordingModelTypeChangeProcessor** processor_address, 19 RecordingModelTypeChangeProcessor** processor_address,
19 bool expect_error, 20 bool expect_error,
20 ModelType type, 21 ModelType type,
(...skipping 10 matching lines...) Expand all
31 } // namespace 32 } // namespace
32 33
33 RecordingModelTypeChangeProcessor::RecordingModelTypeChangeProcessor() {} 34 RecordingModelTypeChangeProcessor::RecordingModelTypeChangeProcessor() {}
34 35
35 RecordingModelTypeChangeProcessor::~RecordingModelTypeChangeProcessor() {} 36 RecordingModelTypeChangeProcessor::~RecordingModelTypeChangeProcessor() {}
36 37
37 void RecordingModelTypeChangeProcessor::Put( 38 void RecordingModelTypeChangeProcessor::Put(
38 const std::string& storage_key, 39 const std::string& storage_key,
39 std::unique_ptr<EntityData> entity_data, 40 std::unique_ptr<EntityData> entity_data,
40 MetadataChangeList* metadata_changes) { 41 MetadataChangeList* metadata_changes) {
42 if (entity_data->modification_time.is_null())
43 entity_data->modification_time = base::Time::Now();
41 put_multimap_.insert(std::make_pair(storage_key, std::move(entity_data))); 44 put_multimap_.insert(std::make_pair(storage_key, std::move(entity_data)));
42 } 45 }
43 46
44 void RecordingModelTypeChangeProcessor::Delete( 47 void RecordingModelTypeChangeProcessor::Delete(
45 const std::string& storage_key, 48 const std::string& storage_key,
46 MetadataChangeList* metadata_changes) { 49 MetadataChangeList* metadata_changes) {
47 delete_set_.insert(storage_key); 50 delete_set_.insert(storage_key);
48 } 51 }
49 52
53 void RecordingModelTypeChangeProcessor::UpdateStorageKey(
54 const EntityData& entity_data,
55 const std::string& storage_key,
56 MetadataChangeList* metadata_change_list) {
57 update_multimap_.insert(std::make_pair(
58 storage_key, FakeModelTypeSyncBridge::CopyEntityData(entity_data)));
59 }
60
61 void RecordingModelTypeChangeProcessor::UntrackEntity(
62 const EntityData& entity_data) {
63 untrack_set_.insert(FakeModelTypeSyncBridge::CopyEntityData(entity_data));
64 }
65
50 void RecordingModelTypeChangeProcessor::ModelReadyToSync( 66 void RecordingModelTypeChangeProcessor::ModelReadyToSync(
51 std::unique_ptr<MetadataBatch> batch) { 67 std::unique_ptr<MetadataBatch> batch) {
52 std::swap(metadata_, batch); 68 std::swap(metadata_, batch);
53 } 69 }
54 70
55 bool RecordingModelTypeChangeProcessor::IsTrackingMetadata() { 71 bool RecordingModelTypeChangeProcessor::IsTrackingMetadata() {
56 return is_tracking_metadata_; 72 return is_tracking_metadata_;
57 } 73 }
58 74
59 void RecordingModelTypeChangeProcessor::SetIsTrackingMetadata( 75 void RecordingModelTypeChangeProcessor::SetIsTrackingMetadata(
60 bool is_tracking) { 76 bool is_tracking) {
61 is_tracking_metadata_ = is_tracking; 77 is_tracking_metadata_ = is_tracking;
62 } 78 }
63 79
64 // static 80 // static
65 ModelTypeSyncBridge::ChangeProcessorFactory 81 ModelTypeSyncBridge::ChangeProcessorFactory
66 RecordingModelTypeChangeProcessor::FactoryForBridgeTest( 82 RecordingModelTypeChangeProcessor::FactoryForBridgeTest(
67 RecordingModelTypeChangeProcessor** processor_address, 83 RecordingModelTypeChangeProcessor** processor_address,
68 bool expect_error) { 84 bool expect_error) {
69 return base::Bind(&CreateAndAssignProcessor, 85 return base::Bind(&CreateAndAssignProcessor,
70 base::Unretained(processor_address), expect_error); 86 base::Unretained(processor_address), expect_error);
71 } 87 }
72 88
73 } // namespace syncer 89 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698