Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/memory/ptr_util.h" | 6 #include "base/memory/ptr_util.h" |
| 7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
| 8 #include "chrome/browser/sync/chrome_sync_client.h" | 8 #include "chrome/browser/sync/chrome_sync_client.h" |
| 9 #include "chrome/browser/sync/profile_sync_service_factory.h" | 9 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 // A FakeModelTypeSyncBridge that supports observing ApplySyncChanges. | 56 // A FakeModelTypeSyncBridge that supports observing ApplySyncChanges. |
| 57 class TestModelTypeSyncBridge : public FakeModelTypeSyncBridge { | 57 class TestModelTypeSyncBridge : public FakeModelTypeSyncBridge { |
| 58 public: | 58 public: |
| 59 class Observer { | 59 class Observer { |
| 60 public: | 60 public: |
| 61 virtual void OnApplySyncChanges() = 0; | 61 virtual void OnApplySyncChanges() = 0; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 TestModelTypeSyncBridge() | 64 TestModelTypeSyncBridge() |
| 65 : FakeModelTypeSyncBridge(base::Bind(&ModelTypeChangeProcessor::Create)) { | 65 : FakeModelTypeSyncBridge(base::Bind(&ModelTypeChangeProcessor::Create)) { |
| 66 change_processor()->OnMetadataLoaded(syncer::SyncError(), | 66 change_processor()->OnMetadataLoaded(db().CreateMetadataBatch()); |
| 67 db().CreateMetadataBatch()); | |
| 68 } | 67 } |
| 69 | 68 |
| 70 syncer::SyncError ApplySyncChanges( | 69 syncer::ModelError ApplySyncChanges( |
| 71 std::unique_ptr<syncer::MetadataChangeList> metadata_changes, | 70 std::unique_ptr<syncer::MetadataChangeList> metadata_changes, |
| 72 syncer::EntityChangeList entity_changes) override { | 71 syncer::EntityChangeList entity_changes) override { |
| 73 syncer::SyncError error = FakeModelTypeSyncBridge::ApplySyncChanges( | 72 syncer::ModelError error = FakeModelTypeSyncBridge::ApplySyncChanges( |
|
skym
2017/01/09 18:20:27
Seems like there should be an #include .../model_e
maxbogue
2017/01/09 21:29:33
Done.
| |
| 74 std::move(metadata_changes), entity_changes); | 73 std::move(metadata_changes), entity_changes); |
| 75 NotifyObservers(); | 74 NotifyObservers(); |
| 76 return error; | 75 return error; |
| 77 } | 76 } |
| 78 | 77 |
| 79 void AddObserver(Observer* observer) { observers_.insert(observer); } | 78 void AddObserver(Observer* observer) { observers_.insert(observer); } |
| 80 void RemoveObserver(Observer* observer) { observers_.erase(observer); } | 79 void RemoveObserver(Observer* observer) { observers_.erase(observer); } |
| 81 | 80 |
| 82 private: | 81 private: |
| 83 void NotifyObservers() { | 82 void NotifyObservers() { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, Error) { | 316 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, Error) { |
| 318 ASSERT_TRUE(SetupSync()); | 317 ASSERT_TRUE(SetupSync()); |
| 319 TestModelTypeSyncBridge* model0 = GetModelTypeSyncBridge(0); | 318 TestModelTypeSyncBridge* model0 = GetModelTypeSyncBridge(0); |
| 320 TestModelTypeSyncBridge* model1 = GetModelTypeSyncBridge(1); | 319 TestModelTypeSyncBridge* model1 = GetModelTypeSyncBridge(1); |
| 321 | 320 |
| 322 // Add an entity. | 321 // Add an entity. |
| 323 model0->WriteItem(kKey1, kValue1); | 322 model0->WriteItem(kKey1, kValue1); |
| 324 ASSERT_TRUE(DataChecker(model1, kKey1, kValue1).Wait()); | 323 ASSERT_TRUE(DataChecker(model1, kKey1, kValue1).Wait()); |
| 325 | 324 |
| 326 // Set an error in model 1 to trigger in the next GetUpdates. | 325 // Set an error in model 1 to trigger in the next GetUpdates. |
| 327 model1->ErrorOnNextCall(syncer::SyncError::DATATYPE_ERROR); | 326 model1->ErrorOnNextCall(); |
| 328 // Write an item on model 0 to trigger a GetUpdates in model 1. | 327 // Write an item on model 0 to trigger a GetUpdates in model 1. |
| 329 model0->WriteItem(kKey1, kValue2); | 328 model0->WriteItem(kKey1, kValue2); |
| 330 | 329 |
| 331 // The type should stop syncing but keep tracking metadata. | 330 // The type should stop syncing but keep tracking metadata. |
| 332 ASSERT_TRUE(PrefsNotRunningChecker(GetSyncService(1)).Wait()); | 331 ASSERT_TRUE(PrefsNotRunningChecker(GetSyncService(1)).Wait()); |
| 333 ASSERT_EQ(1U, model1->db().metadata_count()); | 332 ASSERT_EQ(1U, model1->db().metadata_count()); |
| 334 model1->WriteItem(kKey2, kValue2); | 333 model1->WriteItem(kKey2, kValue2); |
| 335 ASSERT_EQ(2U, model1->db().metadata_count()); | 334 ASSERT_EQ(2U, model1->db().metadata_count()); |
| 336 } | 335 } |
| 337 | 336 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 361 | 360 |
| 362 ASSERT_TRUE(DataChecker(model1, kKey1, kValue2).Wait()); | 361 ASSERT_TRUE(DataChecker(model1, kKey1, kValue2).Wait()); |
| 363 ASSERT_TRUE(DataChecker(model1, kKey2, kValue1).Wait()); | 362 ASSERT_TRUE(DataChecker(model1, kKey2, kValue1).Wait()); |
| 364 ASSERT_TRUE(DataChecker(model1, kKey4, kValue1).Wait()); | 363 ASSERT_TRUE(DataChecker(model1, kKey4, kValue1).Wait()); |
| 365 | 364 |
| 366 ASSERT_TRUE(DataChecker(model0, kKey1, kValue2).Wait()); | 365 ASSERT_TRUE(DataChecker(model0, kKey1, kValue2).Wait()); |
| 367 ASSERT_TRUE(DataChecker(model0, kKey3, kValue1).Wait()); | 366 ASSERT_TRUE(DataChecker(model0, kKey3, kValue1).Wait()); |
| 368 } | 367 } |
| 369 | 368 |
| 370 } // namespace | 369 } // namespace |
| OLD | NEW |