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

Side by Side Diff: chrome/browser/sync/test/integration/two_client_uss_sync_test.cc

Issue 2618483003: [Sync] Introduce ModelError for USS error handling. (Closed)
Patch Set: Address comments. Created 3 years, 11 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
« no previous file with comments | « no previous file | components/autofill/core/browser/webdata/autocomplete_sync_bridge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h" 11 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h"
12 #include "chrome/browser/sync/test/integration/status_change_checker.h" 12 #include "chrome/browser/sync/test/integration/status_change_checker.h"
13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" 13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
14 #include "chrome/browser/sync/test/integration/sync_test.h" 14 #include "chrome/browser/sync/test/integration/sync_test.h"
15 #include "components/browser_sync/profile_sync_components_factory_impl.h" 15 #include "components/browser_sync/profile_sync_components_factory_impl.h"
16 #include "components/browser_sync/profile_sync_service.h" 16 #include "components/browser_sync/profile_sync_service.h"
17 #include "components/sync/model/fake_model_type_sync_bridge.h" 17 #include "components/sync/model/fake_model_type_sync_bridge.h"
18 #include "components/sync/model/metadata_change_list.h" 18 #include "components/sync/model/metadata_change_list.h"
19 #include "components/sync/model/model_error.h"
19 #include "components/sync/model/model_type_change_processor.h" 20 #include "components/sync/model/model_type_change_processor.h"
20 21
21 using browser_sync::ChromeSyncClient; 22 using browser_sync::ChromeSyncClient;
22 using browser_sync::ProfileSyncComponentsFactoryImpl; 23 using browser_sync::ProfileSyncComponentsFactoryImpl;
23 using syncer::ConflictResolution; 24 using syncer::ConflictResolution;
24 using syncer::FakeModelTypeSyncBridge; 25 using syncer::FakeModelTypeSyncBridge;
25 using syncer::ModelTypeChangeProcessor; 26 using syncer::ModelTypeChangeProcessor;
26 using syncer::ModelTypeSyncBridge; 27 using syncer::ModelTypeSyncBridge;
27 28
28 namespace { 29 namespace {
(...skipping 27 matching lines...) Expand all
56 // A FakeModelTypeSyncBridge that supports observing ApplySyncChanges. 57 // A FakeModelTypeSyncBridge that supports observing ApplySyncChanges.
57 class TestModelTypeSyncBridge : public FakeModelTypeSyncBridge { 58 class TestModelTypeSyncBridge : public FakeModelTypeSyncBridge {
58 public: 59 public:
59 class Observer { 60 class Observer {
60 public: 61 public:
61 virtual void OnApplySyncChanges() = 0; 62 virtual void OnApplySyncChanges() = 0;
62 }; 63 };
63 64
64 TestModelTypeSyncBridge() 65 TestModelTypeSyncBridge()
65 : FakeModelTypeSyncBridge(base::Bind(&ModelTypeChangeProcessor::Create)) { 66 : FakeModelTypeSyncBridge(base::Bind(&ModelTypeChangeProcessor::Create)) {
66 change_processor()->OnMetadataLoaded(syncer::SyncError(), 67 change_processor()->OnMetadataLoaded(db().CreateMetadataBatch());
67 db().CreateMetadataBatch());
68 } 68 }
69 69
70 syncer::SyncError ApplySyncChanges( 70 syncer::ModelError ApplySyncChanges(
71 std::unique_ptr<syncer::MetadataChangeList> metadata_changes, 71 std::unique_ptr<syncer::MetadataChangeList> metadata_changes,
72 syncer::EntityChangeList entity_changes) override { 72 syncer::EntityChangeList entity_changes) override {
73 syncer::SyncError error = FakeModelTypeSyncBridge::ApplySyncChanges( 73 syncer::ModelError error = FakeModelTypeSyncBridge::ApplySyncChanges(
74 std::move(metadata_changes), entity_changes); 74 std::move(metadata_changes), entity_changes);
75 NotifyObservers(); 75 NotifyObservers();
76 return error; 76 return error;
77 } 77 }
78 78
79 void AddObserver(Observer* observer) { observers_.insert(observer); } 79 void AddObserver(Observer* observer) { observers_.insert(observer); }
80 void RemoveObserver(Observer* observer) { observers_.erase(observer); } 80 void RemoveObserver(Observer* observer) { observers_.erase(observer); }
81 81
82 private: 82 private:
83 void NotifyObservers() { 83 void NotifyObservers() {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, Error) { 317 IN_PROC_BROWSER_TEST_F(TwoClientUssSyncTest, Error) {
318 ASSERT_TRUE(SetupSync()); 318 ASSERT_TRUE(SetupSync());
319 TestModelTypeSyncBridge* model0 = GetModelTypeSyncBridge(0); 319 TestModelTypeSyncBridge* model0 = GetModelTypeSyncBridge(0);
320 TestModelTypeSyncBridge* model1 = GetModelTypeSyncBridge(1); 320 TestModelTypeSyncBridge* model1 = GetModelTypeSyncBridge(1);
321 321
322 // Add an entity. 322 // Add an entity.
323 model0->WriteItem(kKey1, kValue1); 323 model0->WriteItem(kKey1, kValue1);
324 ASSERT_TRUE(DataChecker(model1, kKey1, kValue1).Wait()); 324 ASSERT_TRUE(DataChecker(model1, kKey1, kValue1).Wait());
325 325
326 // Set an error in model 1 to trigger in the next GetUpdates. 326 // Set an error in model 1 to trigger in the next GetUpdates.
327 model1->ErrorOnNextCall(syncer::SyncError::DATATYPE_ERROR); 327 model1->ErrorOnNextCall();
328 // Write an item on model 0 to trigger a GetUpdates in model 1. 328 // Write an item on model 0 to trigger a GetUpdates in model 1.
329 model0->WriteItem(kKey1, kValue2); 329 model0->WriteItem(kKey1, kValue2);
330 330
331 // The type should stop syncing but keep tracking metadata. 331 // The type should stop syncing but keep tracking metadata.
332 ASSERT_TRUE(PrefsNotRunningChecker(GetSyncService(1)).Wait()); 332 ASSERT_TRUE(PrefsNotRunningChecker(GetSyncService(1)).Wait());
333 ASSERT_EQ(1U, model1->db().metadata_count()); 333 ASSERT_EQ(1U, model1->db().metadata_count());
334 model1->WriteItem(kKey2, kValue2); 334 model1->WriteItem(kKey2, kValue2);
335 ASSERT_EQ(2U, model1->db().metadata_count()); 335 ASSERT_EQ(2U, model1->db().metadata_count());
336 } 336 }
337 337
(...skipping 23 matching lines...) Expand all
361 361
362 ASSERT_TRUE(DataChecker(model1, kKey1, kValue2).Wait()); 362 ASSERT_TRUE(DataChecker(model1, kKey1, kValue2).Wait());
363 ASSERT_TRUE(DataChecker(model1, kKey2, kValue1).Wait()); 363 ASSERT_TRUE(DataChecker(model1, kKey2, kValue1).Wait());
364 ASSERT_TRUE(DataChecker(model1, kKey4, kValue1).Wait()); 364 ASSERT_TRUE(DataChecker(model1, kKey4, kValue1).Wait());
365 365
366 ASSERT_TRUE(DataChecker(model0, kKey1, kValue2).Wait()); 366 ASSERT_TRUE(DataChecker(model0, kKey1, kValue2).Wait());
367 ASSERT_TRUE(DataChecker(model0, kKey3, kValue1).Wait()); 367 ASSERT_TRUE(DataChecker(model0, kKey3, kValue1).Wait());
368 } 368 }
369 369
370 } // namespace 370 } // namespace
OLDNEW
« no previous file with comments | « no previous file | components/autofill/core/browser/webdata/autocomplete_sync_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698