OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/sync/test/integration/p2p_sync_refresher.h" | 5 #include "chrome/browser/sync/test/integration/p2p_sync_refresher.h" |
6 | 6 |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 8 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
9 #include "chrome/browser/sync/test/integration/sync_test.h" | 9 #include "chrome/browser/sync/test/integration/sync_test.h" |
10 #include "components/browser_sync/profile_sync_service.h" | 10 #include "components/browser_sync/profile_sync_service.h" |
11 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" | 11 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" |
12 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
13 | 13 |
14 P2PSyncRefresher::P2PSyncRefresher( | 14 P2PSyncRefresher::P2PSyncRefresher( |
15 Profile* profile, | 15 Profile* profile, |
16 browser_sync::ProfileSyncService* sync_service) | 16 browser_sync::ProfileSyncService* sync_service) |
17 : profile_(profile), sync_service_(sync_service) { | 17 : profile_(profile), sync_service_(sync_service) { |
18 sync_service_->AddObserver(this); | 18 sync_service_->AddObserver(this); |
19 } | 19 } |
20 | 20 |
21 P2PSyncRefresher::~P2PSyncRefresher() { | 21 P2PSyncRefresher::~P2PSyncRefresher() { |
22 sync_service_->RemoveObserver(this); | 22 sync_service_->RemoveObserver(this); |
23 } | 23 } |
24 | 24 |
25 void P2PSyncRefresher::OnStateChanged() {} | 25 void P2PSyncRefresher::OnSyncCycleCompleted(syncer::SyncService* sync) { |
26 | |
27 void P2PSyncRefresher::OnSyncCycleCompleted() { | |
28 const syncer::SyncCycleSnapshot& snap = sync_service_->GetLastCycleSnapshot(); | 26 const syncer::SyncCycleSnapshot& snap = sync_service_->GetLastCycleSnapshot(); |
29 bool is_notifiable_commit = | 27 bool is_notifiable_commit = |
30 (snap.model_neutral_state().num_successful_commits > 0); | 28 (snap.model_neutral_state().num_successful_commits > 0); |
31 if (is_notifiable_commit) { | 29 if (is_notifiable_commit) { |
32 syncer::ModelTypeSet model_types = | 30 syncer::ModelTypeSet model_types = |
33 snap.model_neutral_state().commit_request_types; | 31 snap.model_neutral_state().commit_request_types; |
34 SyncTest* test = sync_datatype_helper::test(); | 32 SyncTest* test = sync_datatype_helper::test(); |
35 for (int i = 0; i < test->num_clients(); ++i) { | 33 for (int i = 0; i < test->num_clients(); ++i) { |
36 if (profile_ != test->GetProfile(i)) | 34 if (profile_ != test->GetProfile(i)) |
37 test->TriggerSyncForModelTypes(i, model_types); | 35 test->TriggerSyncForModelTypes(i, model_types); |
38 } | 36 } |
39 } | 37 } |
40 } | 38 } |
OLD | NEW |