| 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 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 // | 955 // |
| 956 // Notifications are sent at the end of every sync cycle, regardless of | 956 // Notifications are sent at the end of every sync cycle, regardless of |
| 957 // whether we should sync again. | 957 // whether we should sync again. |
| 958 if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_ENDED) { | 958 if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_ENDED) { |
| 959 if (!initialized_) { | 959 if (!initialized_) { |
| 960 LOG(INFO) << "OnSyncCycleCompleted not sent because sync api is not " | 960 LOG(INFO) << "OnSyncCycleCompleted not sent because sync api is not " |
| 961 << "initialized"; | 961 << "initialized"; |
| 962 return; | 962 return; |
| 963 } | 963 } |
| 964 | 964 |
| 965 if (!event.snapshot.has_more_to_sync()) { | 965 DVLOG(1) << "Sending OnSyncCycleCompleted"; |
| 966 DVLOG(1) << "Sending OnSyncCycleCompleted"; | 966 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
| 967 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, | 967 OnSyncCycleCompleted(event.snapshot)); |
| 968 OnSyncCycleCompleted(event.snapshot)); | |
| 969 } | |
| 970 | 968 |
| 971 // This is here for tests, which are still using p2p notifications. | 969 // This is here for tests, which are still using p2p notifications. |
| 972 // | |
| 973 // TODO(chron): Consider changing this back to track has_more_to_sync | |
| 974 // only notify peers if a successful commit has occurred. | |
| 975 bool is_notifiable_commit = | 970 bool is_notifiable_commit = |
| 976 (event.snapshot.model_neutral_state().num_successful_commits > 0); | 971 (event.snapshot.model_neutral_state().num_successful_commits > 0); |
| 977 if (is_notifiable_commit) { | 972 if (is_notifiable_commit) { |
| 978 if (invalidator_.get()) { | 973 if (invalidator_.get()) { |
| 979 const ObjectIdInvalidationMap& invalidation_map = | 974 const ObjectIdInvalidationMap& invalidation_map = |
| 980 ModelTypeInvalidationMapToObjectIdInvalidationMap( | 975 ModelTypeInvalidationMapToObjectIdInvalidationMap( |
| 981 event.snapshot.source().types); | 976 event.snapshot.source().types); |
| 982 invalidator_->SendInvalidation(invalidation_map); | 977 invalidator_->SendInvalidation(invalidation_map); |
| 983 } else { | 978 } else { |
| 984 DVLOG(1) << "Not sending invalidation: invalidator_ is NULL"; | 979 DVLOG(1) << "Not sending invalidation: invalidator_ is NULL"; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1313 int SyncManagerImpl::GetDefaultNudgeDelay() { |
| 1319 return kDefaultNudgeDelayMilliseconds; | 1314 return kDefaultNudgeDelayMilliseconds; |
| 1320 } | 1315 } |
| 1321 | 1316 |
| 1322 // static. | 1317 // static. |
| 1323 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1318 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
| 1324 return kPreferencesNudgeDelayMilliseconds; | 1319 return kPreferencesNudgeDelayMilliseconds; |
| 1325 } | 1320 } |
| 1326 | 1321 |
| 1327 } // namespace syncer | 1322 } // namespace syncer |
| OLD | NEW |