OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sync/internal_api/sync_manager_impl.h" | 5 #include "sync/internal_api/sync_manager_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 // | 949 // |
950 // Notifications are sent at the end of every sync cycle, regardless of | 950 // Notifications are sent at the end of every sync cycle, regardless of |
951 // whether we should sync again. | 951 // whether we should sync again. |
952 if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_ENDED) { | 952 if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_ENDED) { |
953 if (!initialized_) { | 953 if (!initialized_) { |
954 LOG(INFO) << "OnSyncCycleCompleted not sent because sync api is not " | 954 LOG(INFO) << "OnSyncCycleCompleted not sent because sync api is not " |
955 << "initialized"; | 955 << "initialized"; |
956 return; | 956 return; |
957 } | 957 } |
958 | 958 |
959 if (!event.snapshot.has_more_to_sync()) { | 959 DVLOG(1) << "Sending OnSyncCycleCompleted"; |
960 DVLOG(1) << "Sending OnSyncCycleCompleted"; | 960 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
961 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 961 OnSyncCycleCompleted(event.snapshot)); |
962 OnSyncCycleCompleted(event.snapshot)); | |
963 } | |
964 | 962 |
965 // This is here for tests, which are still using p2p notifications. | 963 // This is here for tests, which are still using p2p notifications. |
966 // | |
967 // TODO(chron): Consider changing this back to track has_more_to_sync | |
968 // only notify peers if a successful commit has occurred. | |
969 bool is_notifiable_commit = | 964 bool is_notifiable_commit = |
970 (event.snapshot.model_neutral_state().num_successful_commits > 0); | 965 (event.snapshot.model_neutral_state().num_successful_commits > 0); |
971 if (is_notifiable_commit) { | 966 if (is_notifiable_commit) { |
972 if (invalidator_.get()) { | 967 if (invalidator_.get()) { |
973 const ObjectIdInvalidationMap& invalidation_map = | 968 const ObjectIdInvalidationMap& invalidation_map = |
974 ModelTypeInvalidationMapToObjectIdInvalidationMap( | 969 ModelTypeInvalidationMapToObjectIdInvalidationMap( |
975 event.snapshot.source().types); | 970 event.snapshot.source().types); |
976 invalidator_->SendInvalidation(invalidation_map); | 971 invalidator_->SendInvalidation(invalidation_map); |
977 } else { | 972 } else { |
978 DVLOG(1) << "Not sending invalidation: invalidator_ is NULL"; | 973 DVLOG(1) << "Not sending invalidation: invalidator_ is NULL"; |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1307 int SyncManagerImpl::GetDefaultNudgeDelay() { |
1313 return kDefaultNudgeDelayMilliseconds; | 1308 return kDefaultNudgeDelayMilliseconds; |
1314 } | 1309 } |
1315 | 1310 |
1316 // static. | 1311 // static. |
1317 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1312 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
1318 return kPreferencesNudgeDelayMilliseconds; | 1313 return kPreferencesNudgeDelayMilliseconds; |
1319 } | 1314 } |
1320 | 1315 |
1321 } // namespace syncer | 1316 } // namespace syncer |
OLD | NEW |